2009-05-27 11:16:56 +02:00
|
|
|
# From an end-user configuration file (`configuration'), build a NixOS
|
|
|
|
# configuration object (`config') from which we can retrieve option
|
|
|
|
# values.
|
|
|
|
|
2009-08-27 13:57:43 +02:00
|
|
|
{ system ? builtins.currentSystem
|
2009-06-05 15:19:39 +02:00
|
|
|
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
|
2009-11-12 00:54:54 +01:00
|
|
|
, services ? ../../services
|
2009-08-26 18:52:38 +02:00
|
|
|
, pkgs ? null
|
|
|
|
, baseModules ? import ../modules/module-list.nix
|
2009-08-05 16:43:13 +02:00
|
|
|
, extraArgs ? {}
|
2009-08-27 13:57:43 +02:00
|
|
|
, modules
|
2009-06-05 15:19:39 +02:00
|
|
|
}:
|
2009-05-27 11:16:56 +02:00
|
|
|
|
2010-11-23 17:07:00 +01:00
|
|
|
let extraArgs_ = extraArgs; pkgs_ = pkgs; system_ = system; in
|
2009-08-05 16:43:13 +02:00
|
|
|
|
2009-05-27 11:16:56 +02:00
|
|
|
rec {
|
2009-06-05 15:19:39 +02:00
|
|
|
|
2009-08-26 18:52:38 +02:00
|
|
|
# These are the NixOS modules that constitute the system configuration.
|
2009-08-27 13:57:43 +02:00
|
|
|
configComponents = modules ++ baseModules;
|
2009-05-27 11:16:56 +02:00
|
|
|
|
2009-08-26 18:52:38 +02:00
|
|
|
# Merge the option definitions in all modules, forming the full
|
2009-09-15 16:09:11 +02:00
|
|
|
# system configuration. It's not checked for undeclared options.
|
|
|
|
systemModule =
|
|
|
|
pkgs.lib.fixMergeModules configComponents extraArgs;
|
|
|
|
|
|
|
|
optionDefinitions = systemModule.config;
|
|
|
|
optionDeclarations = systemModule.options;
|
2009-09-15 16:09:18 +02:00
|
|
|
inherit (systemModule) options;
|
2009-08-26 18:52:38 +02:00
|
|
|
|
|
|
|
# These are the extra arguments passed to every module. In
|
|
|
|
# particular, Nixpkgs is passed through the "pkgs" argument.
|
2009-08-05 16:43:13 +02:00
|
|
|
extraArgs = extraArgs_ // {
|
2010-05-08 19:18:26 +02:00
|
|
|
inherit pkgs modules baseModules;
|
2009-07-14 14:36:02 +02:00
|
|
|
modulesPath = ../modules;
|
2009-08-31 16:56:19 +02:00
|
|
|
servicesPath = services;
|
2010-05-31 00:00:52 +02:00
|
|
|
pkgs_i686 = import nixpkgs { system = "i686-linux"; };
|
2009-07-14 14:36:02 +02:00
|
|
|
};
|
|
|
|
|
2009-08-26 18:52:38 +02:00
|
|
|
# Import Nixpkgs, allowing the NixOS option nixpkgs.config to
|
|
|
|
# specify the Nixpkgs configuration (e.g., to set package options
|
|
|
|
# such as firefox.enableGeckoMediaPlayer, or to apply global
|
2010-11-23 17:07:00 +01:00
|
|
|
# overrides such as changing GCC throughout the system), and the
|
|
|
|
# option nixpkgs.system to override the platform type. This is
|
2009-08-26 18:52:38 +02:00
|
|
|
# tricky, because we have to prevent an infinite recursion: "pkgs"
|
|
|
|
# is passed as an argument to NixOS modules, but the value of "pkgs"
|
|
|
|
# depends on config.nixpkgs.config, which we get from the modules.
|
|
|
|
# So we call ourselves here with "pkgs" explicitly set to an
|
|
|
|
# instance that doesn't depend on nixpkgs.config.
|
|
|
|
pkgs =
|
|
|
|
if pkgs_ != null
|
|
|
|
then pkgs_
|
2010-02-27 19:37:12 +01:00
|
|
|
else import nixpkgs (
|
|
|
|
let
|
2010-11-23 17:07:00 +01:00
|
|
|
system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
|
2010-02-27 19:37:12 +01:00
|
|
|
nixpkgsOptions = (import ./eval-config.nix {
|
2009-08-31 16:56:19 +02:00
|
|
|
inherit system nixpkgs services extraArgs modules;
|
2009-08-26 18:52:38 +02:00
|
|
|
# For efficiency, leave out most NixOS modules; they don't
|
|
|
|
# define nixpkgs.config, so it's pointless to evaluate them.
|
|
|
|
baseModules = [ ../modules/misc/nixpkgs.nix ];
|
2010-11-23 17:07:00 +01:00
|
|
|
pkgs = import nixpkgs { system = system_; config = {}; };
|
2010-02-27 19:37:12 +01:00
|
|
|
}).optionDefinitions.nixpkgs;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit system;
|
2010-09-08 18:52:15 +02:00
|
|
|
inherit (nixpkgsOptions) config;
|
2010-02-27 19:37:12 +01:00
|
|
|
});
|
2009-05-27 11:16:56 +02:00
|
|
|
|
2009-06-05 15:19:39 +02:00
|
|
|
# Optionally check wether all config values have corresponding
|
|
|
|
# option declarations.
|
2009-12-05 20:22:02 +01:00
|
|
|
config =
|
|
|
|
let doCheck = optionDefinitions.environment.checkConfigurationOptions; in
|
|
|
|
assert doCheck -> pkgs.lib.checkModule "" systemModule;
|
|
|
|
systemModule.config;
|
2009-05-27 11:16:56 +02:00
|
|
|
}
|