2019-01-17 17:18:00 +03:00
|
|
|
{ nixpkgs ? <nixpkgs>
|
2019-02-01 01:06:29 +03:00
|
|
|
, configuration ? <nixos-config>
|
2019-01-17 17:18:00 +03:00
|
|
|
, system ? builtins.currentSystem
|
2020-10-23 18:54:01 +03:00
|
|
|
|
|
|
|
, formatConfig
|
|
|
|
|
|
|
|
, flakeUri ? null
|
|
|
|
, flakeAttr ? null
|
2019-01-17 17:18:00 +03:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
module = { lib, ... }: {
|
|
|
|
options = {
|
2020-05-22 11:26:49 +03:00
|
|
|
filename = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Declare the path of the wanted file in the output directory";
|
|
|
|
default = "*";
|
|
|
|
};
|
2019-01-17 17:18:00 +03:00
|
|
|
formatAttr = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Declare the default attribute to build";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-10-23 18:54:01 +03:00
|
|
|
|
|
|
|
# Will only get evaluated when used, so no worries
|
|
|
|
flake = builtins.getFlake flakeUri;
|
|
|
|
flakeSystem = flake.outputs.packages."${system}".nixosConfigurations."${flakeAttr}" or flake.outputs.nixosConfigurations."${flakeAttr}";
|
2019-01-17 17:18:00 +03:00
|
|
|
in
|
2020-10-23 18:54:01 +03:00
|
|
|
if flakeUri != null then
|
|
|
|
flakeSystem.override (attrs: {
|
|
|
|
modules = attrs.modules ++ [ module formatConfig ];
|
|
|
|
})
|
|
|
|
else
|
|
|
|
import "${toString nixpkgs}/nixos/lib/eval-config.nix" {
|
|
|
|
inherit system;
|
|
|
|
modules = [
|
|
|
|
module
|
|
|
|
formatConfig
|
|
|
|
configuration
|
|
|
|
];
|
|
|
|
}
|