Browse Source

* 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
nsd-state-dir
Eelco Dolstra 14 years ago
parent
commit
02d26fc77d
  1. 23
      default.nix
  2. 18
      lib/eval-config.nix
  3. 3
      lib/from-env.nix

23
default.nix

@ -1,27 +1,16 @@
let
{ configuration ? import (import ./lib/from-env.nix "NIXOS_CONFIG" /etc/nixos/configuration.nix)
}:
fromEnv = name: default:
let env = builtins.getEnv name; in
if env == "" then default else env;
configuration = import (fromEnv "NIXOS_CONFIG" /etc/nixos/configuration.nix);
let
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;

18
lib/eval-config.nix

@ -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

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