retronix/launch_vm.sh

24 lines
763 B
Bash
Raw Normal View History

2024-01-17 13:31:26 +01:00
set -o errexit
2023-12-30 18:38:14 +01:00
2024-01-06 22:42:36 +01:00
export NIXPKGS_ALLOW_UNFREE=1
2024-01-17 13:31:26 +01:00
# get script dir
#
SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
2023-12-30 18:38:14 +01:00
2024-01-17 13:31:26 +01:00
pushd "$DIR" || exit 1
RESULT=$(nix-build -E 'import ((import ./npins).nixpkgs + "/nixos")' -A config.system.build.vm -I nixos-config=configuration.nix --no-out-link $@) || popd || exit 1
popd || exit 1
echo -e "Running: $RESULT\n"
"$RESULT/bin/run-nixos-vm"