48 Commits

Author SHA1 Message Date
Gitea Actions
72505b647f Update flake.lock 2025-04-28 2025-08-04 00:30:41 +00:00
Gitea Actions
dc010512c1 Update flake.lock 2025-04-27 2025-08-04 00:30:41 +00:00
Gitea Actions
f168fe99a9 Update flake.lock 2025-04-26 2025-08-04 00:30:41 +00:00
Gitea Actions
3ee4584edd Update flake.lock 2025-04-25 2025-08-04 00:30:41 +00:00
Gitea Actions
7876386666 Update flake.lock 2025-04-24 2025-08-04 00:30:41 +00:00
Gitea Actions
25eb63ccc6 Update flake.lock 2025-04-23 2025-08-04 00:30:41 +00:00
Gitea Actions
595da5f840 Update flake.lock 2025-04-22 2025-08-04 00:30:41 +00:00
Gitea Actions
8e8b40cebc Update flake.lock 2025-04-21 2025-08-04 00:30:41 +00:00
Gitea Actions
8662288ddd Update flake.lock 2025-04-20 2025-08-04 00:30:41 +00:00
Gitea Actions
5883460965 Update flake.lock 2025-04-19 2025-08-04 00:30:41 +00:00
Gitea Actions
0577892225 Update flake.lock 2025-04-18 2025-08-04 00:30:41 +00:00
Gitea Actions
a9905b9e3b Update flake.lock 2025-04-17 2025-08-04 00:30:41 +00:00
Gitea Actions
c1123fb1cd Update flake.lock 2025-04-16 2025-08-04 00:30:41 +00:00
Gitea Actions
8b5b91265a Update flake.lock 2025-04-15 2025-08-04 00:30:41 +00:00
Gitea Actions
8757c89ec3 Update flake.lock 2025-04-14 2025-08-04 00:30:41 +00:00
Gitea Actions
a2c1173916 Update flake.lock 2025-04-13 2025-08-04 00:30:41 +00:00
Gitea Actions
6b5a289f2c Update flake.lock 2025-04-12 2025-08-04 00:30:41 +00:00
Gitea Actions
4b0d74f7fc Update flake.lock 2025-04-11 2025-08-04 00:30:41 +00:00
Gitea Actions
0e13a40354 Update flake.lock 2025-04-10 2025-08-04 00:30:41 +00:00
Gitea Actions
172e1e2561 Update flake.lock 2025-04-09 2025-08-04 00:30:41 +00:00
Gitea Actions
65a9cbda4e Update flake.lock 2025-04-08 2025-08-04 00:30:41 +00:00
Gitea Actions
6e5ba66cdf Update flake.lock 2025-04-07 2025-08-04 00:30:41 +00:00
Gitea Actions
780a4eaf88 Update flake.lock 2025-04-06 2025-08-04 00:30:41 +00:00
Gitea Actions
0f92dd5b52 Update flake.lock 2025-04-05 2025-08-04 00:30:41 +00:00
Gitea Actions
ac7c3ac13a Update flake.lock 2025-04-04 2025-08-04 00:30:41 +00:00
Gitea Actions
8cfe561dad Update flake.lock 2025-04-03 2025-08-04 00:30:41 +00:00
Gitea Actions
5fd086a77a Update flake.lock 2025-04-02 2025-08-04 00:30:41 +00:00
Gitea Actions
96fdaf84d6 Update flake.lock 2025-04-01 2025-08-04 00:30:41 +00:00
Gitea Actions
0519da6e6b Update flake.lock 2025-03-31 2025-08-04 00:30:41 +00:00
Gitea Actions
056635f1f9 Update flake.lock 2025-03-30 2025-08-04 00:30:41 +00:00
Gitea Actions
376adb4c98 Update flake.lock 2025-03-29 2025-08-04 00:30:41 +00:00
Gitea Actions
85f63d592f Update flake.lock 2025-03-28 2025-08-04 00:30:41 +00:00
Gitea Actions
932d7a6c47 Update flake.lock 2025-03-27 2025-08-04 00:30:41 +00:00
Gitea Actions
498e86730d Update flake.lock 2025-03-26 2025-08-04 00:30:41 +00:00
Gitea Actions
800cfe69c9 Update flake.lock 2025-03-25 2025-08-04 00:30:41 +00:00
Gitea Actions
37b2bb8bef Update flake.lock 2025-03-24 2025-08-04 00:30:41 +00:00
Gitea Actions
7d6d8eb255 Update flake.lock 2025-03-23 2025-08-04 00:30:41 +00:00
12466b4426 frajul-auto-upgrade: re-add lock file usage
Some checks failed
Update Nix Flake / update-flake (push) Failing after 13s
2025-08-03 16:05:46 +02:00
23155d57b7 update flake
Some checks failed
Update Nix Flake / update-flake (push) Failing after 18s
2025-07-26 08:13:42 +02:00
a9e30bd84b Set fallback for binary caches
This makes builds not fail when my own binary cache is offline for some reason
2025-07-26 08:13:02 +02:00
e62f6e9dce Fix frajul-auto-upgrade git permission issue 2025-07-26 08:12:43 +02:00
c543bc13ea hm: disable warn-dirty
Some checks failed
Update Nix Flake / update-flake (push) Failing after 16s
2025-07-12 15:52:17 +02:00
b4d1681b99 hyprland: fix waybar by running it with exec-once 2025-07-12 15:51:43 +02:00
6c32ffbe94 frajul-auto-upgrade: only run once a day
Some checks failed
Update Nix Flake / update-flake (push) Failing after 14s
2025-07-11 16:22:17 +02:00
6787243414 flake: update 2025-07-11 13:15:42 +02:00
d350807e8c builder: do enable auto-upgrades 2025-07-11 13:15:25 +02:00
f872c8db0c aspi: enable frajul auto upgrade module and integrate into waybar 2025-07-11 13:15:02 +02:00
8c53c66c4d Add frajul-auto-upgrade module 2025-07-11 13:14:48 +02:00
11 changed files with 984 additions and 69 deletions

