PortValhalla/archiso/scripts/build.sh

26 lines
886 B
Bash
Executable file

#!/bin/bash
overlayDir="$(mktemp -d)";
upperDir="$(mktemp -d)";
workDir="$(mktemp -d)";
cacheRoot=~/.cache/archiso-valhalla;
nixCache="$cacheRoot/nixpkgs";
root="airootfs";
rootHome="$overlayDir/$root/root";
profileDir="/mnt/archiso-valhalla";
projectDir="$rootHome/PortValhalla";
nixDir="$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs";
mkdir -p "$rootHome";
fish "${BASH_SOURCE%/*}/../../scripts/copy-repo.fish" "$projectDir";
if [ ! -d "$nixCache" ]; then
mkdir -p "$nixCache"
git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b nixos-24.05 "$nixCache";
rm -rf "$nixCache/.git";
fi;
sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir";
sudo mount --mkdir --bind "$nixCache" "$nixDir";
sudo mkarchiso "$@" "$profileDir";
sudo umount "$nixDir";
sudo umount "$profileDir";