From 606151ddb4c1d537b65bb9e2ed667a0e0f72a8cc Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 9 May 2020 11:14:25 +0100 Subject: [PATCH] ops/nixos: move rebuilder derivation into its own file. --- ops/nixos/default.nix | 15 +-------------- ops/nixos/lib/rebuilder.nix | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 ops/nixos/lib/rebuilder.nix 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 +''