mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 11:36:16 +01:00
99005cd768
Signed-off-by: magic_rb <magic_rb@redalder.org>
52 lines
1.4 KiB
Nix
52 lines
1.4 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
|
|
'';
|
|
};
|
|
}
|
|
|