aboutsummaryrefslogtreecommitdiff
path: root/infra
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-22 20:39:19 +0100
committerMx Kookie <kookie@spacekookie.de>2020-12-22 20:43:51 +0100
commit78a2961f1084f2e9680d09914a847fcbb548096f (patch)
treee27b07bb12f83433ca4ec888bb709ebf89bcc869 /infra
parentdceec84b009fb7cf9f62d0131497a6db53d38825 (diff)
libkookie: build: adding a function to build VM images for debugging
Diffstat (limited to 'infra')
-rwxr-xr-xinfra/libkookie/build26
1 files changed, 24 insertions, 2 deletions
diff --git a/infra/libkookie/build b/infra/libkookie/build
index fb12b28beb78..227620c8519a 100755
--- a/infra/libkookie/build
+++ b/infra/libkookie/build
@@ -24,9 +24,8 @@ function build {
## Build and output build path for debugging
function debug {
- build "$@"
echo "Build path: $OUT"
- exit 0
+ exec build "$@"
}
## Build and switch to the new configuration (requires root)
@@ -36,9 +35,32 @@ function switch {
"$OUT"/bin/switch-to-configuration switch
}
+function vmimage {
+ RUN="$1"; shift
+
+ NIXPKGS_ALLOW_UNFREE=1 \
+ nix build -f '<nixpkgs/nixos>' vm \
+ -I nixos-config="$ROOT" \
+ -I "nixpkgs=$DIR" \
+ -I "nixpkgs-overlays=$DIR/overlays" \
+ -I "home-manager=$DIR/home-manager" \
+ -I "modules=$DIR/modules" \
+ -I "configuration=$DIR/configuration" \
+ --argstr system x86_64-linux "$@"
+
+ if [ "$RUN" -eq "1" ]; then
+ echo "Running VM image..."
+ ./result/bin/run-$HOST-vm
+ fi
+
+ exit 0
+}
+
case "$1" in
-s* | --switch*) shift; switch "$@" ;;
-d* | --debug*) shift; debug "$@" ;;
+ -vr*) shift; vmimage "1" "$@" ;;
+ -v*) shift; vmimage "0" "$@" ;;
*) build "$@" ;;
esac