From 392b8bc9f98d762b6b9e295e3954f8008610552a Mon Sep 17 00:00:00 2001 From: worldofpeace Date: Mon, 27 Apr 2020 22:35:31 -0400 Subject: [PATCH] nixos-artwork: add file path attributes This makes things so much easier, and we install to the path that both gnome-backgrounds and elementary-wallpapers install to. (cherry picked from commit 62587f43ddf884335f2ed0ee83673d9ffa9a2465) --- .../services/x11/desktop-managers/gnome3.nix | 4 ++-- .../services/x11/display-managers/lightdm.nix | 6 +++++- nixos/modules/system/boot/loader/grub/grub.nix | 2 +- pkgs/data/misc/nixos-artwork/wallpapers.nix | 14 +++++++++++++- .../elementary-default-settings/default.nix | 2 +- .../desktop/elementary-greeter/default.nix | 4 ++-- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/x11/desktop-managers/gnome3.nix b/nixos/modules/services/x11/desktop-managers/gnome3.nix index b393b81413493..ba20ee85485f6 100644 --- a/nixos/modules/services/x11/desktop-managers/gnome3.nix +++ b/nixos/modules/services/x11/desktop-managers/gnome3.nix @@ -37,10 +37,10 @@ let chmod -R a+w $out/share/gsettings-schemas/nixos-gsettings-overrides cat - > $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas/nixos-defaults.gschema.override <<- EOF [org.gnome.desktop.background] - picture-uri='file://${pkgs.nixos-artwork.wallpapers.simple-dark-gray}/share/artwork/gnome/nix-wallpaper-simple-dark-gray.png' + picture-uri='file://${pkgs.nixos-artwork.wallpapers.simple-dark-gray.gnomeFilePath}' [org.gnome.desktop.screensaver] - picture-uri='file://${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom}/share/artwork/gnome/nix-wallpaper-simple-dark-gray_bottom.png' + picture-uri='file://${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom.gnomeFilePath}' [org.gnome.shell] favorite-apps=[ 'org.gnome.Epiphany.desktop', 'org.gnome.Geary.desktop', 'org.gnome.Music.desktop', 'org.gnome.Photos.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Software.desktop' ] diff --git a/nixos/modules/services/x11/display-managers/lightdm.nix b/nixos/modules/services/x11/display-managers/lightdm.nix index f7face0adb7ef..8f5e2b4164519 100644 --- a/nixos/modules/services/x11/display-managers/lightdm.nix +++ b/nixos/modules/services/x11/display-managers/lightdm.nix @@ -128,7 +128,8 @@ in background = mkOption { type = types.str; - default = "${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom}/share/artwork/gnome/nix-wallpaper-simple-dark-gray_bottom.png"; + # Manual cannot depend on packages, we are actually setting the default in config below. + defaultText = "pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom.gnomeFilePath"; description = '' The background image or color to use. ''; @@ -207,6 +208,9 @@ in } ]; + # Keep in sync with the defaultText value from the option definition. + services.xserver.displayManager.lightdm.background = mkDefault pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom.gnomeFilePath; + # Set default session in session chooser to a specified values – basically ignore session history. # Auto-login is already covered by a config value. services.xserver.displayManager.job.preStart = optionalString (!cfg.autoLogin.enable && dmcfg.defaultSession != null) '' diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 26c1197bf975f..55e648b643416 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -83,7 +83,7 @@ let ] ++ (optional (cfg.fontSize!=null) "--size ${toString cfg.fontSize}"))) ); - defaultSplash = "${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bootloader}/share/artwork/gnome/nix-wallpaper-simple-dark-gray_bootloader.png"; + defaultSplash = pkgs.nixos-artwork.wallpapers.simple-dark-gray-bootloader.gnomeFilePath; in { diff --git a/pkgs/data/misc/nixos-artwork/wallpapers.nix b/pkgs/data/misc/nixos-artwork/wallpapers.nix index 3983869a45289..ef5ea6034e1ca 100644 --- a/pkgs/data/misc/nixos-artwork/wallpapers.nix +++ b/pkgs/data/misc/nixos-artwork/wallpapers.nix @@ -3,12 +3,18 @@ let mkNixBackground = { name, src, description }: - stdenv.mkDerivation { + let + pkg = stdenv.mkDerivation { inherit name src; dontUnpack = true; installPhase = '' + # GNOME + mkdir -p $out/share/backgrounds/nixos + ln -s $src $out/share/backgrounds/nixos/${src.name} + + # TODO: is this path still needed? mkdir -p $out/share/artwork/gnome ln -s $src $out/share/artwork/gnome/${src.name} @@ -22,6 +28,11 @@ X-KDE-PluginInfo-Name=${name} _EOF ''; + passthru = { + gnomeFilePath = "${pkg}/share/backgrounds/nixos/${src.name}"; + kdeFilePath = "${pkg}/share/wallpapers/${name}/contents/images/${src.name}"; + }; + meta = with stdenv.lib; { inherit description; homepage = https://github.com/NixOS/nixos-artwork; @@ -29,6 +40,7 @@ _EOF platforms = platforms.all; }; }; +in pkg; in diff --git a/pkgs/desktops/pantheon/desktop/elementary-default-settings/default.nix b/pkgs/desktops/pantheon/desktop/elementary-default-settings/default.nix index be97c5903eb39..86192fdc377da 100644 --- a/pkgs/desktops/pantheon/desktop/elementary-default-settings/default.nix +++ b/pkgs/desktops/pantheon/desktop/elementary-default-settings/default.nix @@ -49,7 +49,7 @@ stdenv.mkDerivation rec { mesonFlags = [ "--sysconfdir=${placeholder "out"}/etc" - "-Ddefault-wallpaper=${nixos-artwork.wallpapers.simple-dark-gray}/share/artwork/gnome/nix-wallpaper-simple-dark-gray.png" + "-Ddefault-wallpaper=${nixos-artwork.wallpapers.simple-dark-gray.gnomeFilePath}" "-Dplank-dockitems=false" ]; diff --git a/pkgs/desktops/pantheon/desktop/elementary-greeter/default.nix b/pkgs/desktops/pantheon/desktop/elementary-greeter/default.nix index 407e9e354066a..58a7f01393821 100644 --- a/pkgs/desktops/pantheon/desktop/elementary-greeter/default.nix +++ b/pkgs/desktops/pantheon/desktop/elementary-greeter/default.nix @@ -89,7 +89,7 @@ stdenv.mkDerivation rec { # Needed until https://github.com/elementary/greeter/issues/360 is fixed (substituteAll { src = ./hardcode-fallback-background.patch; - default_wallpaper = "${nixos-artwork.wallpapers.simple-dark-gray}/share/artwork/gnome/nix-wallpaper-simple-dark-gray.png"; + default_wallpaper = "${nixos-artwork.wallpapers.simple-dark-gray.gnomeFilePath}"; }) ]; @@ -113,7 +113,7 @@ stdenv.mkDerivation rec { # Use NixOS default wallpaper substituteInPlace $out/etc/lightdm/io.elementary.greeter.conf \ --replace "#default-wallpaper=/usr/share/backgrounds/elementaryos-default" \ - "default-wallpaper=${nixos-artwork.wallpapers.simple-dark-gray}/share/artwork/gnome/nix-wallpaper-simple-dark-gray.png" + "default-wallpaper=${nixos-artwork.wallpapers.simple-dark-gray.gnomeFilePath}" substituteInPlace $out/share/xgreeters/io.elementary.greeter.desktop \ --replace "Exec=io.elementary.greeter" "Exec=$out/bin/io.elementary.greeter"