842
flake.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -162,7 +162,10 @@ in {
monitor = ",preferred,auto,1"; monitor = ",preferred,auto,1";
# Autostart # Autostart
exec-once = ["firefox"]; exec-once = [
(lib.getExe pkgs.firefox)
(lib.getExe pkgs.waybar)
];
# Look and Feel # Look and Feel
general = { general = {

View File

@@ -12,7 +12,14 @@
"modules-center": [], "modules-center": [],
"modules-right": ["idle_inhibitor", "disk", "cpu", "memory", "pulseaudio", "battery", "clock", "tray"], "modules-right": ["idle_inhibitor", "custom/nixos-update", "disk", "cpu", "memory", "pulseaudio", "battery", "clock", "tray"],
"custom/nixos-update": {
"exec": "frajul-auto-upgrade-status",
"return-type": "json",
"interval": 2,
"on-click-right": "frajul-auto-upgrade-toggle"
},
"hyprland/workspaces": { "hyprland/workspaces": {
"on-scroll-up": "hyprctl dispatch workspace m+1", "on-scroll-up": "hyprctl dispatch workspace m+1",
@@ -35,6 +42,7 @@
}, },
"idle_inhibitor": { "idle_inhibitor": {
"start-activated": true,
"format": "{icon}", "format": "{icon}",
"format-icons": { "format-icons": {
"activated": "", "activated": "",

View File

@@ -10,7 +10,7 @@
in { in {
programs.waybar = { programs.waybar = {
enable = true; enable = true;
systemd.enable = true; # systemd.enable = true;
settings.mainBar = builtins.fromJSON (builtins.readFile ./config.json); settings.mainBar = builtins.fromJSON (builtins.readFile ./config.json);
}; };

View File

@@ -20,7 +20,7 @@
"flakes" "flakes"
"ca-derivations" "ca-derivations"
]; ];
# warn-dirty = false; # TODO: do I want it? also for systems warn-dirty = false; # TODO: do I want it? also for systems
}; };
}; };

View File

@@ -39,5 +39,8 @@
]; ];
# nix.settings. # warn-dirty = false; # TODO: do I want this # nix.settings. # warn-dirty = false; # TODO: do I want this
#
# Ensure we can still build when missing-server is not accessible
fallback = true;
}; };
} }

