mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-01 04:26:13 +01:00
aff0158ef7
Signed-off-by: magic_rb <magic_rb@redalder.org>
50 lines
1.2 KiB
Nix
50 lines
1.2 KiB
Nix
{
|
|
inputs,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit
|
|
(lib)
|
|
filterAttrs
|
|
mapAttrsToList
|
|
concatStringsSep
|
|
;
|
|
in {
|
|
flake.overlays.rolling_datasets = final: prev: let
|
|
writeShellScript = name: text:
|
|
prev.writeTextFile {
|
|
inherit name;
|
|
executable = true;
|
|
text = ''
|
|
#!/bin/sh
|
|
${text}
|
|
'';
|
|
checkPhase = ''
|
|
${prev.stdenv.shellDryRun} "$target"
|
|
'';
|
|
};
|
|
in {
|
|
rolling_datasets =
|
|
final.runCommand "rolling_datasets" {
|
|
} ''
|
|
mkdir -p $out/bin
|
|
mkdir -p $out/share/functions
|
|
export runtimeShell=${prev.runtimeShell} \
|
|
runtimePath=${prev.lib.makeBinPath (with prev; [utillinux zfs])}
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList (name: _: ''
|
|
{
|
|
binary=${writeShellScript name (builtins.readFile (./. + "/bin/${name}"))}
|
|
output_binary="$out/bin/${name}"
|
|
substituteAll "$binary" "$output_binary"
|
|
chmod +x "$output_binary"
|
|
}
|
|
'') (filterAttrs (_: v: v == "regular") (builtins.readDir ./bin)))}
|
|
|
|
for function in ${./functions}/* ; do
|
|
substituteAll "$function" "$out/share/functions/$(basename "$function")"
|
|
done
|
|
'';
|
|
};
|
|
}
|