depot/ops/nixos/lib/rebuilder.nix

17 lines
641 B
Nix
Raw Normal View History

{ system, depot, pkgs, ... }:
pkgs.writeShellScriptBin "rebuilder" ''
set -ue
if [[ $EUID -ne 0 ]]; then
exec sudo "$0" "$@"
fi
2020-05-09 22:49:32 +00:00
DEPOT_PATH="''${1:-<depot>}"
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 --option substituters "https://cache.nixos.org s3://lukegb-nix-cache?endpoint=storage.googleapis.com&trusted=1" -E "(import $DEPOT_PATH {}).ops.nixos.${system}" --no-out-link)"
nix-env -p /nix/var/nix/profiles/system --set "$system"
"$system/bin/switch-to-configuration" switch
''