2023-11-03 20:10:48 +01:00
|
|
|
{ inputs, lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
filterAttrs
|
|
|
|
mapAttrsToList
|
|
|
|
concatStringsSep
|
|
|
|
;
|
|
|
|
in
|
2023-10-07 22:40:05 +02:00
|
|
|
{
|
|
|
|
flake.overlays.rolling_datasets =
|
|
|
|
final: prev:
|
|
|
|
let
|
2023-11-03 20:10:48 +01:00
|
|
|
writeShellScript = name: text:
|
|
|
|
prev.writeTextFile {
|
|
|
|
inherit name;
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!/bin/sh
|
|
|
|
${text}
|
2023-10-07 22:40:05 +02:00
|
|
|
'';
|
2023-11-03 20:10:48 +01:00
|
|
|
checkPhase = ''
|
|
|
|
${prev.stdenv.shellDryRun} "$target"
|
|
|
|
'';
|
|
|
|
};
|
2023-10-07 22:40:05 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
rolling_datasets =
|
|
|
|
final.runCommand "rolling_datasets" {
|
|
|
|
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
mkdir -p $out/share/functions
|
2023-10-18 14:30:17 +02:00
|
|
|
export runtimeShell=${prev.runtimeShell} \
|
|
|
|
runtimePath=${prev.lib.makeBinPath (with prev; [ utillinux zfs ])}
|
2023-10-07 22:40:05 +02:00
|
|
|
|
2023-11-03 20:10:48 +01:00
|
|
|
${concatStringsSep "\n" (mapAttrsToList (name: _: ''
|
|
|
|
{
|
|
|
|
binary=${writeShellScript name (builtins.readFile (./. + "/bin/${name}"))}
|
|
|
|
output_binary="$out/bin/${name}"
|
2023-10-18 14:30:17 +02:00
|
|
|
substituteAll "$binary" "$output_binary"
|
|
|
|
chmod +x "$output_binary"
|
2023-11-03 20:10:48 +01:00
|
|
|
}
|
|
|
|
'') (filterAttrs (_: v: v == "regular") (builtins.readDir ./bin)))}
|
2023-10-07 22:40:05 +02:00
|
|
|
|
|
|
|
for function in ${./functions}/* ; do
|
|
|
|
substituteAll "$function" "$out/share/functions/$(basename "$function")"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|