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 WLR_NO_HARDWARE_CURSORS=1 67 export NIXOS_OZONE_WL=1 68 69 # for intellij 70 export _JAVA_AWT_WM_NONREPARENTING=1 71 72 # for screensharing 73 export XDG_SESSION_TYPE="wayland" 74 export XDG_CURRENT_DESKTOP="sway" 75 76 exec sway -d 77 fi 78 ''; 79 80 xdg.configFile = 81 let 82 entries = { 83 "fusuma/config.yml".source = ./fusuma.yml; 84 "kanshi/config".source = ./kanshi; 85 "dunst/dunstrc".source = ./dunst; 86 "swaylock/config".source = ./swaylock; 87 "wofi/style.css".source = ./wofi.css; 88 "swappy/config".text = '' 89 [Default] 90 save_dir=$XDG_PICTURES_DIR/capture/ 91 save_filename_format=screenshot_%Y-%m-%dT%H:%M:%S%z.png 92 ''; 93 "sway/config".text = 94 let 95 wmFilenames = util.listFilesInDir ./wm/config.d; 96 in 97 let 98 swayFilenames = util.listFilesInDir ./wm/sway; 99 in 100 (util.concatFilesReplace ([ ./wm/config ] ++ wmFilenames ++ swayFilenames) replacements); 101 }; 102 in 103 (util.inDirReplace ./wm/scripts "sway/scripts" replacements) // entries; 104 105 services.gammastep = { 106 enable = true; 107 provider = "geoclue2"; 108 temperature.day = 6500; 109 }; 110 systemd.user.services.gammastep.Service.ExecStart = 111 lib.mkForce "${pkgs.gammastep}/bin/gammastep -r"; 112 }; 113}