sway: add package-option

Changed files
+19 -5
nixos
modules
programs
+19 -5
nixos/modules/programs/sway.nix
···
};
};
-
swayPackage = pkgs.sway.override {
extraSessionCommands = cfg.extraSessionCommands;
extraOptions = cfg.extraOptions;
withBaseWrapper = cfg.wrapperFeatures.base;
···
~/.config/sway/config to modify the default configuration. See
<https://github.com/swaywm/sway/wiki> and
"man 5 sway" for more information'');
wrapperFeatures = mkOption {
type = wrapperOptions;
···
}
];
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" ''
# Import the most important environment variables into the D-Bus and systemd
# user environments (e.g. required for screen sharing and Pinentry prompts):
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
'';
};
};
security.polkit.enable = true;
···
fonts.enableDefaultFonts = mkDefault true;
programs.dconf.enable = mkDefault true;
# To make a Sway session available if a display manager like SDDM is enabled:
-
services.xserver.displayManager.sessionPackages = [ swayPackage ];
programs.xwayland.enable = mkDefault true;
# For screen sharing (this option only has an effect with xdg.portal.enable):
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-wlr ];
···
};
};
+
defaultSwayPackage = pkgs.sway.override {
extraSessionCommands = cfg.extraSessionCommands;
extraOptions = cfg.extraOptions;
withBaseWrapper = cfg.wrapperFeatures.base;
···
~/.config/sway/config to modify the default configuration. See
<https://github.com/swaywm/sway/wiki> and
"man 5 sway" for more information'');
+
+
package = mkOption {
+
type = with types; nullOr package;
+
default = defaultSwayPackage;
+
defaultText = literalExpression "pkgs.sway";
+
description = lib.mdDoc ''
+
Sway package to use. Will override the options
+
'wrapperFeatures', 'extraSessionCommands', and 'extraOptions'.
+
Set to <code>null</code> to not add any Sway package to your
+
path. This should be done if you want to use the Home Manager Sway
+
module to install Sway.
+
'';
+
};
wrapperFeatures = mkOption {
type = wrapperOptions;
···
}
];
environment = {
+
systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
# Needed for the default wallpaper:
+
pathsToLink = optionals (cfg.package != null) [ "/share/backgrounds/sway" ];
etc = {
"sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
# Import the most important environment variables into the D-Bus and systemd
# user environments (e.g. required for screen sharing and Pinentry prompts):
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
'';
+
} // optionalAttrs (cfg.package != null) {
+
"sway/config".source = mkOptionDefault "${cfg.package}/etc/sway/config";
};
};
security.polkit.enable = true;
···
fonts.enableDefaultFonts = mkDefault true;
programs.dconf.enable = mkDefault true;
# To make a Sway session available if a display manager like SDDM is enabled:
+
services.xserver.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ];
programs.xwayland.enable = mkDefault true;
# For screen sharing (this option only has an effect with xdg.portal.enable):
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-wlr ];