nix machine / user configurations
1{ 2 config, 3 nixosConfig, 4 pkgs, 5 lib, 6 tlib, 7 ... 8}: 9{ 10 imports = [ 11 ../wayland 12 ../swaylock 13 ../wlsunset 14 ../dunst 15 ../rofi 16 # ./swayidle.nix 17 ]; 18 wayland.windowManager = { 19 sway = 20 let 21 mkRofiCmd = 22 args: 23 "${config.programs.rofi.package}/bin/rofi ${lib.concatStringsSep " " args} | ${pkgs.sway}/bin/swaymsg --"; 24 inherit (tlib) pkgBin; 25 in 26 { 27 enable = true; 28 extraSessionCommands = '' 29 export QT_QPA_PLATFORM=wayland 30 ''; 31 wrapperFeatures.gtk = true; 32 extraConfig = '' 33 exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway 34 exec xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2 35 ''; 36 config = { 37 bars = [ ]; 38 gaps.smartBorders = "on"; 39 menu = mkRofiCmd [ 40 "-show" 41 "drun" 42 ]; 43 modifier = "Mod4"; 44 terminal = config.settings.terminal.binary; 45 keybindings = 46 let 47 mod = config.wayland.windowManager.sway.config.modifier; 48 49 cat = pkgs.coreutils + "/bin/cat"; 50 grim = pkgBin pkgs.grim; 51 slurp = pkgBin pkgs.slurp; 52 pactl = pkgs.pulseaudio + "/bin/pactl"; 53 playerctl = pkgBin pkgs.playerctl; 54 wf-recorder = pkgBin pkgs.wf-recorder; 55 wl-copy = pkgs.wl-clipboard + "/bin/wl-copy"; 56 wlogout = pkgBin pkgs.wlogout; 57 light = pkgBin pkgs.light; 58 59 shotFile = config.home.homeDirectory + "/shots/shot_$(date '+%Y_%m_%d_%H_%M')"; 60 shotDir = config.home.homeDirectory + "/shots"; 61 in 62 lib.mkOptionDefault { 63 "${mod}+Escape" = "exec ${wlogout} -p layer-shell"; 64 "${mod}+q" = "kill"; 65 "${mod}+Shift+e" = "exit"; 66 "${mod}+Shift+r" = "reload"; 67 # Screenshot and copy it to clipboard 68 "Mod1+s" = '' 69 exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png 70 ''; 71 # Save selected area as a picture and copy it to clipboard 72 "Mod1+Shift+s" = '' 73 exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} -g "$(${slurp})" "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png 74 ''; 75 # Record screen 76 "Mod1+r" = ''exec mkdir -p ${shotDir} && ${wf-recorder} -x yuv420p -f "${shotFile}.mp4"''; 77 # Record an area 78 "Mod1+Shift+r" = 79 ''exec mkdir -p ${shotDir} && ${wf-recorder} -x yuv420p -g "$(${slurp})" -f "${shotFile}.mp4"''; 80 # Stop recording 81 "Mod1+c" = "exec pkill -INT wf-recorder"; 82 "XF86AudioRaiseVolume" = "exec ${pactl} set-sink-volume 0 +5%"; 83 "XF86AudioLowerVolume" = "exec ${pactl} set-sink-volume 0 -5%"; 84 "XF86AudioMute" = "exec ${pactl} set-sink-mute 0 toggle"; 85 "XF86AudioPlay" = "exec ${playerctl} play-pause"; 86 "XF86AudioPrev" = "exec ${playerctl} previous"; 87 "XF86AudioNext" = "exec ${playerctl} next"; 88 "XF86AudioStop" = "exec ${playerctl} stop"; 89 "XF86MonBrightnessUp" = "exec ${light} -T 1.4"; 90 "XF86MonBrightnessDown" = "exec ${light} -T 0.72"; 91 }; 92 input = { 93 "13364:832:Keychron_Keychron_V4_Keyboard" = { 94 xkb_layout = nixosConfig.services.xserver.layout; 95 }; 96 "1:1:AT_Translated_Set_2_keyboard" = { 97 xkb_layout = "tr"; 98 }; 99 "type:pointer" = { 100 accel_profile = "flat"; 101 }; 102 "type:touchpad" = { 103 accel_profile = "adaptive"; 104 tap = "enabled"; 105 scroll_method = "two_finger"; 106 dwt = "enabled"; 107 events = "disabled_on_external_mouse"; 108 }; 109 }; 110 output = { 111 "*" = { 112 bg = "${config.stylix.image} fill"; 113 }; 114 "eDP-1" = { 115 scale = "2"; 116 adaptive_sync = "on"; 117 }; 118 "HDMI-A-1" = { 119 mode = "1920x1080@74.973Hz"; 120 }; 121 }; 122 }; 123 }; 124 }; 125}