From 7907319a11c659c3f5f7d68a3c221083892fd4fb Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 1 Apr 2021 19:57:45 +0200 Subject: refactor(tazjin/nixos): Use setup scripts from //ops/nixos Change-Id: I8baf2404f0f6e9c4fad767911646cdc55051dd2e Reviewed-on: https://cl.tvl.fyi/c/depot/+/2753 Reviewed-by: tazjin Tested-by: BuildkiteCI --- users/tazjin/nixos/default.nix | 45 ++++-------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/users/tazjin/nixos/default.nix b/users/tazjin/nixos/default.nix index 370049859f68..04123a3b5ab1 100644 --- a/users/tazjin/nixos/default.nix +++ b/users/tazjin/nixos/default.nix @@ -1,47 +1,10 @@ -# TODO(tazjin): Generalise this and move to //ops/nixos { depot, lib, ... }: -let - inherit (builtins) foldl'; - - systemFor = configs: (depot.third_party.nixos { - configuration = lib.fix(config: - foldl' lib.recursiveUpdate {} (map (c: c config) configs) - ); - }).system; - - caseFor = hostname: '' - ${hostname}) - echo "Rebuilding NixOS for //users/tazjin/nixos/${hostname}" - system=$(nix-build -E '(import {}).users.tazjin.nixos.${hostname}System' --no-out-link) - ;; - ''; - - rebuilder = depot.third_party.writeShellScriptBin "rebuilder" '' - set -ue - if [[ $EUID -ne 0 ]]; then - echo "Oh no! Only root is allowed to rebuild the system!" >&2 - exit 1 - fi - - case $HOSTNAME in - ${caseFor "camden"} - ${caseFor "frog"} - *) - echo "$HOSTNAME is not a known NixOS host!" >&2 - exit 1 - ;; - esac - - nix-env -p /nix/var/nix/profiles/system --set $system - $system/bin/switch-to-configuration switch - ''; +let systemFor = sys: (depot.ops.nixos.nixosFor sys).system; in { - inherit rebuilder; - - camdenSystem = systemFor [ depot.users.tazjin.nixos.camden ]; - frogSystem = systemFor [ depot.users.tazjin.nixos.frog ]; - tverskoySystem = systemFor [ depot.users.tazjin.nixos.tverskoy ]; + camdenSystem = systemFor depot.users.tazjin.nixos.camden; + frogSystem = systemFor depot.users.tazjin.nixos.frog; + tverskoySystem = systemFor depot.users.tazjin.nixos.tverskoy; meta.targets = [ "camdenSystem" "frogSystem" "tverskoySystem" ]; } -- cgit 1.4.1