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