summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorgnidorah <gnidorah@users.noreply.github.com>2017-10-25 19:35:00 +0300
committergnidorah <gnidorah@users.noreply.github.com>2017-10-25 21:52:02 +0300
commite18afa63b7e126445aa96a19d3a556c341d6b442 (patch)
tree4efe5ccf5d31cb99d6448a7ccb57fcfa109063fc /nixos/modules/programs
parent8cfbf2be5b74f40dbf88008d3acfbc8789c3ad36 (diff)
downloadnixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.tar
nixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.tar.gz
nixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.tar.bz2
nixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.tar.lz
nixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.tar.xz
nixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.tar.zst
nixlib-e18afa63b7e126445aa96a19d3a556c341d6b442.zip
sway module: more options
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/sway.nix59
1 files changed, 55 insertions, 4 deletions
diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix
index fc8a06d106ae..3591893ff3cc 100644
--- a/nixos/modules/programs/sway.nix
+++ b/nixos/modules/programs/sway.nix
@@ -1,13 +1,61 @@
 { config, pkgs, lib, ... }:
 
 with lib;
+
+let
+  cfg = config.programs.sway;
+  sway = pkgs.sway;
+
+  swayWrapped = pkgs.writeScriptBin "sway" ''
+    #! ${pkgs.stdenv.shell}
+    ${cfg.extraSessionCommands}
+    PATH="${sway}/bin:$PATH"
+    exec ${pkgs.dbus.dbus-launch} --exit-with-session "${sway}/bin/sway"
+  '';
+  swayJoined = pkgs.symlinkJoin {
+    name = "sway-wrapped";
+    paths = [ swayWrapped sway ];
+  };
+in
 {
-  options.programs.sway.enable = mkEnableOption "sway";
+  options.programs.sway = {
+    enable = mkEnableOption "sway";
+
+    extraSessionCommands = mkOption {
+      default     = "";
+      type        = types.lines;
+      example = ''
+        export XKB_DEFAULT_LAYOUT=us,ru
+        export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,
+        export QT_QPA_PLATFORM=wayland
+        export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
+      '';
+      description = ''
+        Shell commands executed just before sway is started.
+      '';
+    };
 
-  config = mkIf config.programs.sway.enable {
-    environment.systemPackages = [ pkgs.sway pkgs.xwayland ];
+    extraPackages = mkOption {
+      type = with types; listOf package;
+      default = with pkgs; [ ];
+      example = literalExample ''
+        with pkgs; [
+          i3status
+          xwayland j4-dmenu-desktop dunst
+          qt5.qtwayland
+          imagemagick
+        ]
+      '';
+      description = ''
+        Extra packages to be installed system wide.
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.systemPackages = [ swayJoined ] ++ cfg.extraPackages;
     security.wrappers.sway = {
-      source = "${pkgs.sway}/bin/sway";
+      source = "${swayJoined}/bin/sway";
       capabilities = "cap_sys_ptrace,cap_sys_tty_config=eip";
       owner = "root";
       group = "sway";
@@ -15,5 +63,8 @@ with lib;
     };
 
     users.extraGroups.sway = {};
+
+    hardware.opengl.enable = mkDefault true;
+    fonts.enableDefaultFonts = mkDefault true;
   };
 }