diff options
Diffstat (limited to 'mixins')
-rw-r--r-- | mixins/cli.nix | 33 | ||||
-rw-r--r-- | mixins/greet.nix | 34 | ||||
-rw-r--r-- | mixins/pipewire.nix | 15 | ||||
-rw-r--r-- | mixins/sway.nix | 258 | ||||
-rw-r--r-- | mixins/tailscale.nix | 2 |
5 files changed, 325 insertions, 17 deletions
diff --git a/mixins/cli.nix b/mixins/cli.nix index c5ff7b9..ca6d55d 100644 --- a/mixins/cli.nix +++ b/mixins/cli.nix @@ -7,7 +7,6 @@ }: { imports = [ inputs.home-manager.nixosModules."home-manager" - inputs.agenix.nixosModules ]; config = { home-manager.users.tzlil = {pkgs, ...}@hm: { @@ -17,23 +16,23 @@ curl ripgrep ]; - programs = { - ssh.enable = true; - git = { - userName = "tzlil"; - userEmail = "tzlils@protonmail.com"; - enable = true; + }; + programs = { + ssh.enable = true; + git = { + userName = "tzlil"; + userEmail = "tzlils@protonmail.com"; + enable = true; + }; + fish = { + enable = true; + shellAliases = { + gc = "git clone"; + l = "ls -alh"; }; - fish = { - enable = true; - shellAliases = { - gc = "git clone"; - l = "ls -alh"; - }; - functions = { - sb.body = "sudo nixos-rebuild build --flake ~/sources/nixcfg#(hostname)"; - sw.body = "sudo nixos-rebuild switch --flake ~/sources/nixcfg#(hostname)"; - }; + functions = { + sb.body = "sudo nixos-rebuild build --flake ~/sources/nixcfg#(hostname)"; + sw.body = "sudo nixos-rebuild switch --flake ~/sources/nixcfg#(hostname)"; }; }; }; diff --git a/mixins/greet.nix b/mixins/greet.nix new file mode 100644 index 0000000..5c46792 --- /dev/null +++ b/mixins/greet.nix @@ -0,0 +1,34 @@ +{ + pkgs, + lib, + ... +}: let + user = "tzlil"; + + users.users.greeter.packages = [pkgs.sway]; + greetd = "${pkgs.greetd.greetd}/bin/greetd"; + gtkgreet = "${pkgs.greetd.gtkgreet}/bin/gtkgreet"; + + sway-kiosk = command: "${pkgs.sway}/bin/sway --unsupported-gpu --config ${pkgs.writeText "kiosk.config" '' + output * bg #000000 solid_color + exec "${command}; ${pkgs.sway}/bin/swaymsg exit" + ''}"; +in { + environment.etc."greetd/environments".text = + "sway\n" + + "$SHELL -l\n"; + + services.greetd = { + enable = true; + settings = { + default_session = { + inherit user; + command = sway-kiosk "${gtkgreet} -l &>/dev/null"; + }; + initial_session = { + inherit user; + command = "sh -c sway"; + }; + }; + }; +} \ No newline at end of file diff --git a/mixins/pipewire.nix b/mixins/pipewire.nix new file mode 100644 index 0000000..7f17aa1 --- /dev/null +++ b/mixins/pipewire.nix @@ -0,0 +1,15 @@ +{ pkgs, config, ... }: + +{ + config = { + sound.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + }; +} \ No newline at end of file diff --git a/mixins/sway.nix b/mixins/sway.nix new file mode 100644 index 0000000..f1cf98d --- /dev/null +++ b/mixins/sway.nix @@ -0,0 +1,258 @@ +{ + config, + pkgs, + lib, + ... +}: let + menuscript = + pkgs.writeShellScript "menu" + '' + #!/bin/sh -eu + + in_pipe="$XDG_RUNTIME_DIR/menu-in.$$.pipe" + out_pipe="$XDG_RUNTIME_DIR/menu-out.$$.pipe" + + mkfifo "$in_pipe" "$out_pipe" + trap "rm -f $in_pipe $out_pipe" EXIT + + app_id=menu + chooser="${pkgs.fzf}/bin/fzf <$in_pipe >$out_pipe" + foot -W40x40 --app-id "$app_id" -- sh -c "$chooser" & + cat >"$in_pipe" + cat <"$out_pipe" + ''; + sel = + pkgs.writeShellScript "sel" + '' + #!/bin/sh + swaymsg -t get_tree | \ + ${pkgs.jq}/bin/jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | \ + ${pkgs.slurp}/bin/slurp + ''; +in { + # config.home-manager.users.tzlil.xdg.configFile."i3status-rust/config.toml".source = ./i3status-rs.toml; + config.security.pam.services.swaylock = {}; + config.home-manager.users.tzlil.programs.mako.enable = true; + config.home-manager.users.tzlil.home.packages = with pkgs; [ + grim + slurp + wf-recorder + font-awesome_6 + ]; + config.home-manager.users.tzlil.services.swayidle = let + pgrep = "${pkgs.procps}/bin/pgrep"; + dpms_check = s: + pkgs.writeShellScript "dpms_check_${s}" '' + set -x + if ${pgrep} swaylock; then ${pkgs.sway}/bin/swaymsg 'output * dpms ${s}'; fi + ''; + dpms_set = s: + pkgs.writeShellScript "dpms_set_${s}" '' + set -x + "${pkgs.sway}/bin/swaymsg" 'output * dpms ${s}' + ''; + fadelock = pkgs.writeShellScript "fadelock.sh" '' + set -x + exec "${pkgs.swaylock}/bin/swaylock" + ''; + in { + enable = false; + systemdTarget = "graphical-session.target"; + timeouts = [ + # auto-lock after 30 seconds + { + timeout = 30; + command = fadelock.outPath; + } + ]; + events = [ + { + event = "before-sleep"; + command = fadelock.outPath; + } + ]; + extraArgs = [ + "idlehint 30" + ]; + }; + config.home-manager.users.tzlil.wayland.windowManager.sway = rec { + enable = true; + wrapperFeatures.gtk = true; + config = rec { + fonts = { + names = ["Iosevka"]; + style = "Regular"; + size = 11.0; + }; + output = { + "DP-1" = { + resolution = "1920x1080@166Hz"; + }; + }; + bars = [ + { + fonts = { + names = ["Iosevka" "FontAwesome"]; + style = "Regular"; + size = 11.0; + }; + position = "top"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs"; + colors = { + statusline = "#ffffff"; + background = "#323232"; + inactiveWorkspace = { + background = "#323232"; + border = "#323232"; + text = "#5c5c5c"; + }; + }; + } + ]; + + modifier = "Mod4"; + left = "h"; + down = "n"; + up = "e"; + right = "i"; + keybindings = { + "${modifier}+Return" = "exec $term"; + "${modifier}+q" = "kill"; + "${modifier}+space" = "exec ${pkgs.dmenu}/bin/dmenu_path | ${menuscript} | xargs swaymsg exec --"; + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+q" = "exit"; + "${modifier}+Shift+p" = "exec systemctl poweroff"; + "${modifier}+Shift+s" = "exec systemctl suspend"; + "${modifier}+${left}" = "focus left"; + "${modifier}+${down}" = "focus down"; + "${modifier}+${up}" = "focus up"; + "${modifier}+${right}" = "focus right"; + "${modifier}+Left" = "focus left"; + "${modifier}+Down" = "focus down"; + "${modifier}+Up" = "focus up"; + "${modifier}+Right" = "focus right"; + "${modifier}+Shift+${left}" = "move left"; + "${modifier}+Shift+${down}" = "move down"; + "${modifier}+Shift+${up}" = "move up"; + "${modifier}+Shift+${right}" = "move right"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Right" = "move right"; + "${modifier}+1" = "workspace number 1"; + "${modifier}+2" = "workspace number 2"; + "${modifier}+3" = "workspace number 3"; + "${modifier}+4" = "workspace number 4"; + "${modifier}+5" = "workspace number 5"; + "${modifier}+6" = "workspace number 6"; + "${modifier}+7" = "workspace number 7"; + "${modifier}+8" = "workspace number 8"; + "${modifier}+9" = "workspace number 9"; + "${modifier}+0" = "workspace number 10"; + "${modifier}+Tab" = "workspace back_and_forth"; + "${modifier}+Shift+1" = "move container to workspace number 1"; + "${modifier}+Shift+2" = "move container to workspace number 2"; + "${modifier}+Shift+3" = "move container to workspace number 3"; + "${modifier}+Shift+4" = "move container to workspace number 4"; + "${modifier}+Shift+5" = "move container to workspace number 5"; + "${modifier}+Shift+6" = "move container to workspace number 6"; + "${modifier}+Shift+7" = "move container to workspace number 7"; + "${modifier}+Shift+8" = "move container to workspace number 8"; + "${modifier}+Shift+9" = "move container to workspace number 9"; + "${modifier}+Shift+0" = "move container to workspace number 10"; + "${modifier}+b" = "splith"; + "${modifier}+v" = "splitv"; + "${modifier}+s" = "layout stacking"; + "${modifier}+w" = "layout tabbed"; + "${modifier}+k" = "layout toggle split"; + "${modifier}+f" = "fullscreen"; + "${modifier}+Shift+space" = "floating toggle"; + "${modifier}+t" = "focus mode_toggle"; + "${modifier}+a" = "focus parent"; + "${modifier}+shift+a" = "focus child"; + "${modifier}+Shift+minus" = "move scratchpad"; + "${modifier}+minus" = "scratchpad show"; + "${modifier}+m" = "mode notifications"; + }; + input = { + "type:keyboard" = { + xkb_layout = "us"; + xkb_variant = "colemak_dh"; + xkb_options = "altwin:swap_lalt_lwin,caps:backspace"; + }; + "type:touchpad" = { + tap = "enabled"; + }; + }; + }; + extraConfig = '' + exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway + exec ${pkgs.swayidle}/bin/swayidle -w \ + timeout 300 '${pkgs.swaylock}/bin/swaylock -f -c 000000' \ + timeout 600 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + before-sleep '${pkgs.swaylock}/bin/swaylock -f -c 000000' + exec ${pkgs.polkit_gnome}/polkit-gnome/polkit-gnome-authentication-agent-1 + + #set $mod Alt + set $mod Mod4 + set $left h + set $down n + set $up e + set $right i + set $term ${pkgs.foot}/bin/foot + + default_border pixel + hide_edge_borders smart + smart_borders on + + output * bg ~/tmp/graveyard.png fill + + + + floating_modifier $mod normal + mode notifications { + bindsym Escape mode default + bindsym Return exec ${pkgs.mako}/bin/makoctl invoke; exec ${pkgs.mako}/bin/makoctl dismiss; mode default + bindsym d exec ${pkgs.mako}/bin/makoctl dismiss; mode default + bindsym Shift+d exec ${pkgs.mako}/bin/makoctl dismiss -a; mode default + } + + + font Iosevka 10 + + bindsym $mod+p exec passmenu $menu_args + bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle + bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% + bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% + bindsym --locked XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle + + bindsym --locked XF86AudioNext exec playerctl next + bindsym --locked XF86AudioPlay exec playerctl play-pause + bindsym --locked XF86AudioPrev exec playerctl previous + bindsym --locked XF86AudioStop exec playerctl stop + + for_window [app_id="^menu$"] floating enable, border none + for_window [app_id="mpv"] sticky enable + for_window [floating] border csd + for_window [app_id="firefox" title="Picture-in-Picture"] floating enable, sticky enable, border none + for_window [app_id="imv"] floating enable + for_window [app_id="imv"] floating enable + for_window [class="PacketTracer"] floating enable + + bindsym XF86MonBrightnessUp exec light -A 5 + bindsym XF86MonBrightnessDown exec light -U 5 + + bindsym Print exec ${pkgs.grim}/bin/grim - | tee $(xdg-user-dir PICTURES)/$(date +'%s_grim.png') | wl-copy + bindsym Shift+Print exec ${pkgs.grim}/bin/grim -g "$(${sel})" - | tee $(xdg-user-dir PICTURES)/$(date +'%s_grim.png') | wl-copy + bindsym Ctrl+Print exec ${pkgs.grim}/bin/grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" - |tee $(xdg-user-dir PICTURES)/$(date +'%s_grim.png') | wl-copy + + bindsym $mod+l exec ${pkgs.swaylock}/bin/swaylock -c 070D0D + + exec ${pkgs.mako}/bin/mako >/tmp/mako.log 2>&1 + exec_always kanshi >/tmp/kanshi.log 2>&1 + + include /etc/sway/config.d/* + ''; + }; +} \ No newline at end of file diff --git a/mixins/tailscale.nix b/mixins/tailscale.nix index 8be3147..ccefc48 100644 --- a/mixins/tailscale.nix +++ b/mixins/tailscale.nix @@ -7,5 +7,7 @@ trustedInterfaces = [ "tailscale0" ]; allowedUDPPorts = [41641]; }; + + environment.persistence."/nix/persist".directories = [ "/var/lib/tailscale" ]; }; } \ No newline at end of file |