68 lines
1.6 KiB
Nix
68 lines
1.6 KiB
Nix
final: prev: {
|
|
ensureZfsMounts = prev.writeShellApplication {
|
|
name = "zfsEnsureMounted";
|
|
runtimeInputs = with prev; [
|
|
zfs
|
|
gawk
|
|
coreutils
|
|
];
|
|
|
|
text = ''
|
|
#!/bin/sh
|
|
|
|
if [[ "$#" -eq "0" ]]; then
|
|
echo "no arguments passed"
|
|
exit 1
|
|
fi
|
|
|
|
MOUNTED=$(zfs list -o mountpoint,mounted -H | awk '$NF == "yes" {$NF=""; print $0}' | sed 's/[[:space:]]*$//')
|
|
|
|
MISSING=""
|
|
for target in "$@"; do
|
|
if ! echo "$MOUNTED" | grep -Fxq "$target"; then
|
|
MISSING="$MISSING $target"
|
|
fi
|
|
done
|
|
|
|
if [[ -n "$MISSING" ]]; then
|
|
echo "FAILURE, missing:$MISSING" 1>&2
|
|
exit 1
|
|
fi
|
|
'';
|
|
};
|
|
|
|
reflac = prev.writeShellApplication {
|
|
name = "reflac";
|
|
runtimeInputs = with prev; [ flac ];
|
|
excludeShellChecks = [ "2086" ];
|
|
|
|
text = builtins.readFile (
|
|
prev.fetchurl {
|
|
url = "https://raw.githubusercontent.com/chungy/reflac/refs/heads/master/reflac";
|
|
sha256 = "61c6cc8be3d276c6714e68b55e5de0e6491f50bbf195233073dbce14a1e278a7";
|
|
}
|
|
);
|
|
};
|
|
|
|
list-usb-drives = prev.writeShellApplication {
|
|
name = "list-usb-drives";
|
|
runtimeInputs = with prev; [
|
|
findutils
|
|
gawk
|
|
coreutils
|
|
gnugrep
|
|
util-linux
|
|
];
|
|
|
|
excludeShellChecks = [
|
|
"SC2086"
|
|
"SC2157"
|
|
"SC2155"
|
|
];
|
|
|
|
text = ''
|
|
find "$DISK_BY_ID_DIR" -name "usb*" | grep -v "part[0-9]\$" | while read -r drive; do lsblk -no model,serial "$drive" | head -n1 | tr -d '\n' | tr " " "_" && echo -e " $(echo \"$drive\" | cut -d':' -f2-)"; done | column -t --table-columns=DRIVE,BAY | sort -n -k 2
|
|
'';
|
|
};
|
|
}
|