summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorMichael Weiss <dev.primeos@gmail.com>2019-12-21 23:48:02 +0100
committerGitHub <noreply@github.com>2019-12-21 23:48:02 +0100
commitb9b77386b0e200cf23875909a75467493b2cdfb4 (patch)
treee578757ada75ab673e1ea4e37a9ec71db2e18fe0 /nixos/modules/programs
parent7b6d5dfcab63d49611c6da91acef4b9329386c27 (diff)
parentd467c59825b94185eef55765ee78d9350cec3472 (diff)
Merge pull request #75247 from Elyhaka/sway
sway: refactor with a wrapper This moves the wrapper functionality from the NixOS module to a new package (wrapper) that wraps the original sway package (sway-unwrapped). Therefore it's now also possible to properly use Sway on non-NixOS systems out of the box. The new submodule for the wrapperFeatures makes it easy to extend the functionality which should become useful in the future. This also introduces a GTK wrapper feature to fix issues with icon/GTK themes, e.g. when running waybar or wofi. This should also work for #67704. If not, we might have to add some additional dependencies/arguments for this case.
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/sway.nix67
1 files changed, 45 insertions, 22 deletions
diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix
index d685a5259324..e2a4018e9023 100644
--- a/nixos/modules/programs/sway.nix
+++ b/nixos/modules/programs/sway.nix
@@ -4,27 +4,32 @@ with lib;
let
cfg = config.programs.sway;
- swayPackage = pkgs.sway;
- swayWrapped = pkgs.writeShellScriptBin "sway" ''
- set -o errexit
-
- if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
- export _SWAY_WRAPPER_ALREADY_EXECUTED=1
- ${cfg.extraSessionCommands}
- fi
+ wrapperOptions = types.submodule {
+ options =
+ let
+ mkWrapperFeature = default: description: mkOption {
+ type = types.bool;
+ inherit default;
+ example = !default;
+ description = "Whether to make use of the ${description}";
+ };
+ in {
+ base = mkWrapperFeature true ''
+ base wrapper to execute extra session commands and prepend a
+ dbus-run-session to the sway command.
+ '';
+ gtk = mkWrapperFeature false ''
+ wrapGAppsHook wrapper to execute sway with required environment
+ variables for GTK applications.
+ '';
+ };
+ };
- if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
- export DBUS_SESSION_BUS_ADDRESS
- exec ${swayPackage}/bin/sway "$@"
- else
- exec ${pkgs.dbus}/bin/dbus-run-session ${swayPackage}/bin/sway "$@"
- fi
- '';
- swayJoined = pkgs.symlinkJoin {
- name = "sway-joined";
- paths = [ swayWrapped swayPackage ];
- passthru.providedSessions = [ "sway" ];
+ swayPackage = pkgs.sway.override {
+ extraSessionCommands = cfg.extraSessionCommands;
+ withBaseWrapper = cfg.wrapperFeatures.base;
+ withGtkWrapper = cfg.wrapperFeatures.gtk;
};
in {
options.programs.sway = {
@@ -36,6 +41,15 @@ in {
Please have a look at the "extraSessionCommands" example for running
programs natively under Wayland'';
+ wrapperFeatures = mkOption {
+ type = wrapperOptions;
+ default = { };
+ example = { gtk = true; };
+ description = ''
+ Attribute set of features to enable in the wrapper.
+ '';
+ };
+
extraSessionCommands = mkOption {
type = types.lines;
default = "";
@@ -56,7 +70,7 @@ in {
extraPackages = mkOption {
type = with types; listOf package;
default = with pkgs; [
- swaylock swayidle swaybg
+ swaylock swayidle
xwayland rxvt_unicode dmenu
];
defaultText = literalExample ''
@@ -76,8 +90,17 @@ in {
};
config = mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = cfg.extraSessionCommands != "" -> cfg.wrapperFeatures.base;
+ message = ''
+ The extraSessionCommands for Sway will not be run if
+ wrapperFeatures.base is disabled.
+ '';
+ }
+ ];
environment = {
- systemPackages = [ swayJoined ] ++ cfg.extraPackages;
+ systemPackages = [ swayPackage ] ++ cfg.extraPackages;
etc = {
"sway/config".source = mkOptionDefault "${swayPackage}/etc/sway/config";
#"sway/security.d".source = mkOptionDefault "${swayPackage}/etc/sway/security.d/";
@@ -89,7 +112,7 @@ in {
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 = [ swayJoined ];
+ services.xserver.displayManager.sessionPackages = [ swayPackage ];
};
meta.maintainers = with lib.maintainers; [ gnidorah primeos colemickens ];