71 lines
1.3 KiB
Bash
Executable file
71 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env nix-shell
|
||
#! nix-shell -i bash
|
||
#! nix-shell -p bash nix-output-monitor
|
||
|
||
echo FIXME Not flakes ready
|
||
exit 1
|
||
|
||
set -euo pipefail
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||
|
||
# Parse arguments
|
||
function help {
|
||
echo "Usage: $0 [-h|-v|-b] profile"
|
||
echo "Build NixOS configuration on the local machine."
|
||
echo
|
||
echo "Arguments:"
|
||
echo " profile: OS/disk profile to use"
|
||
echo
|
||
echo "Options:"
|
||
echo " -h: Display this help message."
|
||
echo " -v: Build a virtual machine."
|
||
echo " -b: Build a virtual machine with boot loader."
|
||
}
|
||
|
||
attr=system
|
||
while getopts "hvb" OPTION
|
||
do
|
||
case "$OPTION" in
|
||
h)
|
||
help
|
||
exit 0
|
||
;;
|
||
v)
|
||
attr=vm
|
||
;;
|
||
b)
|
||
attr=vmWithBootLoader
|
||
;;
|
||
?)
|
||
help
|
||
exit 2
|
||
;;
|
||
esac
|
||
done
|
||
shift "$(($OPTIND -1))"
|
||
|
||
if [ "$#" -ne 1 ]
|
||
then
|
||
help
|
||
exit 2
|
||
fi
|
||
profile="$1"
|
||
|
||
profile_dir="${SCRIPT_DIR}/${profile}"
|
||
if [ ! -d "$profile_dir" ]
|
||
then
|
||
echo "Profile not found."
|
||
fi
|
||
|
||
nixos_config="${profile_dir}/os.nix"
|
||
if [ ! -f "$nixos_config" ]
|
||
then
|
||
echo "NixOS configuration not found."
|
||
fi
|
||
|
||
set -x
|
||
|
||
nom-build '<nixpkgs/nixos>' -I "nixos-config=${nixos_config}" -A "$attr" -o "${profile_dir}/${attr}"
|
||
|
||
echo
|