View File

@@ -32,6 +32,10 @@
enable = true; enable = true;
overrideSettings = false; overrideSettings = false;
}; };
frajulAutoUpgrade = {
enable = true;
flakePath = "/home/julian/.dotfiles";
};
}; };
services.blueman.enable = true; services.blueman.enable = true;

View File

@@ -43,6 +43,15 @@
cores = 0; cores = 0;
}; };
system.autoUpgrade = {
enable = true;
flake = "git+https://gitlab.julian-mutter.de/julian/dotfiles";
flags = [
"--recreate-lock-file" # update lock file
];
dates = "02:13";
};
# optimize store by hardlinking store files # optimize store by hardlinking store files
nix.optimise.automatic = true; nix.optimise.automatic = true;
nix.optimise.dates = ["03:15"]; nix.optimise.dates = ["03:15"];

View File

@@ -21,5 +21,8 @@
"root" "root"
"@wheel" "@wheel"
]; # needed for devenv to add custom caches ]; # needed for devenv to add custom caches
# Ensure we can still build when missing-server is not accessible
fallback = true;
}; };
} }

View File

@@ -1,4 +1,5 @@
{ {
# hydra-auto-upgrade = import ./hydra-auto-upgrade.nix; # hydra-auto-upgrade = import ./hydra-auto-upgrade.nix;
syncthing = import ./syncthing.nix; syncthing = import ./syncthing.nix;
frajulAutoUpgrade = import ./frajul-auto-upgrade.nix;
} }

View File

