dotfiles/overlays/rolling_datasets/default.nix
magic_rb aff0158ef7
Reformat the whole flake using alejandra
Signed-off-by: magic_rb <magic_rb@redalder.org>
2024-03-02 22:17:03 +01:00

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
'';
};
}