auto-upgrade added
This commit is contained in:
parent
e0c7765176
commit
04ec7debc9
2 changed files with 32 additions and 0 deletions
31
system/common/global/auto-upgrade.nix
Normal file
31
system/common/global/auto-upgrade.nix
Normal 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")"
|
||||||
|
''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
./security.nix
|
./security.nix
|
||||||
./systemdboot.nix
|
./systemdboot.nix
|
||||||
./pipewire.nix
|
./pipewire.nix
|
||||||
|
# ./auto-upgrade.nix # still needs some work
|
||||||
] ++ (builtins.attrValues outputs.nixosModules);
|
] ++ (builtins.attrValues outputs.nixosModules);
|
||||||
|
|
||||||
home-manager.extraSpecialArgs = { inherit inputs outputs; };
|
home-manager.extraSpecialArgs = { inherit inputs outputs; };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue