mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 17:49:07 +01:00
scripts: Refactor following tests' example
This commit is contained in:
parent
a3bae7baec
commit
0ea72891c8
4 changed files with 15 additions and 21 deletions
|
|
@ -7,19 +7,19 @@
|
|||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
mkScript = file: rec {
|
||||
name =
|
||||
file
|
||||
|> lib.unsafeDiscardStringContext
|
||||
|> lib.removePrefix "${self}/scripts/"
|
||||
|> lib.removeSuffix ".nix"
|
||||
|> lib.replaceString "/" "-";
|
||||
value = pkgs.writeShellApplication ({ inherit name; } // import file { inherit self' pkgs lib; });
|
||||
};
|
||||
in
|
||||
{
|
||||
packages =
|
||||
"${self}/scripts"
|
||||
|> lib.filesystem.listFilesRecursive
|
||||
|> lib.map (file: {
|
||||
name =
|
||||
file
|
||||
|> lib.unsafeDiscardStringContext
|
||||
|> lib.removePrefix "${self}/scripts/"
|
||||
|> lib.removeSuffix ".nix"
|
||||
|> lib.replaceString "/" "-";
|
||||
value = import file { inherit self' pkgs lib; };
|
||||
})
|
||||
|> lib.listToAttrs;
|
||||
"${self}/scripts" |> lib.filesystem.listFilesRecursive |> lib.map mkScript |> lib.listToAttrs;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue