diff --git a/flake.lock b/flake.lock index d704c3d..07f8afd 100755 --- a/flake.lock +++ b/flake.lock @@ -11,11 +11,11 @@ ] }, "locked": { - "lastModified": 1777726295, - "narHash": "sha256-Db9B3uTLDSj7zjQ4L3tIk9RcxHXbWRKw5fw8JozikyI=", + "lastModified": 1778125502, + "narHash": "sha256-QAAO9RCR6byVJi50l8RMVJWzrsNYbXonfR6tqU93vIQ=", "owner": "caelestia-dots", "repo": "cli", - "rev": "a00e71d6b7572a8dbbb7945a45b79acf2401ad56", + "rev": "7b8a4281aa8b2b12745de531cce0c65d87aea2e5", "type": "github" }, "original": { @@ -33,11 +33,11 @@ "quickshell": "quickshell" }, "locked": { - "lastModified": 1777891103, - "narHash": "sha256-/b87CUV9NEh4YYtG6tGGbbSJurqkfwZQ5rZNiIBJWYw=", + "lastModified": 1778381004, + "narHash": "sha256-JwIlrajiY74obxyTMu/Ym6wOEQaCjpHwfziPK+E5u3Q=", "owner": "caelestia-dots", "repo": "shell", - "rev": "54cdd80c1b7671deeb057cc554f83e436765596a", + "rev": "2ca4ad4a434e91e73504debd5225e66dc5ebb2b6", "type": "github" }, "original": { @@ -53,11 +53,11 @@ ] }, "locked": { - "lastModified": 1777851538, - "narHash": "sha256-Gp8qwTEYNoy2yvmErVGlvLOQvrtEECCAKbonW7VJef8=", + "lastModified": 1778606796, + "narHash": "sha256-P2krpSkFVYJ89bgsnAZ9RtQiGwiTW77sfSJp9SEDscM=", "owner": "nix-community", "repo": "home-manager", - "rev": "cc09c0f9b7eaa95c2d9827338a5eb03d32505ca5", + "rev": "e1fd7350f4410972bcb8c42a697d8c924ffe642a", "type": "github" }, "original": { @@ -119,11 +119,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1777826146, - "narHash": "sha256-wQ/iN5Zp5VIa3ebBibijPnLyKhor+xEbDy4d0goa9Zs=", + "lastModified": 1778794387, + "narHash": "sha256-BL04pOS9453Awkeb9f90XBJXBSkWxN+vB7HIgnL0iMM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "73c703c22422b8951895a960959dbbaca7296492", + "rev": "8a1b0127302ea51e05bf4ea5a291743fac442406", "type": "github" }, "original": { @@ -135,11 +135,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1777673416, - "narHash": "sha256-5c2POKPOjU40Kh0MirOdScBLG0bu9TAuPYAtPRNZMBs=", + "lastModified": 1778737229, + "narHash": "sha256-6xWoytx8jFW4PF1GjRm/i/53trbpKGfz6zjzQGBr4cI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "26ef669cffa904b6f6832ab57b77892a37c1a671", + "rev": "d7a713c0b7e47c908258e71cba7a2d77cc8d71d5", "type": "github" }, "original": { @@ -157,11 +157,11 @@ ] }, "locked": { - "lastModified": 1777706159, - "narHash": "sha256-TuD8hw9lkRCEb+6v93iB7HDvcmvH8R0qyD6wBmPGfv8=", + "lastModified": 1778222427, + "narHash": "sha256-6GFiP611nEJvtm+m03sMyfaVIJ9QOCi//hS+PPKyyPA=", "ref": "refs/heads/master", - "rev": "8db8ca1fecfcce8def1f9265fa1742baa0e0c271", - "revCount": 813, + "rev": "d1760ed1f31c02a95b37a9bf4084129c829ebe7f", + "revCount": 817, "type": "git", "url": "https://git.outfoxxed.me/outfoxxed/quickshell" }, diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index e5cd095..baa3f6b 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -22,7 +22,8 @@ ../../hostsModules/laptop/nixos/disk.nix ../../modules/nixos/printer.nix ../../hostsModules/laptop/nixos/ollama.nix # llm config - ../../modules/nixos/mullvad.nix # vpn config + ../../modules/nixos/mullvad.nix # vpn config + ../../hostsModules/laptop/nixos/autoUpdate.nix # auto update the flakes. Handles notification via libnotify and matrix-commander-rs ]; @@ -162,6 +163,20 @@ shell = pkgs.zsh; }; + # removes need for password for nixos-rebuild + security.sudo.extraRules = [ + { + users = [ "tomasr" ]; + commands = [ + { + command = "/run/current-system/sw/bin/nixos-rebuild"; + options = [ "NOPASSWD" ]; + } + ]; + } + ]; + + #adds nixos experimental features: nix.settings.experimental-features = ["nix-command" "flakes"]; @@ -235,7 +250,7 @@ networkx scipy ])) - iamb # matrix client + fluffychat matrix-commander-rs # matrix client direnv # utils for dev pkg-config @@ -268,10 +283,9 @@ papirus-folders inkscape birdtray # thunderbird tray app - #vivify # for NoteWrapper # this is more up to date - (callPackage ../../modules/packages/vivify.nix {}) - (callPackage ../../modules/packages/sbb-tui.nix {}) + #(callPackage ../../modules/packages/vivify.nix {}) + #(callPackage ../../modules/packages/sbb-tui.nix {}) pkgs-unstable.nixpkgs-review pkgs-unstable.nixfmt-tree pkgs-unstable.treefmt diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 236732d..2b5d28e 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -68,6 +68,10 @@ (pkgs.callPackage ../../modules/scripts/dontkillsteam.nix {}) # kill app (if it is steam put it in some background (pkgs.callPackage ../../hostsModules/laptop/scripts/batterynotify.nix {}) (pkgs.callPackage ../../hostsModules/laptop/scripts/batterywarning.nix {}) + + # checks if matrix-commander-rs is installed and logged in + (pkgs.callPackage ../../hostsModules/laptop/scripts/checkMatrix.nix {}) + (pkgs.callPackage ../../modules/scripts/weather.nix {}) (pkgs.callPackage ../../modules/scripts/wallpaper.nix {}) (pkgs.callPackage ../../modules/scripts/mountkdrive.nix {}) diff --git a/hostsModules/laptop/home-manager/zsh.nix b/hostsModules/laptop/home-manager/zsh.nix index 3718598..7ff0679 100644 --- a/hostsModules/laptop/home-manager/zsh.nix +++ b/hostsModules/laptop/home-manager/zsh.nix @@ -5,8 +5,8 @@ }: { programs.zsh = { shellAliases = { - snrt = "git add -A && sudo nixos-rebuild test --flake ~/nixos/#laptop"; - snrs = "git add -A && sudo nixos-rebuild switch --flake ~/nixos/#laptop"; + snrt = "git add -A && time sudo nixos-rebuild test --flake ~/nixos/#laptop"; + snrs = "git add -A && time sudo nixos-rebuild switch --flake ~/nixos/#laptop"; }; }; } diff --git a/hostsModules/laptop/nixos/autoUpdate.nix b/hostsModules/laptop/nixos/autoUpdate.nix new file mode 100644 index 0000000..eb46b5d --- /dev/null +++ b/hostsModules/laptop/nixos/autoUpdate.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: + +{ + # Ensure your script is available system-wide + environment.systemPackages = [ + (pkgs.callPackage ../scripts/autoUpdate.nix {}) + ]; + users.users.tomasr = { + linger = true; # lingering is required + }; + + systemd.user.services.custom-autoupdate = { + description = "NixOS flake auto update"; + + serviceConfig = { + Type = "oneshot"; + + ExecStart = "/run/current-system/sw/bin/custom-autoupdate"; + + # safety for long rebuilds + TimeoutStartSec = "45min"; + TimeoutStopSec = "10min"; + + # avoid overlap + RemainAfterExit = true; + + # tweaks that should make the system run normally during the rebuilds + Nice = 10; + IOSchedulingClass = "best-effort"; + IOSchedulingPriority = 7; + }; + }; + + # Systemd USER timer + systemd.user.timers.custom-autoupdate = { + wantedBy = [ "timers.target" ]; + + timerConfig = { + OnCalendar = "Fri *-*-* 20:00:00"; # runs friday night. If for whatever reason something breaks. I have whole week-end to fix it. + + Persistent = true; # if it happens during shutted down + + # avoids thundering herd on boot + RandomizedDelaySec = "2h"; + }; + }; +} diff --git a/hostsModules/laptop/scripts/autoUpdate.nix b/hostsModules/laptop/scripts/autoUpdate.nix new file mode 100644 index 0000000..5828ede --- /dev/null +++ b/hostsModules/laptop/scripts/autoUpdate.nix @@ -0,0 +1,63 @@ +{ + pkgs, + ... +}: +pkgs.writeShellApplication { + name = "custom-autoupdate"; + + runtimeInputs = with pkgs; [ + git + nixos-rebuild + matrix-commander-rs + libnotify + ]; + + text = '' + set -e + + FLAKE_DIR="/home/tomasr/nixos" + FLAKE="$FLAKE_DIR#laptop" + TIME=$(date -u +"%Y-%m-%dT%H-%M-%SZ") + + ERROR_FILE=$(mktemp) + + # snapshot current state + git -C "$FLAKE_DIR" add -A + git -C "$FLAKE_DIR" commit --allow-empty -m "snapshot pre-autoupdate-$TIME" + git -C "$FLAKE_DIR" tag "pre-autoupdate-$TIME" HEAD + + # update lock only + nix flake update --flake "$FLAKE_DIR" + + if sudo nixos-rebuild switch --flake "$FLAKE" 2> "$ERROR_FILE"; then + + if ! git -C "$FLAKE_DIR" diff --quiet -- flake.lock; then + git -C "$FLAKE_DIR" add flake.lock + git -C "$FLAKE_DIR" commit -m "flake.lock: autoupdate-$TIME" + git -C "$FLAKE_DIR" push + + notify-send "Flake autoupdate" "Rebuild OK" + + matrix-commander-rs --verbose -m "Flake rebuild succesfull.
@notificationbot_0000" \ + --html \ + -r "\!7j-78_02dHROeLj4Ns8F12eo4IiZGv4zNsQ_1-WlyIU" + else + notify-send "Flake autoupdate" "No changes" + git -C "$FLAKE_DIR" push + fi + + else + ERROR_MSG=$(cat "$ERROR_FILE") + + notify-send -u critical "Flake autoupdate" "FAILED" + + matrix-commander-rs --verbose -m "Flake rebuild failed.
Error:
$ERROR_MSG

