From 8c273754156c77aac6bdb4db2c131e3537f5d104 Mon Sep 17 00:00:00 2001 From: surtur Date: Tue, 12 Dec 2023 20:57:03 +0100 Subject: [PATCH] nix(t14): reconfigure home environment --- nix/flake.nix | 2 +- nix/hosts/t14/home.nix | 276 ++++++++++++++++++++++++- nix/hosts/t14/modules/desktop/sway.nix | 14 +- 3 files changed, 283 insertions(+), 9 deletions(-) diff --git a/nix/flake.nix b/nix/flake.nix index ee5656f..c2fd8fc 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -79,7 +79,7 @@ { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = {inherit usr;}; + home-manager.extraSpecialArgs = {inherit usr; hostName = "t14";}; home-manager.users.${usr} = { home.stateVersion = "23.11"; imports = [ diff --git a/nix/hosts/t14/home.nix b/nix/hosts/t14/home.nix index d93caa5..9309d59 100644 --- a/nix/hosts/t14/home.nix +++ b/nix/hosts/t14/home.nix @@ -3,14 +3,42 @@ lib, pkgs, usr, + hostName, ... -}: { +}: let + dotfiles = builtins.fetchGit { + url = "https://git.dotya.ml/wanderer/dotfiles"; + rev = "a08927ef24a1fa7b408f6e3bec5754cb733a9c49"; + }; + swayTgt = "sway-session.target"; + start-waybar = pkgs.writeShellScriptBin "start-waybar" '' + export SWAYSOCK=/run/user/$(id -u)/sway-ipc.$(id -u).$(pgrep -f 'sway$').sock + ${pkgs.waybar}/bin/waybar + ''; +in { imports = [ # ./modules/desktop/waybar.nix # ./modules/desktop/wayland.nix ./modules/desktop/sway.nix ]; + sops = { + secrets = { + gitUsername.owner = "mko"; + }; + templates = { + "gitConfig-${hostName}" = { + owner = "mko"; + content = '' + [user] + name = ${hostName} + email = ${config.sops.placeholder.gitUsername} + signingkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDAqwhsHHLKG7k7kDa7Tauy2V+rXqQFxiuMCdVltz0n1 + ''; + }; + }; + }; + # home.enableNixpkgsReleaseCheck = false; home = { username = lib.mkForce "${usr}"; @@ -56,12 +84,12 @@ goreleaser gotools graph-easy - graphviz hadolint hugo ipcalc jq killall + libnotify libtelnet lolcat lsof @@ -108,6 +136,13 @@ services = { blueman-applet.enable = true; network-manager-applet.enable = true; + + avizo.enable = true; + + batsignal = { + enable = true; + extraArgs = ["-w 25" "-c 15" "-d 10"]; + }; }; programs = { @@ -122,4 +157,241 @@ plugins = with pkgs.obs-studio-plugins; [wlrobs]; }; }; + + home.file = { + ".config/kitty/kitty.conf" = { + source = "${dotfiles}/.config/kitty/kitty.conf"; + }; + + ".vimrc" = { + source = "${dotfiles}/.vim/vimrc"; + }; + ".vim/deoplete.vimrc.vim" = { + source = "${dotfiles}/.vim/deoplete.vimrc.vim"; + }; + ".vim/gotags.vimrc.vim" = { + source = "${dotfiles}/.vim/gotags.vimrc.vim"; + }; + ".vim/python.vimrc.vim" = { + source = "${dotfiles}/.vim/python.vimrc.vim"; + }; + + ".config/nvim/init.vim" = { + source = "${dotfiles}/.config/nvim/init.vim"; + }; + + ".config/systemd/user.conf" = { + text = '' + [Manager] + DefaultTimeoutStarSec=15s + DefaultTimeoutStopSec=15s + ''; + }; + + ".config/sway/config.d/dracula.sway" = { + source = "${dotfiles}/.config/sway/config.d/dracula.sway"; + }; + ".config/waybar/config" = { + source = "${dotfiles}/.config/waybar/config"; + }; + ".config/waybar/style.css" = { + source = "${dotfiles}/.config/waybar/style.css"; + }; + ".config/waybar/modules/storage.sh" = { + source = "${dotfiles}/.config/waybar/modules/storage.sh"; + }; + ".config/kanshi/config" = { + source = "${dotfiles}/.config/kanshi/config"; + }; + + ".config/mako/config" = { + source = "${dotfiles}/.config/mako/config"; + }; + ".config/swaylock/config" = { + source = "${dotfiles}/.config/swaylock/config"; + }; + + ".config/albert.conf" = { + source = "${dotfiles}/.config/albert/albert.conf"; + }; + + ".config/direnv/direnv.toml" = { + source = "${dotfiles}/.config/direnv/direnv.toml"; + }; + + ".config/git/config-common" = { + source = "${dotfiles}/.config/git/config"; + }; + # host-specific gitconfig. + ".config/git/config.${hostName}" = { + source = config.sops.templates."gitConfig-${hostName}".path; + }; + ".config/git/config" = { + text = '' + [include] + path = ~/.config/git/config-common + [include] + path = ~/.config/git/config.${hostName} + ''; + }; + ".config/git/allowed_signers" = { + source = "${dotfiles}/.config/git/allowed_signers"; + }; + + ".cargo/config.toml" = { + source = "${dotfiles}/.cargo/config.toml"; + }; + + ".npmrc" = { + text = '' + prefix=''${HOME}/.npm-packages + audit=false + fund=false + ''; + }; + + ".config/tridactyl/tridactylrc" = { + source = "${dotfiles}/.config/tridactyl/tridactylrc"; + }; + + ".config/bat/config" = { + source = "${dotfiles}/.config/bat/config"; + }; + + ".ncpamixer.conf" = { + source = "${dotfiles}/.config/ncpamixer.conf"; + }; + + ".gdbinit" = { + text = '' + set auto-load safe-path /nix/store + set history save on + set history size 10000 + set history remove-duplicates 100 + set history filename ~/.gdb_history + ''; + }; + + ".local/bin/winprint.sh" = { + source = "${dotfiles}/bin/winprint.sh"; + executable = true; + }; + }; + + systemd.user.services = { + waybar = { + Unit = { + Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors."; + Documentation = "https://github.com/Alexays/Waybar/wiki/"; + PartOf = swayTgt; + After = swayTgt; + }; + + Service = { + ExecStart = "${start-waybar}/bin/start-waybar"; + ExecReload = "kill -SIGUSR2 $MAINPID"; + Restart = "on-failure"; + RestartSec = "3s"; + LockPersonality = true; + PrivateTmp = "yes"; + DevicePolicy = "closed"; + }; + + Install = {WantedBy = [swayTgt];}; + }; + + autotiling = { + Unit = { + Description = "Script for sway and i3 to automatically switch the horizontal / vertical window split orientation"; + Documentation = "https://github.com/nwg-piotr/autotiling"; + BindsTo = swayTgt; + }; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.autotiling}/bin/autotiling"; + Restart = "always"; + RestartSec = "5s"; + LockPersonality = true; + PrivateTmp = "yes"; + DevicePolicy = "closed"; + }; + + Install = {WantedBy = [swayTgt];}; + }; + + albert = { + Unit = { + Description = "A C++/Qt based desktop agnostic keyboard launcher that helps you to accomplish your workflows in a breeze"; + Documentation = "https://albertlauncher.github.io/"; + BindsTo = swayTgt; + }; + + Service = { + Type = "simple"; + # after hm stateVersion bump to 23.05, albert doesn't seem to support explicit wayland. + # Environment = "QT_QPA_PLATFORM=xcb"; + ExecStart = "${pkgs.albert}/bin/albert"; + Restart = "always"; + RestartSec = "3s"; + LockPersonality = true; + PrivateTmp = "yes"; + DevicePolicy = "closed"; + }; + + Install = {WantedBy = [swayTgt];}; + }; + mako = { + Unit = { + Description = "Mako notification daemon"; + BindsTo = [swayTgt]; + }; + Install = { + WantedBy = [swayTgt]; + }; + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.mako}/bin/mako"; + RestartSec = 5; + Restart = "always"; + }; + }; + + gopls = { + Unit = { + Description = "Go language server"; + }; + + Service = { + Type = "simple"; + ExecStartPre = "bash -c 'rm -v -f /tmp/.gopls-daemon.sock || true'"; + ExecStart = "%h/go/bin/gopls -listen='unix;/tmp/.gopls-daemon.sock'"; + ExecStopPost = "bash -c 'rm -v -f /tmp/.gopls-daemon.sock || true'"; + Restart = "on-failure"; + RestartSec = "1m"; + TimeoutStopFailureMode = "abort"; + SystemCallFilter = "~@reboot @obsolete"; + ProtectProc = "invisible"; + ProcSubset = "pid"; + ProtectHome = "tmpfs"; + BindPaths = ["%h/.cache"]; + RestrictNamespaces = true; + NoNewPrivileges = "yes"; + ProtectSystem = "strict"; + DevicePolicy = "closed"; + LockPersonality = true; + MemoryDenyWriteExecute = true; + #RestrictAddressFamilies="AF_UNIX AF_INET AF_INET6"; + RestrictAddressFamilies = "AF_UNIX"; + RestrictRealtime = true; + RestrictSUIDSGID = true; + SystemCallArchitectures = "native"; + }; + + Install = {WantedBy = ["default.target"];}; + }; + }; + + xdg = (import "${dotfiles}/nix/xdg.nix") {inherit pkgs config hostName;}; } diff --git a/nix/hosts/t14/modules/desktop/sway.nix b/nix/hosts/t14/modules/desktop/sway.nix index 72d9ab6..a851396 100644 --- a/nix/hosts/t14/modules/desktop/sway.nix +++ b/nix/hosts/t14/modules/desktop/sway.nix @@ -80,6 +80,7 @@ in { wayland.windowManager.sway = { enable = true; package = pkgs.swayfx; + systemd.enable = true; config = rec { modifier = "Mod4"; # super key # Use kitty as default terminal @@ -89,6 +90,7 @@ in { # {command = "firefox";} {command = "kitty";} ]; + bars = []; }; extraConfig = '' set { @@ -119,10 +121,11 @@ in { $sec $ext_screen $term KITTY_ENABLE_WAYLAND=1 kitty -1 # qterminal alacritty + $albert QT_QPA_PLATFORM=xcb albert show $menu wofi --show drun --allow-markup swaymsg exec -- $othermenu XDG_DATA_DIRS=/usr/share/:/usr/local/share/:/var/lib/flatpak/exports/share/:$HOME/.local/share/flatpak/exports/share/ j4-dmenu-desktop --dmenu="bemenu -n -p \"applications\" -l 30 --fn 'FiraCode Retina 17'" --term="kitty" --no-generic --display-binary $nutermmenu kitty --class 'launcher' bash -c 'compgen -c | sort -u | fzf | xargs -r kitty' - $bemenu XDG_DATA_DIRS=/usr/share/:/usr/local/share/:/var/lib/flatpak/exports/share/:$HOME/.local/share/flatpak/exports/share/ bemenu-run --fork -l 5 -n -p "▶" --fn 'FiraCode Retina 17' | xargs swaymsg exec + $bemenu PATH=$/.cargo/bin:$HOME/go/bin:$PATH XDG_DATA_DIRS=/usr/share/:/usr/local/share/:/var/lib/flatpak/exports/share/:$HOME/.local/share/flatpak/exports/share/ bemenu-run --fork -l 5 -n -p "▶" --fn 'FiraCode Retina 17' | xargs swaymsg exec $gtk_font_name "CascadiaCodePL ExtraLight" $gtk_font_size "10.4" } @@ -173,14 +176,11 @@ in { gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true gsettings set org.gtk.Settings.FileChooser window-size '(1100,700)' - pgrep mako && pkill mako # pgrep kanshi && pkill kanshi pgrep swayrd && pkill swayrd pgrep swayidle && pkill swayidle - pgrep avizo && pkill avizo pgrep nm-applet && pkill nm-applet - mako # kanshi env RUST_BACKTRACE=1 swayrd > /tmp/swayrd.log 2>&1 # timeout 545 'pgrep -u $(id -u) swaylock || notify-send -t 20000 -r 344334 -u critical "Idle timeout" "Screen is locking soon"' \ @@ -191,7 +191,6 @@ in { timeout 15 'pgrep swaylock && swaymsg "output * power off"' \ resume 'swaymsg "output * power on"' \ before-sleep "pgrep swaylock || $lock" - avizo-service # TODO(me): # https://github.com/slgobinath/SafeEyes @@ -398,7 +397,9 @@ in { # screenshot of a window Control+print exec winprint.sh # colour picker / eyedropper + $mod+Shift+Alt+f exec farge --notify Control+Shift+print exec grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt: | wl-copy + $mod+tab exec swayr switch-workspace-or-window $mod+c exec gnome-calculator # -w: Always open a new window for browsing specified URIs. $mod+n exec nautilus -w @@ -638,7 +639,8 @@ in { } } bindsym --no-warn $mod+r mode "resize" - bindsym $mod+Shift+r --no-warn reload; exec kanshictl reload + #bindsym --no-warn $mod+Shift+r reload; exec kanshictl reload + bindsym --no-warn $mod+Shift+r reload # kudos to github.com/rbnis for the following menu-like section inspiration # https://github.com/rbnis/dotfiles/blob/dfd6f956f6d00a1012a3a167d947773095dac7fd/.config/sway/config#L228-L235