a73714a93c
This adds a first crack at one idea for a generic, non-user-specific rebuild-system script to ops.nixos.rebuild-system. The idea here is that we enumerate all the nixos systems stored in the monorepo (similarly to what we do for ci-builds right now) then search through them by hostname to find the one matching the hostname of the current system, which is an attempt at a more generic version of tazjin's rebuilder script which does the same thing but with an explicit case block. As a caveat, it feels like there's a slight possibility that this way of finding systems is going to get slow to evaluate - on my system it feels fine but if it grows out of hand it's probably feasible to just bake this into the built script as a dynamically generated case statement. Change-Id: I2e4c5401913b6f4d936ab48ba2f95f96e0e78eb4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/894 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi>
67 lines
1.3 KiB
Bash
Executable file
67 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# This script dispatches invocations transparently to programs instantiated from
|
|
# Nix.
|
|
#
|
|
# To add a new tool, insert it into the case statement below by setting `attr`
|
|
# to the key in nixpkgs which represents the program you want to run.
|
|
set -ueo pipefail
|
|
|
|
readonly REPO_ROOT=$(dirname "$0")/..
|
|
TARGET_TOOL=$(basename "$0")
|
|
|
|
case "${TARGET_TOOL}" in
|
|
terraform)
|
|
attr="third_party.terraform-gcp"
|
|
;;
|
|
kontemplate)
|
|
attr="kontemplate"
|
|
;;
|
|
stern)
|
|
attr="third_party.stern"
|
|
;;
|
|
aoc2019)
|
|
attr="fun.aoc2019.${1}"
|
|
;;
|
|
rink)
|
|
attr="third_party.rink"
|
|
;;
|
|
age)
|
|
attr="third_party.age"
|
|
;;
|
|
age-keygen)
|
|
attr="third_party.age"
|
|
;;
|
|
rebuilder)
|
|
attr="users.tazjin.nixos.rebuilder"
|
|
;;
|
|
meson)
|
|
attr="third_party.meson"
|
|
;;
|
|
ninja)
|
|
attr="third_party.ninja"
|
|
;;
|
|
git-bug)
|
|
attr="third_party.git-bug"
|
|
;;
|
|
depot-build)
|
|
attr="tools.depot-build"
|
|
;;
|
|
gerrit)
|
|
attr="tools.gerrit-cli"
|
|
;;
|
|
hash-password)
|
|
attr="tools.hash-password"
|
|
;;
|
|
rebuild-system)
|
|
attr="ops.nixos.rebuild-system"
|
|
;;
|
|
*)
|
|
echo "The tool '${TARGET_TOOL}' is currently not installed in this repository."
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}")
|
|
PATH="${result}/bin:$PATH"
|
|
|
|
exec "${TARGET_TOOL}" "${@}"
|