Cache nixpkgs locally

This commit is contained in:
Manuel Thalmann 2024-07-06 19:36:47 +02:00
parent 9844355048
commit 1697879c64

View file

@ -1,13 +1,24 @@
#!/bin/bash #!/bin/bash
contextRoot="$(mktemp -d)"; overlayDir="$(mktemp -d)";
root="$contextRoot/airootfs"; upperDir="$(mktemp -d)";
rootHome="$root/root"; workDir="$(mktemp -d)";
nixDir="$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs"; cacheRoot=~/.cache/archiso-valhalla;
nixCache="$cacheRoot/nixpkgs";
root="airootfs";
rootHome="$overlayDir/$root/root";
profileDir="/mnt/archiso-valhalla"; profileDir="/mnt/archiso-valhalla";
nixDir="$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs";
mkdir -p "$rootHome"; mkdir -p "$rootHome";
git clone .. "$rootHome/PortValhalla"; git clone .. "$rootHome/PortValhalla";
git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b nixos-24.05 "$nixDir";
rm -rf "$nixDir/.git"; if [ ! -d "$nixCache" ]; then
sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$contextRoot" "$profileDir"; 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 mkarchiso "$@" "$profileDir";
sudo umount "$nixDir";
sudo umount "$profileDir"; sudo umount "$profileDir";