1{ 2 pkgs, 3 config, 4 lib, 5 ... 6}@inputs: 7 8let 9 i3-workspace-history = 10 inputs.i3-workspace-history.packages.${pkgs.stdenv.hostPlatform.system}.default; 11 replacements = { 12 wm = "sway"; 13 wmmsg = "swaymsg"; 14 rofi = "wofi"; 15 app_id = "app_id"; 16 bar_extra = '' 17 icon_theme Papirus 18 ''; 19 locked = "--locked"; 20 polkit_gnome = "${pkgs.polkit_gnome}"; 21 locker = "swaylock -f -i ~/.cache/timewall/last_image"; 22 enable_output = "swaymsg output $laptop_output enable"; 23 disable_output = "swaymsg output $laptop_output disable"; 24 drun = "wofi -i --show drun --allow-images -a"; 25 dmenu = "wofi -d -i -p"; 26 displays = "wdisplays"; 27 notification_deamon = "dunst"; 28 i3_workspace_history = "${i3-workspace-history}/bin/i3-workspace-history"; 29 i3_workspace_history_args = "-sway"; 30 }; 31 util = import ./util.nix { inherit pkgs lib; }; 32 cfg = config.custom.gui.sway; 33in 34{ 35 options.custom.gui.sway.enable = lib.mkEnableOption "sway"; 36 37 config = lib.mkIf cfg.enable { 38 home.packages = with pkgs; [ 39 i3-workspace-history 40 # https://todo.sr.ht/~scoopta/wofi/73 41 (stdenv.mkDerivation { 42 name = "xterm-compat"; 43 buildInputs = [ pkgs.bash ]; 44 dontUnpack = true; 45 installPhase = '' 46 mkdir -p $out/bin 47 cat > $out/bin/xterm <<EOF 48 #!/usr/bin/env bash 49 50 exec \$TERMINAL "\$@" 51 EOF 52 chmod +x $out/bin/xterm 53 ''; 54 }) 55 ]; 56 57 home.file.".zprofile".text = '' 58 # Autostart sway at login on TTY 1 59 if [ -z "''${DISPLAY}" ] && [ "''${XDG_VTNR}" -eq 1 ]; then 60 source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh 61 export QT_QPA_PLATFORM="wayland" 62 export SDL_VIDEODRIVER="wayland" 63 export MOZ_ENABLE_WAYLAND=1 64 export MOZ_DBUS_REMOTE=1 65 export QT_STYLE_OVERRIDE="Fusion" 66 export NIXOS_OZONE_WL=1 67 68 # for intellij 69 export _JAVA_AWT_WM_NONREPARENTING=1 70 71 # for screensharing 72 export XDG_SESSION_TYPE="wayland" 73 export XDG_CURRENT_DESKTOP="sway" 74 75 exec sway -d 76 fi 77 ''; 78 79 xdg.configFile = 80 let 81 entries = { 82 "fusuma/config.yml".source = ./fusuma.yml; 83 "kanshi/config".source = ./kanshi; 84 "dunst/dunstrc".source = ./dunst; 85 "swaylock/config".source = ./swaylock; 86 "wofi/style.css".source = ./wofi.css; 87 "swappy/config".text = '' 88 [Default] 89 save_dir=$XDG_PICTURES_DIR/capture/ 90 save_filename_format=screenshot_%Y-%m-%dT%H:%M:%S%z.png 91 ''; 92 "sway/config".text = 93 let 94 wmFilenames = util.listFilesInDir ./wm/config.d; 95 in 96 let 97 swayFilenames = util.listFilesInDir ./wm/sway; 98 in 99 (util.concatFilesReplace ([ ./wm/config ] ++ wmFilenames ++ swayFilenames) replacements); 100 }; 101 in 102 (util.inDirReplace ./wm/scripts "sway/scripts" replacements) // entries; 103 104 services.gammastep = { 105 enable = true; 106 provider = "geoclue2"; 107 temperature.day = 6500; 108 }; 109 systemd.user.services.gammastep.Service.ExecStart = 110 lib.mkForce "${pkgs.gammastep}/bin/gammastep -r"; 111 }; 112}