nixfiles/extras/mk-raspberry-ext-drive.nix
2023-09-13 19:26:50 +01:00

36 lines
1,017 B
Nix

{
stdenv,
bash,
util-linux,
cryptsetup,
btrfs-progs,
}: let
external_drive_data = import ../data/raspberry_ext_drive.nix {};
in
stdenv.mkDerivation {
name = "mk-raspberry-ext-drive";
src = ./mk-raspberry-ext-drive.sh;
unpackPhase = ''
for srcFile in $src; do
cp $srcFile $(stripHash $srcFile)
done
'';
patchPhase = ''
substituteAllInPlace mk-raspberry-ext-drive.sh
substituteInPlace mk-raspberry-ext-drive.sh \
--replace "@util-linux@" "${util-linux}" \
--replace "@btrfs-progs@" "${btrfs-progs}" \
--replace "@cryptsetup@" "${cryptsetup}" \
--replace "@bash@" "${bash}" \
--replace "@ENCRYPTED_LABEL@" "${external_drive_data.encrypted_label}" \
--replace "@UNENCRYPTED_LABEL@" "${external_drive_data.unencrypted_label}"
'';
installPhase = ''
mkdir -p $out/bin
cp mk-raspberry-ext-drive.sh $out/bin/mk-raspberry-ext-drive
chmod +x $out/bin/mk-raspberry-ext-drive
'';
}