From 83265a850dea2824456db1debf902520db1a536d Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 14 May 2021 16:34:18 +0200 Subject: [PATCH] sway: Install the wallpapers by default and use them on NixOS Size impact: $ du -sh $(nix-build -A sway-unwrapped) 5.9M /nix/store/d07zcpybgpdj8xhn9n4qb04lgm453ia1-sway-unwrapped-1.6 nix@sessel:/var/tmp/michael/nixpkgs$ du -sh $(nix-build -A sway-unwrapped)/share/backgrounds 4.9M /nix/store/d07zcpybgpdj8xhn9n4qb04lgm453ia1-sway-unwrapped-1.6/share/backgrounds --- nixos/modules/programs/sway.nix | 2 ++ .../window-managers/sway/default.nix | 14 +++++++------ .../sway/sway-config-nixos-paths.patch | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 pkgs/applications/window-managers/sway/sway-config-nixos-paths.patch diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix index 2b69851b340b..068788cfd14e 100644 --- a/nixos/modules/programs/sway.nix +++ b/nixos/modules/programs/sway.nix @@ -119,6 +119,8 @@ in { ]; environment = { systemPackages = [ swayPackage ] ++ cfg.extraPackages; + # Needed for the default wallpaper: + pathsToLink = [ "/share/backgrounds/sway" ]; etc = { "sway/config".source = mkOptionDefault "${swayPackage}/etc/sway/config"; "sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" '' diff --git a/pkgs/applications/window-managers/sway/default.nix b/pkgs/applications/window-managers/sway/default.nix index 03abea94a2e9..24c70b376746 100644 --- a/pkgs/applications/window-managers/sway/default.nix +++ b/pkgs/applications/window-managers/sway/default.nix @@ -20,19 +20,22 @@ stdenv.mkDerivation rec { }; patches = [ - ./sway-config-no-nix-store-references.patch ./load-configuration-from-etc.patch (substituteAll { src = ./fix-paths.patch; inherit swaybg; }) + ] ++ lib.optionals (!isNixOS) [ + # References to /nix/store/... will get GC'ed which causes problems when + # copying the default configuration: + ./sway-config-no-nix-store-references.patch + ] ++ lib.optionals isNixOS [ + # Use /run/current-system/sw/share and /etc instead of /nix/store + # references: + ./sway-config-nixos-paths.patch ]; - postPatch = lib.optionalString isNixOS '' - echo -e '\ninclude /etc/sway/config.d/*' >> config.in - ''; - nativeBuildInputs = [ meson ninja pkg-config wayland scdoc ]; @@ -44,7 +47,6 @@ stdenv.mkDerivation rec { ]; mesonFlags = [ - "-Ddefault-wallpaper=false" "-Dsd-bus-provider=libsystemd" ]; diff --git a/pkgs/applications/window-managers/sway/sway-config-nixos-paths.patch b/pkgs/applications/window-managers/sway/sway-config-nixos-paths.patch new file mode 100644 index 000000000000..bbb0f722b8bc --- /dev/null +++ b/pkgs/applications/window-managers/sway/sway-config-nixos-paths.patch @@ -0,0 +1,21 @@ +diff --git a/config.in b/config.in +index 08703bef..f3872730 100644 +--- a/config.in ++++ b/config.in +@@ -22,8 +22,8 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec -- + + ### Output configuration + # +-# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/) +-output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill ++# Default wallpaper (more resolutions are available in /run/current-system/sw/share/backgrounds/sway/) ++output * bg /run/current-system/sw/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill + # + # Example configuration: + # +@@ -214,4 +214,4 @@ bar { + } + } + +-include @sysconfdir@/sway/config.d/* ++include /etc/sway/config.d/*