nixos-generators/nixos-generate.nix

30 lines
710 B
Nix
Raw Normal View History

{ nixpkgs ? <nixpkgs>
, configuration ? <nixos-config>
, system ? builtins.currentSystem
2020-10-23 18:54:01 +03:00
, formatConfig
, flakeUri ? null
, flakeAttr ? null
}:
let
2021-06-07 03:20:11 +03:00
module = import ./format-module.nix;
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}";
in
2020-10-23 18:54:01 +03:00
if flakeUri != null then
flakeSystem.extendModules {
modules = [ module formatConfig ];
}
2020-10-23 18:54:01 +03:00
else
import "${toString nixpkgs}/nixos/lib/eval-config.nix" {
inherit system;
modules = [
module
formatConfig
configuration
];
}