auto-upgrade added

This commit is contained in:
ooks-io 2023-07-30 21:59:08 +12:00
parent e0c7765176
commit 04ec7debc9
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,31 @@
{ config, inputs, pkgs, lib, ... }:
let
inherit (config.networking) hostName;
isClean = inputs.self ? rev;
in
{
system.autoUpgrade = {
enable = isClean;
dates = "hourly";
flags = [
"--refresh"
];
flake = "github:ooks-io/nix#${hostName};
};
# Only run if current config (self) is older than the new one.
systemd.services.nixos-upgrade = lib.mkIf config.system.autoUpgrade.enable {
serviceConfig.ExecCondition = lib.getExe (
pkgs.writeShellScriptBin "check-date" ''
lastModified() {
nix flake metadata "$1" --refresh --json | ${lib.getExe pkgs.jq} '.lastModified'
}
test "$(lastModified "${config.system.autoUpgrade.flake}")" -gt "$(lastModified "self")"
''
);
};
}

View file

@ -7,6 +7,7 @@
./security.nix
./systemdboot.nix
./pipewire.nix
# ./auto-upgrade.nix # still needs some work
] ++ (builtins.attrValues outputs.nixosModules);
home-manager.extraSpecialArgs = { inherit inputs outputs; };