2009-05-27 10:16:56 +01:00
|
|
|
# From an end-user configuration file (`configuration'), build a NixOS
|
|
|
|
# configuration object (`config') from which we can retrieve option
|
|
|
|
# values.
|
|
|
|
|
2009-06-05 14:19:39 +01:00
|
|
|
{ configuration
|
|
|
|
, system ? builtins.currentSystem
|
|
|
|
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
|
|
|
|
, pkgs ? import nixpkgs {inherit system;}
|
2009-08-05 15:43:13 +01:00
|
|
|
, extraArgs ? {}
|
2009-08-11 02:35:56 +01:00
|
|
|
, extraModules ? []
|
2009-06-05 14:19:39 +01:00
|
|
|
}:
|
2009-05-27 10:16:56 +01:00
|
|
|
|
2009-08-05 15:43:13 +01:00
|
|
|
let extraArgs_ = extraArgs; in
|
|
|
|
|
2009-05-27 10:16:56 +01:00
|
|
|
rec {
|
2009-06-05 14:19:39 +01:00
|
|
|
inherit nixpkgs pkgs;
|
|
|
|
|
2009-08-11 02:35:56 +01:00
|
|
|
configComponents =
|
|
|
|
[ configuration
|
|
|
|
./check-config.nix
|
|
|
|
]
|
|
|
|
++ extraModules
|
|
|
|
++ (import ../modules/module-list.nix);
|
2009-05-27 10:16:56 +01:00
|
|
|
|
2009-08-05 15:43:13 +01:00
|
|
|
extraArgs = extraArgs_ // {
|
2009-08-21 10:08:55 +01:00
|
|
|
inherit pkgs optionDeclarations;
|
2009-07-14 13:36:02 +01:00
|
|
|
modulesPath = ../modules;
|
|
|
|
};
|
|
|
|
|
2009-06-05 14:19:39 +01:00
|
|
|
config_ =
|
2009-07-14 13:36:02 +01:00
|
|
|
pkgs.lib.definitionsOf configComponents extraArgs;
|
2009-05-27 10:16:56 +01:00
|
|
|
|
2009-07-07 00:25:12 +01:00
|
|
|
# "fixableDeclarationsOf" is used instead of "declarationsOf" because some
|
|
|
|
# option default values may depends on the definition of other options.
|
2009-08-21 10:11:33 +01:00
|
|
|
# !!! This seems inefficent. Didn't definitionsOf already compute
|
|
|
|
# the option declarations?
|
2009-05-27 10:16:56 +01:00
|
|
|
optionDeclarations =
|
2009-07-14 13:36:02 +01:00
|
|
|
pkgs.lib.fixableDeclarationsOf configComponents extraArgs config_;
|
2009-07-07 00:25:12 +01:00
|
|
|
|
2009-06-05 14:19:39 +01:00
|
|
|
# Optionally check wether all config values have corresponding
|
|
|
|
# option declarations.
|
|
|
|
config = pkgs.checker config_
|
|
|
|
config_.environment.checkConfigurationOptions
|
|
|
|
optionDeclarations config_;
|
2009-05-27 10:16:56 +01:00
|
|
|
}
|