diff --git a/ops/nixos/default.nix b/ops/nixos/default.nix index 197053e9b5..467748774a 100644 --- a/ops/nixos/default.nix +++ b/ops/nixos/default.nix @@ -12,20 +12,7 @@ let modules = [ (baseModule systemName) (args: { imports = [ lib/common.nix config ]; }) ]; }).config.system.build.toplevel; systems = [ "porcorosso" "ixvm-fra01" "marukuru" "clouvider-fra01" ]; - rebuilder = system: - pkgs.writeShellScriptBin "rebuilder" '' - set -ue - if [[ $EUID -ne 0 ]]; then - exec sudo "$0" "$@" - fi - - export AWS_ACCESS_KEY_ID="${depot.ops.secrets.nixCache.AWS_ACCESS_KEY_ID}" - export AWS_SECRET_ACCESS_KEY="${depot.ops.secrets.nixCache.AWS_SECRET_ACCESS_KEY}" - - system="$(nix-build -E '(import {}).ops.nixos.${system}' --no-out-link)" - nix-env -p /nix/var/nix/profiles/system --set "$system" - "$system/bin/switch-to-configuration" switch - ''; + rebuilder = system: (import ./lib/rebuilder.nix (args // { system = system; })); systemCfgs = lib.genAttrs systems (name: import (./. + "/${name}")); systemDrvs = mapAttrs systemFor systemCfgs; diff --git a/ops/nixos/lib/rebuilder.nix b/ops/nixos/lib/rebuilder.nix new file mode 100644 index 0000000000..a73d78a48b --- /dev/null +++ b/ops/nixos/lib/rebuilder.nix @@ -0,0 +1,14 @@ +{ system, depot, pkgs, ... }: +pkgs.writeShellScriptBin "rebuilder" '' + set -ue + if [[ $EUID -ne 0 ]]; then + exec sudo "$0" "$@" + fi + + export AWS_ACCESS_KEY_ID="${depot.ops.secrets.nixCache.AWS_ACCESS_KEY_ID}" + export AWS_SECRET_ACCESS_KEY="${depot.ops.secrets.nixCache.AWS_SECRET_ACCESS_KEY}" + + system="$(nix-build -E '(import {}).ops.nixos.${system}' --no-out-link)" + nix-env -p /nix/var/nix/profiles/system --set "$system" + "$system/bin/switch-to-configuration" switch +''