27 lines
926 B
Bash
Executable file
27 lines
926 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Function to check if a command was successful
|
|
check_command() {
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error: $1 failed"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Build the qemu image and get the path
|
|
qemuImageBuildPath=$(nix build .#nixosConfigurations.fj-lxc-vm-x86_64.config.system.build.qemuImage --print-out-paths)
|
|
check_command "Building qemu image"
|
|
|
|
# Build the metadata and get the path
|
|
metadataBuildPath=$(nix build .#nixosConfigurations.fj-lxc-vm-x86_64.config.system.build.metadata --print-out-paths)
|
|
check_command "Building metadata"
|
|
|
|
# Set the paths for the metadata and qemu image
|
|
MBP="${metadataBuildPath}/tarball/nixos-system-x86_64-linux.tar.xz"
|
|
QBP="${qemuImageBuildPath}/nixos.qcow2"
|
|
|
|
# Import the image to Incus and capture the instance name
|
|
incus image import --alias nixos-gen/custom/fj-lxc-vm-x86_64 "$MBP" "$QBP"
|
|
check_command "Importing image to Incus"
|
|
|
|
echo "Process completed successfully"
|