From 20993c24b1ebd0f0c42450baee1c64492bdbffe8 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sun, 21 Nov 2021 22:14:52 +0100 Subject: [PATCH] libkookie: formatting change of build script --- infra/libkookie/build | 63 +++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/infra/libkookie/build b/infra/libkookie/build index 6637a54af68..cc55cf7c69b 100755 --- a/infra/libkookie/build +++ b/infra/libkookie/build @@ -15,15 +15,15 @@ echo Active tree: "$ROOT" ## Build the libkookie tree function build { NIXPKGS_ALLOW_UNFREE=1 \ - nix build -f '' system \ - -I nixos-config="$ROOT" \ - -I "nixpkgs=$DIR/nixpkgs/unstable" \ - -I "nixpkgs-overlays=$DIR/overlays" \ - -I "home-manager=$DIR/home-manager" \ - -I "modules=$DIR/modules" \ - -I "shells=$DIR/shells" \ - -I "configuration=$DIR/configuration" \ - --out-link "$OUT" "$@" + nix build -f '' system \ + -I nixos-config="$ROOT" \ + -I "nixpkgs=$DIR/nixpkgs/unstable" \ + -I "nixpkgs-overlays=$DIR/overlays" \ + -I "home-manager=$DIR/home-manager" \ + -I "modules=$DIR/modules" \ + -I "shells=$DIR/shells" \ + -I "configuration=$DIR/configuration" \ + --out-link "$OUT" "$@" } ## Build and output build path for debugging @@ -40,19 +40,26 @@ function switch { "$OUT"/bin/switch-to-configuration switch } +## Build and switch to the new configuration (requires root) +function switch_reboot { + build "$@" + nix-env -p /nix/var/nix/profiles/system --set "$OUT" + "$OUT"/bin/switch-to-configuration boot +} + function vmimage { RUN="$1"; shift NIXPKGS_ALLOW_UNFREE=1 \ - nix build -f '' vm \ - -I nixos-config="$ROOT" \ - -I "nixpkgs=$DIR" \ - -I "nixpkgs-overlays=$DIR/overlays" \ - -I "home-manager=$DIR/home-manager" \ - -I "modules=$DIR/modules" \ - -I "shells=$DIR/shells" \ - -I "configuration=$DIR/configuration" \ - --argstr system x86_64-linux "$@" + nix build -f '' vm \ + -I nixos-config="$ROOT" \ + -I "nixpkgs=$DIR" \ + -I "nixpkgs-overlays=$DIR/overlays" \ + -I "home-manager=$DIR/home-manager" \ + -I "modules=$DIR/modules" \ + -I "shells=$DIR/shells" \ + -I "configuration=$DIR/configuration" \ + --argstr system x86_64-linux "$@" if [ "$RUN" -eq "1" ]; then echo "Running VM image..." @@ -62,9 +69,25 @@ function vmimage { exit 0 } +function iso { + echo "Running iso command" + NIXPKGS_ALLOW_UNFREE=1 \ + nix build -f '' system.build.isoImage \ + -I nixos-config="$DIR/roots/iso.nix" + -I "nixpkgs=$DIR/nixpkgs/unstable" \ + -I "nixpkgs-overlays=$DIR/overlays" \ + -I "home-manager=$DIR/home-manager" \ + -I "modules=$DIR/modules" \ + -I "shells=$DIR/shells" \ + -I "configuration=$DIR/configuration" \ + --out-link "$OUT" "$@" +} + case "$1" in - -s* | --switch*) shift; switch "$@" ;; - -d* | --debug*) shift; debug "$@" ;; + -sb* | --switch-rb) shift; switch_reboot "$@" ;; + -s* | --switch*) shift; switch "$@" ;; + -d* | --debug*) shift; debug "$@" ;; + -i* | --iso*) shift; iso "$@" ;; -vr*) shift; vmimage "1" "$@" ;; -v*) shift; vmimage "0" "$@" ;; *) build "$@" ;;