@notificationbot_0000" \ + --html \ + -r "\!7j-78_02dHROeLj4Ns8F12eo4IiZGv4zNsQ_1-WlyIU" + + git -C "$FLAKE_DIR" reset --hard "pre-autoupdate-$TIME" + fi + + rm -f "$ERROR_FILE" + ''; +} diff --git a/hostsModules/laptop/scripts/checkMatrix.nix b/hostsModules/laptop/scripts/checkMatrix.nix new file mode 100644 index 0000000..177ca7a --- /dev/null +++ b/hostsModules/laptop/scripts/checkMatrix.nix @@ -0,0 +1,21 @@ +{ pkgs }: + +pkgs.writeShellApplication { + name = "custom-checkMatrix"; + + runtimeInputs = [ + pkgs.matrix-commander-rs + pkgs.libnotify + ]; + + text = '' + expected="@totorile1:unredacted.org" + + current="$(matrix-commander-rs --whoami | tr -d '\n')" + + if [ "$current" != "$expected" ]; then + notify-send "matrix-commander-rs" \ + "You are not logged in as @totorile1:unredacted.org\nLog:\n$current" + fi + ''; +} diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index d935bca..4e08037 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -218,6 +218,7 @@ in { "custom-mountkdrive" #"waybar" "custom-gitnotify" + "custom-checkMatrix" # checks if matrix-commander-rs is connected which is important for other stuff #"custom-obsidianbackup" # backups the obsidian notes to kdrive and to a timed hidden dir (~/.Notes.backup/) #"QS-notifycache" # builds the cache that will be used for the notification history "sleep 4 & caelestia-shell" #works better if it sleeps a bit before @@ -234,7 +235,7 @@ in { ###################### */ ]; - splash = false; # remove default background on startup + splash = true; # remove default background on startup # gestures (also keybindings) gesture = [ "3, right, move, +col" diff --git a/modules/home-manager/librewolf.nix b/modules/home-manager/librewolf.nix index ce224f6..0097dd7 100644 --- a/modules/home-manager/librewolf.nix +++ b/modules/home-manager/librewolf.nix @@ -314,6 +314,18 @@ keyword = "AI writing"; url = "https://en.wikipedia.org/wiki/Wikipedia:Signs_of_AI_writing"; } + { + name = "nixpkgs-review-gha"; + tags = [ "nixpkgs-review" "gha" ]; + keyword = "nixpkgs-review"; + url = "https://github.com/tomasriveral/nixpkgs-review-gha/actions/workflows/review.yml"; + } + { + name = "nixpkgs tracker"; + tags = [ "nixpkgs" "tracker" ]; + keyword = "nixpkgs tracker"; + url = "https://nixpk.gs/pr-tracker.html"; + } ]; }; search = { diff --git a/modules/home-manager/vivify.nix b/modules/home-manager/vivify.nix index ae19b3b..1074d4f 100644 --- a/modules/home-manager/vivify.nix +++ b/modules/home-manager/vivify.nix @@ -1,6 +1,5 @@ { - config, - pkgs, + pkgs-unstable, ... }: { home.file.".config/vivify/config.json" = { @@ -13,6 +12,9 @@ } }''; }; +home.packages = [ + pkgs-unstable.vivify +]; programs.qutebrowser = { enable = true; settings = { diff --git a/modules/nixos/autoUpdate.nix b/modules/nixos/autoUpdate.nix new file mode 100644 index 0000000..30f743f --- /dev/null +++ b/modules/nixos/autoUpdate.nix @@ -0,0 +1,62 @@ +{ pkgs, ... }: + +{ + # Ensure your script is available system-wide + environment.systemPackages = [ + (pkgs.callPackage ./custom-autoupdate.nix {}) + ]; + + # ---------------------------- + # 🔥 Enable lingering for user services (IMPORTANT) + # ---------------------------- + users.users.tomasr = { + isNormalUser = true; + + # other config... + + linger = true; # <-- declarative equivalent of `loginctl enable-linger` + }; + + # ---------------------------- + # ✅ 2. Systemd USER service + # ---------------------------- + systemd.user.services.custom-autoupdate = { + description = "NixOS flake auto update"; + + serviceConfig = { + Type = "oneshot"; + + ExecStart = "/run/current-system/sw/bin/custom-autoupdate"; + + # safety for long rebuilds + TimeoutStartSec = "45min"; + TimeoutStopSec = "10min"; + + # avoid overlap + RemainAfterExit = true; + + # 🔥 recommended reliability tweaks + Nice = 10; + IOSchedulingClass = "best-effort"; + IOSchedulingPriority = 7; + }; + }; + + # ---------------------------- + # ⏱️ 3. Systemd USER timer + # ---------------------------- + systemd.user.timers.custom-autoupdate = { + wantedBy = [ "timers.target" ]; + + timerConfig = { + OnBootSec = "10min"; # run after boot + OnUnitActiveSec = "6h"; # every 6 hours + + # 🔥 ensures missed runs after shutdown happen + Persistent = true; + + # avoids thundering herd on boot + RandomizedDelaySec = "30min"; + }; + }; +} diff --git a/modules/packages/sbb-tui.nix b/modules/packages/sbb-tui.nix index 815def8..5b19420 100644 --- a/modules/packages/sbb-tui.nix +++ b/modules/packages/sbb-tui.nix @@ -8,13 +8,13 @@ buildGoModule (finalAttrs: { pname = "sbb-tui"; - version = "1.14.1"; + version = "1.14.2"; __structuredAttrs = true; src = fetchFromGitHub { owner = "Necrom4"; repo = "sbb-tui"; tag = "v${finalAttrs.version}"; - hash = "sha256-nXkzy5PDR3MRrA0Hsh6/icjAbYyBR2q7oBn74ir1O3E="; + hash = lib.fakeHash; }; vendorHash = "sha256-K4DOu3rfSlKAa5JNKCzWWpnWZlXXxtN5Po7p1Spqe1w=";