89ef5c979b
machine containing a replica (minus the state) of the system configuration. This is mostly useful for testing configuration changes prior to doing an actual "nixos-rebuild switch" (or even "nixos-rebuild test"). The VM can be started as follows: $ nixos-rebuild build-vm $ ./result/bin/run-*-vm which starts a KVM/QEMU instance. Additional QEMU options can be passed through the QEMU_OPTS environment variable (e.g. QEMU_OPTS="-redir tcp:8080::80" to forward a host port to the guest). The fileSystem attribute of the regular system configuration is ignored (using mkOverride), because obviously we can't allow the VM to access the host's block devices. Instead, at startup the VM creates an empty disk image in ./<hostname>.qcow2 to store the VM's root filesystem. Building a VM in this way is efficient because the VM shares its Nix store with the host (through a CIFS mount). However, because the Nix store of the host is mounted read-only in the guest, you cannot run Nix build actions inside the VM. Therefore the VM can only be reconfigured by re-running "nixos-rebuild build-vm" on the host and restarting the VM. svn path=/nixos/trunk/; revision=16662
43 lines
1.1 KiB
Nix
43 lines
1.1 KiB
Nix
# From an end-user configuration file (`configuration'), build a NixOS
|
|
# configuration object (`config') from which we can retrieve option
|
|
# values.
|
|
|
|
{ configuration
|
|
, system ? builtins.currentSystem
|
|
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
|
|
, pkgs ? import nixpkgs {inherit system;}
|
|
, extraArgs ? {}
|
|
, extraModules ? []
|
|
}:
|
|
|
|
let extraArgs_ = extraArgs; in
|
|
|
|
rec {
|
|
inherit nixpkgs pkgs;
|
|
|
|
configComponents =
|
|
[ configuration
|
|
./check-config.nix
|
|
]
|
|
++ extraModules
|
|
++ (import ../modules/module-list.nix);
|
|
|
|
extraArgs = extraArgs_ // {
|
|
inherit pkgs;
|
|
modulesPath = ../modules;
|
|
};
|
|
|
|
config_ =
|
|
pkgs.lib.definitionsOf configComponents extraArgs;
|
|
|
|
# "fixableDeclarationsOf" is used instead of "declarationsOf" because some
|
|
# option default values may depends on the definition of other options.
|
|
optionDeclarations =
|
|
pkgs.lib.fixableDeclarationsOf configComponents extraArgs config_;
|
|
|
|
# Optionally check wether all config values have corresponding
|
|
# option declarations.
|
|
config = pkgs.checker config_
|
|
config_.environment.checkConfigurationOptions
|
|
optionDeclarations config_;
|
|
}
|