fixed deployment

weird thing happen when you try to copy things from a binary cache to
a local store
This commit is contained in:
emily 2024-05-14 15:27:57 +02:00
parent e3ec78b937
commit 1de66b3795
Signed by: emily
GPG key ID: F6F4C66207FCF995
7 changed files with 27 additions and 14 deletions

View file

@ -30,7 +30,7 @@ with lib; {
kyouma.deployment = {
tags = [ "all" ];
upgradeSystem.enable = true;
auto-upgrade.enable = true;
};
security.dhparams.defaultBitSize = 4096;

View file

@ -1,4 +1,5 @@
{ lib, pkgs, ... }: {
kyouma.deployment.auto-upgrade.cache = "daemon";
nix.gc.options = lib.mkForce "--delete-older-than 60d";
nix.settings.trusted-users = [ "build" ];
nix.extraOptions = ''

View file

@ -1,6 +1,4 @@
{ config, pkgs, lib, modulesPath, ... }:
with lib; {
{ lib, modulesPath, ... }: {
imports = [
(modulesPath + "/virtualisation/proxmox-lxc.nix")
];
@ -8,11 +6,11 @@ with lib; {
manageNetwork = true;
manageHostName = true;
};
kyouma ={
kyouma = {
machine-type.virtual = true;
deployment = {
tags = [ "pve-lxc" ];
upgradeSystem.allowReboot = false;
auto-upgrade.allowReboot = false;
};
};

View file

@ -10,6 +10,7 @@
owner = "hydra-queue-runner";
sopsFile = ../../../secrets/services/hydra.yaml;
};
kyouma.deployment.auto-upgrade.cache = "daemon";
services.hydra = {
enable = true;

View file

@ -33,7 +33,7 @@
({ ... }: {
nixpkgs.overlays = [ self.overlays.kyouma self.overlays.otherPkgs ];
nixpkgs.hostPlatform.system = system;
kyouma.deployment.upgradeSystem.hostName = hostname;
kyouma.deployment.auto-upgrade.hostName = hostname;
})
];
};

View file

@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.kyouma.deployment.upgradeSystem;
let cfg = config.kyouma.deployment.auto-upgrade;
in {
options.kyouma.deployment = {
tags = mkOption {
@ -13,8 +13,8 @@ in {
default = null;
description = "colmena target host override";
};
upgradeSystem = {
enable = mkEnableOption "automatically apply hydra builds";
auto-upgrade = {
enable = mkEnableOption "automatically upgrade from hydra";
allowReboot = mkOption {
type = types.bool;
default = true;
@ -25,6 +25,11 @@ in {
default = "main";
description = "branch to use for updates";
};
cache = mkOption {
type = types.str;
default = "https://cache.kyouma.net";
description = "Set the binary cache";
};
hostName = mkOption {
type = with types; nullOr str;
default = null;
@ -51,9 +56,11 @@ in {
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.upgrade-system}/bin/upgrade-system${optionalString cfg.allowReboot " --allow-reboot"} --branch ${cfg.branch}${
optionalString (cfg.hostName != null) " --hostname ${cfg.hostName}"
}${optionalString cfg.noDelay " --no-delay"}";
ExecStart = "${pkgs.upgrade-system}/bin/upgrade-system${
optionalString cfg.allowReboot " --allow-reboot"
} --branch ${cfg.branch} --cache ${cfg.cache}${optionalString (cfg.hostName != null) " --hostname ${cfg.hostName}"}${
optionalString cfg.noDelay " --no-delay"
}";
};
};
systemd.timers.upgrade-system = {

View file

@ -4,6 +4,7 @@ set -euo pipefail
ALLOW_REBOOT=
BRANCH="main"
BINARY_CACHE=
HOST_NAME=$HOSTNAME
NO_DELAY=
@ -18,6 +19,11 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--cache)
BINARY_CACHE="$2"
shift
shift
;;
--hostname)
HOST_NAME="$2"
shift
@ -65,7 +71,7 @@ if [[ "$OLD_STORE_PATH" == "$NEW_STORE_PATH" ]]; then
fi
echo "Downloading ${NEW_STORE_PATH}"
nix copy --from "https://cache.kyouma.net" "${NEW_STORE_PATH}"
nix copy --from "${BINARY_CACHE}" --to "daemon" "${NEW_STORE_PATH}"
echo "Adding path to system profile"
nix-env -p "/nix/var/nix/profiles/system" --set "${NEW_STORE_PATH}"