cluster/lib.nix
2021-02-07 14:23:15 +01:00

34 lines
958 B
Nix

{ nixpkgs, pkgs, system, inputs }:
with pkgs.lib; {
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}
'');
flakes = path: modules: genAttrs modules (module:
let
self = (import (path + "/${module}/flake.nix")).outputs (inputs // { inherit self; });
in
self
);
dockerImages = pkgs: path: modules: genAttrs modules (module:
import (path + "/${module}") ({ inherit pkgs system; } // inputs)
);
pkgsWithFlakes = flakes: import nixpkgs
{
inherit system;
overlays = builtins.concatLists (mapAttrsToList (_: flake:
if builtins.hasAttr "overlay" flake then
[ flake.overlay ]
else
[]
) flakes);
};
}