1
0
Fork 0

Services: add extra build flags to autoupgrade

This commit is contained in:
Aires 2024-10-01 09:57:42 -04:00
parent 14c4629461
commit f4402e9956
3 changed files with 19 additions and 8 deletions

View file

@ -3,11 +3,11 @@
# Configuration parameters # Configuration parameters
operation="switch" # The nixos-rebuild operation to use operation="switch" # The nixos-rebuild operation to use
hostname=$(hostname) # The name of the host to build hostname=$(/run/current-system/sw/bin/hostname) # The name of the host to build
flakeDir="${FLAKE_DIR}" # Path to the flake file (and optionally the hostname). Defaults to the FLAKE_DIR environment variable. flakeDir="${FLAKE_DIR}" # Path to the flake file (and optionally the hostname). Defaults to the FLAKE_DIR environment variable.
remainingArgs="" # All remaining arguments that haven't been processed remainingArgs="" # All remaining arguments that haven't been processed
update=true # Whether to update git (true by default) update=true # Whether to update git (true by default)
user=$(whoami) # Which user account to use for git commands. user=$(/run/current-system/sw/bin/whoami) # Which user account to use for git commands.
function usage() { function usage() {
echo "nixos-rebuild Operations Script (NOS) updates your system and your flake.lock file by pulling the latest versions." echo "nixos-rebuild Operations Script (NOS) updates your system and your flake.lock file by pulling the latest versions."
@ -87,6 +87,6 @@ fi
options="--flake $flakeDir $remainingArgs --use-remote-sudo --log-format multiline-with-logs" options="--flake $flakeDir $remainingArgs --use-remote-sudo --log-format multiline-with-logs"
echo "Running this operation: nixos-rebuild $operation $options" echo "Running this operation: nixos-rebuild $operation $options"
nixos-rebuild $operation $options /run/current-system/sw/bin/nixos-rebuild $operation $options
exit 0 exit 0

View file

@ -1,4 +1,4 @@
{ ... }: { config, ... }:
let let
# Do not change this value! This tracks when NixOS was installed on your system. # Do not change this value! This tracks when NixOS was installed on your system.
@ -48,7 +48,13 @@ in
retentionPeriod = "14d"; retentionPeriod = "14d";
services = { services = {
autoUpgrade.enable = false; autoUpgrade = {
enable = true;
extraFlags = "--build-host hevana";
configDir = config.secrets.nixConfigFolder;
onCalendar = "weekly";
user = config.users.users.aires.name;
};
virtualization.enable = true; virtualization.enable = true;
}; };

View file

@ -12,6 +12,10 @@ in
type = lib.types.str; type = lib.types.str;
description = "Path where your NixOS configuration files are stored."; description = "Path where your NixOS configuration files are stored.";
}; };
extraFlags = lib.mkOption {
type = lib.types.str;
description = "Extra flags to pass to nixos-rebuild.";
};
onCalendar = lib.mkOption { onCalendar = lib.mkOption {
default = "daily"; default = "daily";
type = lib.types.str; type = lib.types.str;
@ -53,9 +57,10 @@ in
unitConfig.RequiresMountsFor = cfg.configDir; unitConfig.RequiresMountsFor = cfg.configDir;
script = lib.strings.concatStrings [ script = lib.strings.concatStrings [
"/run/current-system/sw/bin/nixos-upgrade-script --operation switch " "/run/current-system/sw/bin/nixos-upgrade-script --operation switch "
(lib.mkIf (cfg.configDir != "") "--flake ${cfg.configDir} ").content (lib.mkIf (cfg.configDir) "--flake ${cfg.configDir} ").content
(lib.mkIf (cfg.user != "") "--user ${cfg.user} ").content (lib.mkIf (cfg.user) "--user ${cfg.user} ").content
(lib.mkIf (!cfg.pushUpdates) "--no-update ").content (lib.mkIf (!cfg.pushUpdates) "--no-update ").content
(lib.mkIf (cfg.extraFlags) cfg.extraFlags).content
]; ];
}; };
timers."nixos-upgrade" = { timers."nixos-upgrade" = {