2020-06-07 14:03:12 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-05-09 10:14:25 +00:00
|
|
|
{ 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>}"
|
|
|
|
|
2020-05-09 10:14:25 +00:00
|
|
|
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}"
|
|
|
|
|
2021-12-31 23:51:09 +00:00
|
|
|
current_specialisation="$(cat /run/current-system/specialisation-name 2>/dev/null)"
|
|
|
|
specialisation_path=""
|
|
|
|
if [[ ! -z "$current_specialisation" ]]; then
|
|
|
|
specialisation_path="specialisation/$current_specialisation/"
|
|
|
|
fi
|
|
|
|
|
2020-05-22 12:04:17 +00:00
|
|
|
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)"
|
2020-05-09 10:14:25 +00:00
|
|
|
nix-env -p /nix/var/nix/profiles/system --set "$system"
|
2021-12-31 23:51:09 +00:00
|
|
|
"$system/''${specialisation_path}bin/switch-to-configuration" test
|
|
|
|
"$system/bin/switch-to-configuration" boot
|
|
|
|
''
|