mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-08-16 23:51:00 +03:00
29 lines
716 B
Nix
29 lines
716 B
Nix
{
|
|
nixpkgs ? <nixpkgs>,
|
|
configuration ? <nixos-config>,
|
|
system ? builtins.currentSystem,
|
|
formatConfig,
|
|
flakeUri ? null,
|
|
flakeAttr ? null,
|
|
}: let
|
|
module = import ./format-module.nix;
|
|
|
|
# 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
|
|
if flakeUri != null
|
|
then
|
|
flakeSystem.extendModules {
|
|
modules = [module formatConfig];
|
|
}
|
|
else
|
|
import "${toString nixpkgs}/nixos/lib/eval-config.nix" {
|
|
inherit system;
|
|
modules = [
|
|
module
|
|
formatConfig
|
|
configuration
|
|
];
|
|
}
|