nixos/sway: Improve the module and adapt it to NixOS

This commit contains the following changes:
- nixos/sway: Remove the beta references
- sway: Drop buildDocs
- nixos/sway: Improve the documentation
- sway,nixos/sway: Adapt Sway to NixOS
- Copy the default configuration file to /etc/sway/config (Sway will
still load the identical file from the Nix store but this makes it
easier to copy the default configuration file).
- This will also remove all references to the Nix store from the
default configuration file as they will eventually be garbage
collected which is a problem if the user copies it.
- I've also decided to drop the default wallpaper (alternatively we
could copy it to a fixed location).
- nixos/sway: Drop the package option

+44 -22
+17 -15
nixos/modules/programs/sway.nix
··· 3 with lib; 4 5 let 6 - cfg = config.programs.sway-beta; 7 - swayPackage = cfg.package; 8 9 swayWrapped = pkgs.writeShellScriptBin "sway" '' 10 set -o errexit ··· 26 paths = [ swayWrapped swayPackage ]; 27 }; 28 in { 29 - options.programs.sway-beta = { 30 enable = mkEnableOption '' 31 - Sway, the i3-compatible tiling Wayland compositor. This module will be removed after the final release of Sway 1.0 32 - ''; 33 - 34 - package = mkOption { 35 - type = types.package; 36 - default = pkgs.sway-beta; 37 - defaultText = "pkgs.sway-beta"; 38 - description = '' 39 - The package to be used for `sway`. 40 - ''; 41 - }; 42 43 extraSessionCommands = mkOption { 44 type = types.lines; ··· 80 }; 81 82 config = mkIf cfg.enable { 83 - environment.systemPackages = [ swayJoined ] ++ cfg.extraPackages; 84 security.pam.services.swaylock = {}; 85 hardware.opengl.enable = mkDefault true; 86 fonts.enableDefaultFonts = mkDefault true;
··· 3 with lib; 4 5 let 6 + cfg = config.programs.sway; 7 + swayPackage = pkgs.sway; 8 9 swayWrapped = pkgs.writeShellScriptBin "sway" '' 10 set -o errexit ··· 26 paths = [ swayWrapped swayPackage ]; 27 }; 28 in { 29 + options.programs.sway = { 30 enable = mkEnableOption '' 31 + Sway, the i3-compatible tiling Wayland compositor. You can manually launch 32 + Sway by executing "exec sway" on a TTY. Copy /etc/sway/config to 33 + ~/.config/sway/config to modify the default configuration. See 34 + https://github.com/swaywm/sway/wiki and "man 5 sway" for more information. 35 + Please have a look at the "extraSessionCommands" example for running 36 + programs natively under Wayland''; 37 38 extraSessionCommands = mkOption { 39 type = types.lines; ··· 75 }; 76 77 config = mkIf cfg.enable { 78 + environment = { 79 + systemPackages = [ swayJoined ] ++ cfg.extraPackages; 80 + etc = { 81 + "sway/config".source = "${swayPackage}/etc/sway/config"; 82 + #"sway/security.d".source = "${swayPackage}/etc/sway/security.d/"; 83 + #"sway/config.d".source = "${swayPackage}/etc/sway/config.d/"; 84 + }; 85 + }; 86 security.pam.services.swaylock = {}; 87 hardware.opengl.enable = mkDefault true; 88 fonts.enableDefaultFonts = mkDefault true;
+6 -7
pkgs/applications/window-managers/sway/default.nix
··· 4 , wayland, libxkbcommon, pcre, json_c, dbus, libevdev 5 , pango, cairo, libinput, libcap, pam, gdk_pixbuf 6 , wlroots, wayland-protocols 7 - , buildDocs ? true 8 }: 9 10 stdenv.mkDerivation rec { ··· 26 url = "https://github.com/swaywm/sway/commit/bcde298a719f60b9913133dbd2a169dedbc8dd7d.patch"; 27 sha256 = "0r583nmqvq43ib93yv6flw8pj833v32lbs0q0xld56s3rnzvvdcp"; 28 }) 29 ]; 30 31 - nativeBuildInputs = [ 32 - pkgconfig meson ninja 33 - ] ++ stdenv.lib.optional buildDocs scdoc; 34 35 buildInputs = [ 36 wayland libxkbcommon pcre json_c dbus libevdev ··· 41 enableParallelBuilding = true; 42 43 mesonFlags = [ 44 - "-Dxwayland=enabled" "-Dgdk-pixbuf=enabled" "-Dtray=enabled" 45 - ] ++ stdenv.lib.optional buildDocs "-Dman-pages=enabled"; 46 47 meta = with stdenv.lib; { 48 - description = "i3-compatible window manager for Wayland"; 49 homepage = https://swaywm.org; 50 license = licenses.mit; 51 platforms = platforms.linux;
··· 4 , wayland, libxkbcommon, pcre, json_c, dbus, libevdev 5 , pango, cairo, libinput, libcap, pam, gdk_pixbuf 6 , wlroots, wayland-protocols 7 }: 8 9 stdenv.mkDerivation rec { ··· 25 url = "https://github.com/swaywm/sway/commit/bcde298a719f60b9913133dbd2a169dedbc8dd7d.patch"; 26 sha256 = "0r583nmqvq43ib93yv6flw8pj833v32lbs0q0xld56s3rnzvvdcp"; 27 }) 28 + ./sway-config-no-nix-store-references.patch 29 ]; 30 31 + nativeBuildInputs = [ pkgconfig meson ninja scdoc ]; 32 33 buildInputs = [ 34 wayland libxkbcommon pcre json_c dbus libevdev ··· 39 enableParallelBuilding = true; 40 41 mesonFlags = [ 42 + "-Ddefault-wallpaper=false" "-Dxwayland=enabled" "-Dgdk-pixbuf=enabled" 43 + "-Dtray=enabled" "-Dman-pages=enabled" 44 + ]; 45 46 meta = with stdenv.lib; { 47 + description = "i3-compatible tiling Wayland compositor"; 48 homepage = https://swaywm.org; 49 license = licenses.mit; 50 platforms = platforms.linux;
+21
pkgs/applications/window-managers/sway/sway-config-no-nix-store-references.patch
···
··· 1 + diff --git a/config.in b/config.in 2 + --- a/config.in 3 + +++ b/config.in 4 + @@ -21,8 +21,8 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec 5 + 6 + ### Output configuration 7 + # 8 + -# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/) 9 + -output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill 10 + +# Default wallpaper 11 + +#output * bg ~/.config/sway/backgrounds/Sway_Wallpaper_Blue_1920x1080.png fill 12 + # 13 + # Example configuration: 14 + # 15 + @@ -213,5 +213,3 @@ bar { 16 + inactive_workspace #32323200 #32323200 #5c5c5c 17 + } 18 + } 19 + - 20 + -include @sysconfdir@/sway/config.d/* 21 +