modules: refactor common

move common into directory
This commit is contained in:
zowoq 2023-07-02 08:16:12 +10:00
parent f8a2457154
commit 1441015937
7 changed files with 1 additions and 1 deletions
modules/nixos/common

View file

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
system.autoUpgrade.enable = true;
system.autoUpgrade.flake = "github:nix-community/infra";
system.autoUpgrade.dates = "hourly";
system.autoUpgrade.flags = [ "--option" "accept-flake-config" "true" "--option" "tarball-ttl" "0" ];
# adapted from https://github.com/NixOS/nixpkgs/blob/3428bdf3c93a7608615dddd44dec50c3df89b4be/nixos/modules/tasks/auto-upgrade.nix
systemd.services.reboot-after-update = {
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig.Type = "oneshot";
script = ''
booted="$(${pkgs.coreutils}/bin/readlink /run/booted-system/{initrd,kernel,kernel-modules})"
built="$(${pkgs.coreutils}/bin/readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
if [ "''${booted}" != "''${built}" ]; then
${config.systemd.package}/bin/shutdown -r now
fi
'';
startAt = "0/6:00";
};
systemd.timers.reboot-after-update = {
timerConfig.RandomizedDelaySec = "6h";
};
}