diff options
author | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-11-20 20:11:21 +0000 |
---|---|---|
committer | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-11-20 20:11:21 +0000 |
commit | 4e61fc89d261eb4815186b451e43a5925a4eb2a1 (patch) | |
tree | 18a0003e7d917216a91d5f1e544c5f11f029b4de /nixos/modules/misc/nixos.nix | |
parent | eae62caf916bae65c40a69f88a088d540c6c7765 (diff) | |
parent | a5992ad61b314104aff7e28a41ce101a1b0e7c35 (diff) | |
download | nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.gz nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.bz2 nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.lz nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.xz nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.zst nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.zip |
Merge pull request #11106 from nbp/nixos-reentry
Add a way to pin a NixOS version within the module system.
Diffstat (limited to 'nixos/modules/misc/nixos.nix')
-rw-r--r-- | nixos/modules/misc/nixos.nix | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/nixos/modules/misc/nixos.nix b/nixos/modules/misc/nixos.nix new file mode 100644 index 000000000000..356129211d06 --- /dev/null +++ b/nixos/modules/misc/nixos.nix @@ -0,0 +1,82 @@ +{ config, options, lib, ... }: + +# This modules is used to inject a different NixOS version as well as its +# argument such that one can pin a specific version with the versionning +# system of the configuration. +let + nixosReentry = import config.nixos.path { + inherit (config.nixos) configuration extraModules; + inherit (config.nixpkgs) system; + reEnter = true; + }; +in + +with lib; + +{ + options = { + nixos.path = mkOption { + default = null; + example = literalExample "./nixpkgs-15.09/nixos"; + type = types.nullOr types.path; + description = '' + This option give the ability to evaluate the current set of modules + with a different version of NixOS. This option can be used version + the version of NixOS with the configuration without relying on the + <literal>NIX_PATH</literal> environment variable. + ''; + }; + + nixos.system = mkOption { + example = "i686-linux"; + type = types.uniq types.str; + description = '' + Name of the system used to compile NixOS. + ''; + }; + + nixos.extraModules = mkOption { + default = []; + example = literalExample "mkIf config.services.openssh.enable [ ./sshd-config.nix ]"; + type = types.listOf types.unspecified; + description = '' + Define additional modules which would be loaded to evaluate the + configuration. + ''; + }; + + nixos.configuration = mkOption { + type = types.unspecified; + internal = true; + description = '' + Option used by <filename>nixos/default.nix</filename> to re-inject + the same configuration module as the one used for the current + execution. + ''; + }; + + nixos.reflect = mkOption { + default = { inherit config options; }; + type = types.unspecified; + internal = true; + description = '' + Provides <literal>config</literal> and <literal>options</literal> + computed by the module system and given as argument to all + modules. These are used for introspection of options and + configuration by tools such as <literal>nixos-option</literal>. + ''; + }; + }; + + config = mkMerge [ + (mkIf (config.nixos.path != null) (mkForce { + system.build.toplevel = nixosReentry.system; + system.build.vm = nixosReentry.vm; + nixos.reflect = { inherit (nixosReentry) config options; }; + })) + + { meta.maintainers = singleton lib.maintainers.pierron; + meta.doc = ./nixos.xml; + } + ]; +} |