* Make eval-config.nix a bit more general to make it easier to build

other kinds of configurations (like the installation CD).

svn path=/nixos/branches/modular-nixos/; revision=15864
This commit is contained in:
Eelco Dolstra 2009-06-05 13:19:39 +00:00
parent dc8cbffe31
commit 02d26fc77d
3 changed files with 24 additions and 20 deletions

View file

@ -1,27 +1,16 @@
{ configuration ? import (import ./lib/from-env.nix "NIXOS_CONFIG" /etc/nixos/configuration.nix)
}:
let
fromEnv = name: default:
let env = builtins.getEnv name; in
if env == "" then default else env;
configuration = import (fromEnv "NIXOS_CONFIG" /etc/nixos/configuration.nix);
nixpkgs = fromEnv "NIXPKGS" /etc/nixos/nixpkgs;
pkgs = import nixpkgs {system = builtins.currentSystem;};
inherit
(import ./lib/eval-config.nix {inherit configuration pkgs;})
config optionDeclarations;
(import ./lib/eval-config.nix {inherit configuration;})
config optionDeclarations pkgs;
in
{
# Optionally check wether all config values have corresponding
# option declarations.
system = pkgs.checker config.system.build.system
config.environment.checkConfigurationOptions
optionDeclarations config;
system = config.system.build.system;
# The following are used by nixos-rebuild.
nixFallback = pkgs.nixUnstable;

View file

@ -2,9 +2,15 @@
# configuration object (`config') from which we can retrieve option
# values.
{configuration, pkgs}:
{ configuration
, system ? builtins.currentSystem
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
, pkgs ? import nixpkgs {inherit system;}
}:
rec {
inherit nixpkgs pkgs;
configComponents = [
configuration
{
@ -19,7 +25,7 @@ rec {
}
];
config =
config_ =
pkgs.lib.fixOptionSets
pkgs.lib.mergeOptionSets
pkgs configComponents;
@ -28,5 +34,11 @@ rec {
pkgs.lib.fixOptionSetsFun
pkgs.lib.filterOptionSets
pkgs configComponents
config;
config_;
# Optionally check wether all config values have corresponding
# option declarations.
config = pkgs.checker config_
config_.environment.checkConfigurationOptions
optionDeclarations config_;
}

3
lib/from-env.nix Normal file
View file

@ -0,0 +1,3 @@
name: default:
let value = builtins.getEnv name; in
if value == "" then default else value