cluster/lib.nix

34 lines
958 B
Nix
Raw Normal View History

2021-01-11 18:35:35 +01:00
{ nixpkgs, pkgs, system, inputs }:
with pkgs.lib; {
2021-02-07 14:23:15 +01:00
substitute = runCommand: name: inFile: vars:
runCommand name {}
(let
varsStr = pkgs.lib.mapAttrsToList
(name: value: ''--subst-var-by "${name}" "${value}"'')
vars;
in
''
substitute ${inFile} $out \
${builtins.concatStringsSep " " varsStr}
'');
2021-01-11 18:35:35 +01:00
flakes = path: modules: genAttrs modules (module:
let
self = (import (path + "/${module}/flake.nix")).outputs (inputs // { inherit self; });
in
self
);
2021-01-26 13:10:49 +01:00
dockerImages = pkgs: path: modules: genAttrs modules (module:
2021-01-11 21:30:37 +01:00
import (path + "/${module}") ({ inherit pkgs system; } // inputs)
2021-01-11 18:35:35 +01:00
);
pkgsWithFlakes = flakes: import nixpkgs
{
inherit system;
2021-01-26 13:10:49 +01:00
overlays = builtins.concatLists (mapAttrsToList (_: flake:
2021-01-11 18:35:35 +01:00
if builtins.hasAttr "overlay" flake then
[ flake.overlay ]
else
[]
2021-01-26 13:10:49 +01:00
) flakes);
2021-01-11 18:35:35 +01:00
};
}