dot
vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks
12a2b1d
6 files changed +189 −27
modifiedconfig/waybar/eww/eww.scss
@@ -39,7 +39,7 @@ | ||
| 39 | 39 | font-weight: bold; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | -// ---- tiles (Network / Bluetooth, Update NixOS) ----------------------------------- | |
| 42 | +// ---- tiles (Network / Bluetooth, Update NixOS: Desktop / Server) ----------------- | |
| 43 | 43 | |
| 44 | 44 | .tile { |
| 45 | 45 | background-color: $card; |
@@ -51,10 +51,6 @@ | ||
| 51 | 51 | &.split { |
| 52 | 52 | padding: 4px; |
| 53 | 53 | } |
| 54 | -} | |
| 55 | - | |
| 56 | -.tile-wrap:hover .tile { | |
| 57 | - background-color: $card-hover; | |
| 58 | 54 | } |
| 59 | 55 | |
| 60 | 56 | .toggle { |
@@ -77,8 +73,7 @@ | ||
| 77 | 73 | color: $dim; |
| 78 | 74 | } |
| 79 | 75 | |
| 80 | -.open-wrap:hover .chevron, | |
| 81 | -.tile-wrap:hover .chevron { | |
| 76 | +.open-wrap:hover .chevron { | |
| 82 | 77 | color: $fg; |
| 83 | 78 | } |
| 84 | 79 | |
@@ -90,12 +85,6 @@ | ||
| 90 | 85 | |
| 91 | 86 | label { |
| 92 | 87 | font-size: 18px; |
| 93 | - } | |
| 94 | - | |
| 95 | - // The NixOS snowflake sits a little left of centre in the font. | |
| 96 | - .nix { | |
| 97 | - font-size: 19px; | |
| 98 | - padding-left: 2px; | |
| 99 | 88 | } |
| 100 | 89 | |
| 101 | 90 | &.on { |
modifiedconfig/waybar/eww/eww.yuck
@@ -33,11 +33,16 @@ | ||
| 33 | 33 | :initial "0" |
| 34 | 34 | "df --output=pcent / | tail -1 | tr -dc '0-9'") |
| 35 | 35 | |
| 36 | -;; "26.11 · nixpkgs from 15 Oct", from nixos-version (26.11.20261015.fe13242). | |
| 36 | +;; "26.11 · 15 Oct" (release · nixpkgs date) of this desktop and of the server. | |
| 37 | 37 | (defpoll nixos |
| 38 | 38 | :interval "10m" |
| 39 | 39 | :initial "" |
| 40 | - "v=$(nixos-version | cut -d' ' -f1); date -d \"$(cut -d. -f3 <<<\"$v\")\" \"+$(cut -d. -f1-2 <<<\"$v\") · nixpkgs from %-d %b\"") | |
| 40 | + "bash $HOME/.config/waybar/eww/scripts/nixos-version.sh") | |
| 41 | + | |
| 42 | +(defpoll nixos_server | |
| 43 | + :interval "10m" | |
| 44 | + :initial "" | |
| 45 | + "bash $HOME/.config/waybar/eww/scripts/nixos-version.sh granstrm") | |
| 41 | 46 | |
| 42 | 47 | ;; Last notifications from dunst's history. Only polled while the panel is open; |
| 43 | 48 | ;; scripts/toggle.sh fills it once right before opening. |
@@ -208,18 +213,27 @@ | ||
| 208 | 213 | (box :class "btn danger" |
| 209 | 214 | (label :text "Confirm"))))))) |
| 210 | 215 | |
| 211 | -;; Updates and reboots in a kitty window (tools/nixos-update), asking before it | |
| 212 | -;; installs anything. | |
| 216 | +;; Update NixOS, in two halves like the split tiles: this desktop (tools/nixos-update, | |
| 217 | +;; reboots when done) and the server (tools/server-update, switches it over SSH). Each | |
| 218 | +;; runs in a kitty window and asks before it installs anything. | |
| 213 | 219 | (defwidget update [] |
| 214 | - (eventbox :class "tile-wrap" :cursor "pointer" :timeout "3s" | |
| 215 | - :onclick "${EWW_CMD} close control-center cc-closer; setsid -f kitty --title 'NixOS update' nixos-update" | |
| 216 | - (box :class "tile" :orientation "h" :space-evenly false :spacing 10 | |
| 220 | + (box :class "tile split" :orientation "h" :space-evenly true | |
| 221 | + (update-half :icon "" :title "Desktop" :sub nixos | |
| 222 | + :tooltip "Update NixOS on this desktop" | |
| 223 | + :command "nixos-update") | |
| 224 | + (update-half :icon "" :title "Server" :sub nixos_server | |
| 225 | + :tooltip "Update NixOS on the server" | |
| 226 | + :command "server-update"))) | |
| 227 | + | |
| 228 | +(defwidget update-half [icon title sub tooltip command] | |
| 229 | + (eventbox :class "open-wrap" :cursor "pointer" :timeout "3s" :hexpand true :tooltip tooltip | |
| 230 | + :onclick "${EWW_CMD} close control-center cc-closer; setsid -f kitty --title '${tooltip}' ${command}" | |
| 231 | + (box :class "open" :orientation "h" :space-evenly false :spacing 10 | |
| 217 | 232 | (box :class "icon-circle" :space-evenly true |
| 218 | - (label :class "nix" :text "")) | |
| 233 | + (label :text icon)) | |
| 219 | 234 | (box :orientation "v" :valign "center" :halign "start" :hexpand true :space-evenly false |
| 220 | - (label :class "tile-title" :halign "start" :text "Update NixOS") | |
| 221 | - (label :class "tile-sub" :halign "start" :limit-width 34 :text nixos)) | |
| 222 | - (label :class "chevron" :valign "center" :text "")))) | |
| 235 | + (label :class "tile-title" :halign "start" :text title) | |
| 236 | + (label :class "tile-sub" :halign "start" :limit-width 15 :text sub))))) | |
| 223 | 237 | |
| 224 | 238 | ;; --------------------------------------------------------------------------- |
| 225 | 239 | ;; Notifications panel |
@@ -1,0 +1,14 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# "26.11 · 15 Oct" (release and nixpkgs date) from nixos-version (26.11.20261015.fe13242), | |
| 3 | +# for the update tile. With a host, asks it over SSH; "Unreachable" if that fails. | |
| 4 | +# nixos-version.sh [host] | |
| 5 | + | |
| 6 | +if [; then | |
| 7 | + v= | |
| 8 | +else | |
| 9 | + v= | |
| 10 | +fi | |
| 11 | +v= | |
| 12 | +[ || { ; ; } | |
| 13 | +IFS=. | |
| 14 | + |
modifiedmodules/home/packages.nix
@@ -8,7 +8,7 @@ | ||
| 8 | 8 | let |
| 9 | 9 | system = pkgs.stdenv.hostPlatform.system; |
| 10 | 10 | |
| 11 | - # The control centre's "Update NixOS" tile (tools/nixos-update). | |
| 11 | + # The "Desktop" half of the control centre's update tile (tools/nixos-update). | |
| 12 | 12 | nixos-update = pkgs.writeShellApplication { |
| 13 | 13 | name = "nixos-update"; |
| 14 | 14 | runtimeInputs = with pkgs; [ |
@@ -19,6 +19,17 @@ | ||
| 19 | 19 | text = builtins.readFile ../../tools/nixos-update; |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | + # The same tile's "Server" half (tools/server-update): updates and deploys ~/git/srv. | |
| 23 | + server-update = pkgs.writeShellApplication { | |
| 24 | + name = "server-update"; | |
| 25 | + runtimeInputs = with pkgs; [ | |
| 26 | + git | |
| 27 | + nvd | |
| 28 | + openssh | |
| 29 | + ]; | |
| 30 | + text = builtins.readFile ../../tools/server-update; | |
| 31 | + }; | |
| 32 | + | |
| 22 | 33 | # The Network tile's settings window, on its own: the networkmanagerapplet |
| 23 | 34 | # package also has an autostart entry that would bring nm-applet back to the tray. |
| 24 | 35 | nm-connection-editor = pkgs.runCommand "nm-connection-editor" { } '' |
@@ -63,6 +74,7 @@ | ||
| 63 | 74 | bluez # bluetoothctl |
| 64 | 75 | nm-connection-editor |
| 65 | 76 | nixos-update |
| 77 | + server-update | |
| 66 | 78 | solaar # mouse battery fallback (mouse-battery.sh) |
| 67 | 79 | |
| 68 | 80 | # Screenshots and screen recording (imsh-shot, imsh-cast; Super+Shift+S/F/R). |
modifiedtools/nixos-update
@@ -1,7 +1,7 @@ | ||
| 1 | 1 | #!/usr/bin/env bash |
| 2 | 2 | # Updates NixOS from a throwaway worktree of this repo, so the checkout you edit in |
| 3 | -# is left alone until the update is done. Started from the control centre's | |
| 4 | -# "Update NixOS" tile in a kitty window (installed as `nixos-update`, | |
| 3 | +# is left alone until the update is done. Started from the "Desktop" half of the | |
| 4 | +# control centre's update tile in a kitty window (installed as `nixos-update`, | |
| 5 | 5 | # modules/home/packages.nix, which sets DOT_REPO). |
| 6 | 6 | # |
| 7 | 7 | # 1. a temporary worktree of main |
addedtools/server-update
@@ -1,0 +1,133 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# Updates the server (granstrm, from the srv repo) the way nixos-update updates this | |
| 3 | +# desktop, from a throwaway worktree so the checkout you edit in is left alone. | |
| 4 | +# Started from the "Server" half of the control centre's update tile in a kitty | |
| 5 | +# window (installed as `server-update`, modules/home/packages.nix). | |
| 6 | +# | |
| 7 | +# 1. a temporary worktree of main | |
| 8 | +# 2. nix flake update, committed there | |
| 9 | +# 3. builds the server's system and the repo's VM tests (router, web, media), then | |
| 10 | +# nvd's list of what changed against the system the server runs | |
| 11 | +# 4. asks before going on; then pushes the commit, switches the server to it over | |
| 12 | +# SSH (nixos-rebuild switch --target-host) and brings your checkout's main up | |
| 13 | +# to date | |
| 14 | +# 5. if the kernel changed, asks whether to reboot the server now. It is the | |
| 15 | +# house router, so the internet drops while it reboots. | |
| 16 | +# | |
| 17 | +# If anything fails, the window stays open until you press Enter, and nothing on the | |
| 18 | +# server is changed. | |
| 19 | +set -E | |
| 20 | + | |
| 21 | +repo=${SRV_REPO:-$HOME/git/srv} | |
| 22 | +host=${SRV_HOST:-granstrm} | |
| 23 | +tmp="" | |
| 24 | + | |
| 25 | +step() { printf '\n\e[1;34m==> %s\e[0m\n' "$*"; } | |
| 26 | +note() { printf '\e[1;33m%s\e[0m\n' "$*"; } | |
| 27 | +wait_close() { read -rp "Press Enter to close. " _ || true; } | |
| 28 | + | |
| 29 | +die() { | |
| 30 | + trap - ERR | |
| 31 | + printf '\n\e[1;31m%s\e[0m\n' "$*" | |
| 32 | + wait_close | |
| 33 | + exit 1 | |
| 34 | +} | |
| 35 | + | |
| 36 | +cleanup() { | |
| 37 | + if [ -n "$tmp" ]; then | |
| 38 | + git -C "$repo" worktree remove --force "$tmp" 2>/dev/null || true | |
| 39 | + rm -rf "$tmp" | |
| 40 | + tmp="" | |
| 41 | + fi | |
| 42 | +} | |
| 43 | + | |
| 44 | +trap 'die "The update failed (see above). The server was not changed."' ERR | |
| 45 | +trap cleanup EXIT | |
| 46 | + | |
| 47 | +step "Fetching $repo" | |
| 48 | +git -C "$repo" worktree prune | |
| 49 | +git -C "$repo" fetch origin main | |
| 50 | +git -C "$repo" merge-base --is-ancestor origin/main main || | |
| 51 | + die "main in $repo is behind origin/main (or has diverged); pull first." | |
| 52 | +base=$(git -C "$repo" rev-parse main) | |
| 53 | +ahead=$(git -C "$repo" rev-list --count origin/main..main) | |
| 54 | +dirty=$(git -C "$repo" status --porcelain) | |
| 55 | + | |
| 56 | +tmp=$(mktemp -d -t srv-update.XXXXXX) | |
| 57 | +step "Creating a worktree of main in $tmp" | |
| 58 | +git -C "$repo" worktree add --detach "$tmp" main | |
| 59 | +cd "$tmp" || die "Could not enter $tmp." | |
| 60 | + | |
| 61 | +step "Updating flake inputs" | |
| 62 | +nix flake update --commit-lock-file | |
| 63 | +if [ "$(git rev-parse HEAD)" = "$base" ]; then | |
| 64 | + printf '\nEverything is already up to date.\n' | |
| 65 | + wait_close | |
| 66 | + exit 0 | |
| 67 | +fi | |
| 68 | + | |
| 69 | +step "Building the server's system" | |
| 70 | +nixos-rebuild build --flake "$tmp#$host" | |
| 71 | + | |
| 72 | +checks=$(nix eval --raw .#checks.x86_64-linux --apply 'c: builtins.concatStringsSep " " (builtins.attrNames c)') | |
| 73 | +step "Running the VM tests ($checks)" | |
| 74 | +for c in $checks; do | |
| 75 | + nix build --no-link ".#checks.x86_64-linux.$c" | |
| 76 | +done | |
| 77 | + | |
| 78 | +step "What changes" | |
| 79 | +git --no-pager log -1 --format=%b | |
| 80 | +running=$(ssh "$host" readlink -f /run/current-system) | |
| 81 | +# Usually still here from the last deploy; fetched from the server if not. | |
| 82 | +nix path-info "$running" >/dev/null 2>&1 || nix copy --from "ssh-ng://$host" "$running" | |
| 83 | +nvd diff "$running" "$tmp/result" | |
| 84 | + | |
| 85 | +echo | |
| 86 | +[ -z "$dirty" ] || note "Uncommitted changes in $repo are not part of this update." | |
| 87 | +[ "$ahead" -eq 0 ] || note "main has $ahead commit(s) not on GitHub yet; they are pushed and deployed too." | |
| 88 | +read -rp "Commit, push and switch the server? [y/N] " answer || answer="" | |
| 89 | +case $answer in | |
| 90 | + [yY]*) ;; | |
| 91 | + *) | |
| 92 | + echo "Nothing was changed." | |
| 93 | + sleep 1 | |
| 94 | + exit 0 | |
| 95 | + ;; | |
| 96 | +esac | |
| 97 | + | |
| 98 | +step "Pushing" | |
| 99 | +git push origin HEAD:main | |
| 100 | + | |
| 101 | +step "Switching the server" | |
| 102 | +nixos-rebuild switch --flake "$tmp#$host" --target-host "$host" | |
| 103 | + | |
| 104 | +step "Updating main in $repo" | |
| 105 | +commit=$(git rev-parse HEAD) | |
| 106 | +if [ "$(git -C "$repo" symbolic-ref --quiet --short HEAD)" = main ]; then | |
| 107 | + git -C "$repo" merge --ff-only "$commit" | |
| 108 | +else | |
| 109 | + git -C "$repo" update-ref refs/heads/main "$commit" "$base" | |
| 110 | +fi | |
| 111 | +cd "$repo" | |
| 112 | +cleanup | |
| 113 | + | |
| 114 | +# The same test NixOS's own auto-upgrade uses: a new kernel or initrd only takes | |
| 115 | +# effect after a reboot. | |
| 116 | +# shellcheck disable=SC2016 # expanded on the server | |
| 117 | +if ssh "$host" '[ "$(readlink /run/booted-system/{initrd,kernel,kernel-modules})" = "$(readlink /run/current-system/{initrd,kernel,kernel-modules})" ]'; then | |
| 118 | + printf '\nDone. No reboot needed.\n' | |
| 119 | + wait_close | |
| 120 | + exit 0 | |
| 121 | +fi | |
| 122 | + | |
| 123 | +echo | |
| 124 | +note "The kernel changed; it is used after the server's next reboot." | |
| 125 | +read -rp "Reboot the server now? The internet drops for a few minutes. [y/N] " answer || answer="" | |
| 126 | +case $answer in | |
| 127 | + [yY]*) | |
| 128 | + step "Rebooting the server" | |
| 129 | + ssh "$host" systemctl reboot || true | |
| 130 | + ;; | |
| 131 | + *) echo "Not rebooted. The new kernel is used after the next reboot." ;; | |
| 132 | +esac | |
| 133 | +wait_close |