idk
This commit is contained in:
parent
48765e36f6
commit
a939cd8d00
4 changed files with 26 additions and 7 deletions
|
@ -8,8 +8,13 @@ with lib; {
|
||||||
manageNetwork = true;
|
manageNetwork = true;
|
||||||
manageHostName = true;
|
manageHostName = true;
|
||||||
};
|
};
|
||||||
kyouma.machine-type.virtual = true;
|
kyouma ={
|
||||||
kyouma.deployment.tags = [ "pve-lxc" ];
|
machine-type.virtual = true;
|
||||||
|
deployment = {
|
||||||
|
tags = [ "pve-lxc" ];
|
||||||
|
upgradeSystem.allowReboot = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
networking.useDHCP = false;
|
networking.useDHCP = false;
|
||||||
networking.useHostResolvConf = false;
|
networking.useHostResolvConf = false;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
({ ... }: {
|
({ ... }: {
|
||||||
nixpkgs.overlays = [ self.overlays.kyouma self.overlays.otherPkgs ];
|
nixpkgs.overlays = [ self.overlays.kyouma self.overlays.otherPkgs ];
|
||||||
nixpkgs.hostPlatform.system = system;
|
nixpkgs.hostPlatform.system = system;
|
||||||
|
kyouma.deployment.upgradeSystem.hostName = hostname;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,11 @@ in {
|
||||||
default = "main";
|
default = "main";
|
||||||
description = "branch to use for updates";
|
description = "branch to use for updates";
|
||||||
};
|
};
|
||||||
|
hostName = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = "Set hostname";
|
||||||
|
};
|
||||||
noDelay = mkOption {
|
noDelay = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -47,15 +52,15 @@ in {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${pkgs.upgrade-system}/bin/upgrade-system${optionalString cfg.allowReboot " --allow-reboot"} --branch ${cfg.branch}${
|
ExecStart = "${pkgs.upgrade-system}/bin/upgrade-system${optionalString cfg.allowReboot " --allow-reboot"} --branch ${cfg.branch}${
|
||||||
optionalString cfg.noDelay " --no-delay"
|
optionalString (cfg.hostName != null) " --hostname ${cfg.hostName}"
|
||||||
}";
|
}${optionalString cfg.noDelay " --no-delay"}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.timers.upgrade-system = {
|
systemd.timers.upgrade-system = {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnCalendar = if cfg.noDelay then "*-*-* *:*:00" else cfg.runFreq;
|
OnCalendar = if cfg.noDelay then "*-*-* *:*:00" else cfg.runFreq;
|
||||||
RandomizedDelaySec = if cfg.noDelay then "1s" else "1h";
|
RandomizedDelaySec = if cfg.noDelay then "1s" else "10m";
|
||||||
};
|
};
|
||||||
requires = [ "network-online.target" ];
|
requires = [ "network-online.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
|
|
|
@ -4,6 +4,7 @@ set -euo pipefail
|
||||||
|
|
||||||
ALLOW_REBOOT=
|
ALLOW_REBOOT=
|
||||||
BRANCH="main"
|
BRANCH="main"
|
||||||
|
HOST_NAME=$HOSTNAME
|
||||||
NO_DELAY=
|
NO_DELAY=
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
@ -17,6 +18,11 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--hostname)
|
||||||
|
HOST_NAME="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--no-delay)
|
--no-delay)
|
||||||
NO_DELAY=1
|
NO_DELAY=1
|
||||||
shift
|
shift
|
||||||
|
@ -28,7 +34,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
HYDRA_URL="https://hydra.kyouma.net/job/nixfiles/${BRANCH}/nixosConfigurations.${HOSTNAME}/latest-finished"
|
HYDRA_URL="https://hydra.kyouma.net/job/nixfiles/${BRANCH}/nixosConfigurations.${HOST_NAME}/latest-finished"
|
||||||
|
|
||||||
NEW_STORE_PATH="$(curl --fail -s -L -H "Accept: application/json" "${HYDRA_URL}" | jq -r ".buildoutputs.out.path")"
|
NEW_STORE_PATH="$(curl --fail -s -L -H "Accept: application/json" "${HYDRA_URL}" | jq -r ".buildoutputs.out.path")"
|
||||||
|
|
||||||
|
@ -67,7 +73,9 @@ nix-env -p "/nix/var/nix/profiles/system" --set "${NEW_STORE_PATH}"
|
||||||
echo "Set new profile as boot target"
|
echo "Set new profile as boot target"
|
||||||
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
||||||
|
|
||||||
|
if [[ -n "$ALLOW_REBOOT" ]]; then
|
||||||
nixos-needsreboot
|
nixos-needsreboot
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$NO_DELAY" ]]; then
|
if [[ -n "$NO_DELAY" ]]; then
|
||||||
delay="1"
|
delay="1"
|
||||||
|
|
Loading…
Reference in a new issue