@@ -0,0 +1,172 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.modules.frajulAutoUpgrade;
flagFile = "/var/lib/frajul-auto-upgrade/flag";
lockFile = "/var/lib/frajul-auto-upgrade/lock";
lastStatusFile = "/var/lib/frajul-auto-upgrade/last-status";
lastAttemptFile = "/var/lib/frajul-auto-upgrade/last-attempt";
in {
options.modules.frajulAutoUpgrade = {
enable = lib.mkEnableOption "NixOS auto-upgrade on boot";
user = lib.mkOption {
type = lib.types.str;
default = "root";
description = "User account to run the upgrade service as.";
};
flakePath = lib.mkOption {
type = lib.types.path;
description = "The path to your flake";
};
};
config = lib.mkIf cfg.enable {
# Ensure the flag directory exists
systemd.tmpfiles.rules = [
"d /var/lib/frajul-auto-upgrade 0755 root root -"
"f ${flagFile} 0766 root root -"
"f ${lastStatusFile} 0644 root root -"
"f ${lastAttemptFile} 0644 root root -"
];
environment.systemPackages = [
(pkgs.writeShellScriptBin "frajul-auto-upgrade" ''
#!/bin/sh
FLAG_FILE="${flagFile}"
LOCK_FILE="${lockFile}"
LAST_STATUS_FILE="${lastStatusFile}"
LAST_ATTEMPT_FILE="${lastAttemptFile}"
TODAY=$(date +%Y-%m-%d)
if [ ! -f "$FLAG_FILE" ] || [ "$(cat "$FLAG_FILE")" != "enabled" ]; then
echo "Auto upgrade disabled. Exiting."
exit 0
fi
# Check if already attempted today
if [ -f "$LAST_ATTEMPT_FILE" ]; then
LAST_ATTEMPT_DATE=$(cut -d' ' -f1 "$LAST_ATTEMPT_FILE")
if [ "$LAST_ATTEMPT_DATE" = "$TODAY" ]; then
echo "Update already attempted today. Skipping."
exit 0
fi
fi
if [ -f "$LOCK_FILE" ]; then
echo "Already running"
exit 1
fi
echo $$ > "$LOCK_FILE"
trap 'rm -f "$LOCK_FILE"' EXIT
if /run/current-system/sw/bin/nix flake update --flake "${cfg.flakePath}" && /run/current-system/sw/bin/nixos-rebuild switch --flake "${cfg.flakePath}"; then
echo "success" > "$LAST_STATUS_FILE"
else
echo "failure" > "$LAST_STATUS_FILE"
fi
# Write full timestamp
date '+%Y-%m-%d %H:%M:%S' > "$LAST_ATTEMPT_FILE"
'')
(pkgs.writeShellScriptBin "frajul-auto-upgrade-status" ''
#!/bin/sh
FLAG_FILE="${flagFile}"
LOCK_FILE="${lockFile}"
LAST_STATUS_FILE="${lastStatusFile}"
LAST_ATTEMPT_FILE="${lastAttemptFile}"
if [ -f "$LOCK_FILE" ]; then
ICON=" "
STATUS="running"
elif [ -f "$FLAG_FILE" ] && [ "$(cat "$FLAG_FILE")" == "enabled" ]; then
LAST_STATUS="unknown"
LAST_ATTEMPT="never"
if [ -f "$LAST_STATUS_FILE" ]; then
LAST_STATUS=$(cat "$LAST_STATUS_FILE")
fi
if [ -f "$LAST_ATTEMPT_FILE" ]; then
LAST_ATTEMPT=$(cat "$LAST_ATTEMPT_FILE")
fi
if [ "$LAST_STATUS" = "success" ]; then
ICON=""
elif [ "$LAST_STATUS" = "failure" ]; then
ICON=""
else
ICON=""
fi
STATUS="enabled (last attempt: $LAST_ATTEMPT, $LAST_STATUS)"
else
ICON=" "
STATUS="disabled"
fi
echo "{\"text\": \"$ICON\", \"tooltip\": \"NixOS Auto Update: $STATUS\"}"
'')
(pkgs.writeShellScriptBin "frajul-auto-upgrade-toggle" ''
#!/bin/sh
FLAG_FILE="${flagFile}"
LOCK_FILE="${lockFile}"
if [ ! -f "$FLAG_FILE" ] || [ "$(cat "$FLAG_FILE")" != "enabled" ]; then
echo "enabled" > "$FLAG_FILE"
else
echo "disabled" > "$FLAG_FILE"
if [ -f "$LOCK_FILE" ]; then
kill -TERM "$(cat "$LOCK_FILE")"
fi
fi
'')
];
# Fixes error: repository path '...' is not owned by current user
environment.etc."root/.gitconfig".text = ''
[safe]
directory = ${cfg.flakePath}
'';
systemd.services.frajul-auto-upgrade = {
description = "Frajul's NixOS Auto Upgrade";
after = ["network-online.target"];
wants = ["network-online.target"];
restartIfChanged = false; # Do not start service on nixos switch
path = with pkgs; [
coreutils
gnutar
xz.bin
gzip
gitMinimal
config.nix.package.out
config.programs.ssh.package
];
serviceConfig = {
Type = "oneshot";
User = cfg.user;
ExecStart = "/run/current-system/sw/bin/frajul-auto-upgrade";
};
};
systemd.timers.frajul-auto-upgrade = {
description = "Run Frajul's NixOS Auto Upgrade at boot";
wantedBy = ["timers.target"];
timerConfig = {
OnBootSec = "1min";
AccuracySec = "10s";
Unit = "frajul-auto-upgrade.service";
};
};
};
}