Revert "Add a way to pin a NixOS version within the module system."
This reverts commita5992ad61b
. Motivation:a5992ad61b (commitcomment-14986820)
This commit is contained in:
parent
a6347a3477
commit
d4636fa254
@ -1,20 +1,12 @@
|
|||||||
{ configuration ? import ./lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
|
{ configuration ? import ./lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
|
||||||
, system ? builtins.currentSystem
|
, system ? builtins.currentSystem
|
||||||
, extraModules ? []
|
|
||||||
# This attribute is used to specify a different nixos version, a different
|
|
||||||
# system or additional modules which might be set conditionally.
|
|
||||||
, reEnter ? false
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
reEnterModule = {
|
|
||||||
config.nixos.path = with (import ../lib); mkIf reEnter (mkForce null);
|
|
||||||
config.nixos.configuration = configuration;
|
|
||||||
};
|
|
||||||
|
|
||||||
eval = import ./lib/eval-config.nix {
|
eval = import ./lib/eval-config.nix {
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [ configuration reEnterModule ] ++ extraModules;
|
modules = [ configuration ];
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (eval) pkgs;
|
inherit (eval) pkgs;
|
||||||
@ -22,14 +14,14 @@ let
|
|||||||
# This is for `nixos-rebuild build-vm'.
|
# This is for `nixos-rebuild build-vm'.
|
||||||
vmConfig = (import ./lib/eval-config.nix {
|
vmConfig = (import ./lib/eval-config.nix {
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [ configuration reEnterModule ./modules/virtualisation/qemu-vm.nix ] ++ extraModules;
|
modules = [ configuration ./modules/virtualisation/qemu-vm.nix ];
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
# This is for `nixos-rebuild build-vm-with-bootloader'.
|
# This is for `nixos-rebuild build-vm-with-bootloader'.
|
||||||
vmWithBootLoaderConfig = (import ./lib/eval-config.nix {
|
vmWithBootLoaderConfig = (import ./lib/eval-config.nix {
|
||||||
inherit system;
|
inherit system;
|
||||||
modules =
|
modules =
|
||||||
[ configuration reEnterModule
|
[ configuration
|
||||||
./modules/virtualisation/qemu-vm.nix
|
./modules/virtualisation/qemu-vm.nix
|
||||||
{ virtualisation.useBootLoader = true; }
|
{ virtualisation.useBootLoader = true; }
|
||||||
];
|
];
|
||||||
@ -38,7 +30,7 @@ let
|
|||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
inherit (eval.config.nixos.reflect) config options;
|
inherit (eval) config options;
|
||||||
|
|
||||||
system = eval.config.system.build.toplevel;
|
system = eval.config.system.build.toplevel;
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ effect after you run <command>nixos-rebuild</command>.</para>
|
|||||||
<xi:include href="postgresql.xml" />
|
<xi:include href="postgresql.xml" />
|
||||||
<xi:include href="gitlab.xml" />
|
<xi:include href="gitlab.xml" />
|
||||||
<xi:include href="acme.xml" />
|
<xi:include href="acme.xml" />
|
||||||
<xi:include href="nixos.xml" />
|
|
||||||
|
|
||||||
<!-- Apache; libvirtd virtualisation -->
|
<!-- Apache; libvirtd virtualisation -->
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ let
|
|||||||
cp ${../../modules/services/databases/postgresql.xml} configuration/postgresql.xml
|
cp ${../../modules/services/databases/postgresql.xml} configuration/postgresql.xml
|
||||||
cp ${../../modules/services/misc/gitlab.xml} configuration/gitlab.xml
|
cp ${../../modules/services/misc/gitlab.xml} configuration/gitlab.xml
|
||||||
cp ${../../modules/security/acme.xml} configuration/acme.xml
|
cp ${../../modules/security/acme.xml} configuration/acme.xml
|
||||||
cp ${../../modules/misc/nixos.xml} configuration/nixos.xml
|
|
||||||
ln -s ${optionsDocBook} options-db.xml
|
ln -s ${optionsDocBook} options-db.xml
|
||||||
echo "${version}" > version
|
echo "${version}" > version
|
||||||
'';
|
'';
|
||||||
|
@ -11,19 +11,6 @@ has the following highlights:</para>
|
|||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>You can now pin a specific version of NixOS in your <filename>configuration.nix</filename>
|
|
||||||
by setting:
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
nixos.path = ./nixpkgs-unstable-2015-12-06/nixos;
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
This will make NixOS re-evaluate your configuration with the modules of
|
|
||||||
the specified NixOS version at the given path. For more details, see
|
|
||||||
<xref linkend="module-misc-nixos" /></para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Firefox and similar browsers are now <emphasis>wrapped by default</emphasis>.
|
<para>Firefox and similar browsers are now <emphasis>wrapped by default</emphasis>.
|
||||||
The package and attribute names are plain <literal>firefox</literal>
|
The package and attribute names are plain <literal>firefox</literal>
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
{ 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 "[ ./sshd-config.nix ]";
|
|
||||||
type = types.listOf (types.either (types.submodule ({...}:{options={};})) types.path);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
||||||
version="5.0"
|
|
||||||
xml:id="module-misc-nixos">
|
|
||||||
|
|
||||||
<title>NixOS Reentry</title>
|
|
||||||
|
|
||||||
<!-- FIXME: render nicely -->
|
|
||||||
|
|
||||||
<!-- FIXME: source can be added automatically -->
|
|
||||||
<para><emphasis>Source:</emphasis> <filename>modules/misc/nixos.nix</filename></para>
|
|
||||||
|
|
||||||
<!-- FIXME: more stuff, like maintainer? -->
|
|
||||||
|
|
||||||
<para>NixOS reentry can be used for both pinning the evaluation to a
|
|
||||||
specific version of NixOS, and to dynamically add additional modules into
|
|
||||||
the Module evaluation.</para>
|
|
||||||
|
|
||||||
<section><title>NixOS Version Pinning</title>
|
|
||||||
|
|
||||||
<para>To pin a specific version of NixOS, you need a version that you can
|
|
||||||
either clone localy, or that you can fetch remotely.</para>
|
|
||||||
|
|
||||||
<para>If you already have a cloned version of NixOS in the directory
|
|
||||||
<filename>/etc/nixos/nixpkgs-16-03</filename>, then you can specify the
|
|
||||||
<option>nixos.path</option> with either the path or the relative path of
|
|
||||||
your NixOS clone. For example, you can add the following to your
|
|
||||||
<filename>/etc/nixos/configuration.nix</filename> file:
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
nixos.path = ./nixpkgs-16-03/nixos;
|
|
||||||
</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>Another option is to fetch a specific version of NixOS, with either
|
|
||||||
the <literal>fetchTarball</literal> builtin, or the
|
|
||||||
<literal>pkgs.fetchFromGitHub</literal> function and use the result as an
|
|
||||||
input.
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
nixos.path = "${builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/1f27976e03c15183191d1b4aa1a40d1f14666cd2.tar.gz}/nixos";
|
|
||||||
</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section><title>Adding Module Dynamically</title>
|
|
||||||
|
|
||||||
<para>To add additional module, the recommended way is to use statically
|
|
||||||
known modules in the list of imported arguments as described in <xref
|
|
||||||
linkend="sec-modularity" />. Unfortunately, this recommended method has
|
|
||||||
limitation, such that the list of imported files cannot be selected based on
|
|
||||||
the content of the configuration.
|
|
||||||
|
|
||||||
Fortunately, NixOS reentry system can be used as an alternative to register
|
|
||||||
new imported modules based on the content of the configuration. To do so,
|
|
||||||
one should define both <option>nixos.path</option> and
|
|
||||||
<option>nixos.extraModules</option> options.
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
nixos.path = <nixos>;
|
|
||||||
nixos.extraModules =
|
|
||||||
if config.networking.hostName == "server" then
|
|
||||||
[ ./server.nix ] else [ ./client.nix ];
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
Also note, that the above can be reimplemented in a different way which is
|
|
||||||
not as expensive, by using <literal>mkIf</literal> at the top each
|
|
||||||
configuration if both modules are present on the file system (see <xref
|
|
||||||
linkend="sec-option-definitions" />) and by always inmporting both
|
|
||||||
modules.</para>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section><title>Options</title>
|
|
||||||
|
|
||||||
<para>FIXME: auto-generated list of module options.</para>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
</chapter>
|
|
@ -58,7 +58,6 @@
|
|||||||
./misc/lib.nix
|
./misc/lib.nix
|
||||||
./misc/locate.nix
|
./misc/locate.nix
|
||||||
./misc/meta.nix
|
./misc/meta.nix
|
||||||
./misc/nixos.nix
|
|
||||||
./misc/nixpkgs.nix
|
./misc/nixpkgs.nix
|
||||||
./misc/passthru.nix
|
./misc/passthru.nix
|
||||||
./misc/version.nix
|
./misc/version.nix
|
||||||
|
@ -284,7 +284,6 @@ in rec {
|
|||||||
tests.networkingProxy = callTest tests/networking-proxy.nix {};
|
tests.networkingProxy = callTest tests/networking-proxy.nix {};
|
||||||
tests.nfs3 = callTest tests/nfs.nix { version = 3; };
|
tests.nfs3 = callTest tests/nfs.nix { version = 3; };
|
||||||
tests.nfs4 = callTest tests/nfs.nix { version = 4; };
|
tests.nfs4 = callTest tests/nfs.nix { version = 4; };
|
||||||
tests.nixosPinVersion = callTest tests/nixos-pin-version.nix {};
|
|
||||||
tests.nsd = callTest tests/nsd.nix {};
|
tests.nsd = callTest tests/nsd.nix {};
|
||||||
tests.openssh = callTest tests/openssh.nix {};
|
tests.openssh = callTest tests/openssh.nix {};
|
||||||
tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; });
|
tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; });
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
{ system ? builtins.currentSystem }:
|
|
||||||
|
|
||||||
with import ../lib/testing.nix { inherit system; };
|
|
||||||
let
|
|
||||||
in
|
|
||||||
|
|
||||||
pkgs.stdenv.mkDerivation rec {
|
|
||||||
name = "nixos-pin-version";
|
|
||||||
src = ../..;
|
|
||||||
buildInputs = with pkgs; [ nix gnugrep ];
|
|
||||||
|
|
||||||
withoutPath = pkgs.writeText "configuration.nix" ''
|
|
||||||
{
|
|
||||||
nixos.extraModules = [ ({lib, ...}: { system.nixosRevision = lib.mkForce "ABCDEF"; }) ];
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
withPath = pkgs.writeText "configuration.nix" ''
|
|
||||||
{
|
|
||||||
nixos.path = ${src}/nixos ;
|
|
||||||
nixos.extraModules = [ ({lib, ...}: { system.nixosRevision = lib.mkForce "ABCDEF"; }) ];
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
phases = "buildPhase";
|
|
||||||
buildPhase = ''
|
|
||||||
datadir="${pkgs.nix}/share"
|
|
||||||
export TEST_ROOT=$(pwd)/test-tmp
|
|
||||||
export NIX_STORE_DIR=$TEST_ROOT/store
|
|
||||||
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
|
||||||
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
|
||||||
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
|
||||||
export NIX_DB_DIR=$TEST_ROOT/db
|
|
||||||
export NIX_CONF_DIR=$TEST_ROOT/etc
|
|
||||||
export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests
|
|
||||||
export NIX_BUILD_HOOK=
|
|
||||||
export PAGER=cat
|
|
||||||
cacheDir=$TEST_ROOT/binary-cache
|
|
||||||
nix-store --init
|
|
||||||
|
|
||||||
export NIX_PATH="nixpkgs=$src:nixos=$src/nixos:nixos-config=${withoutPath}" ;
|
|
||||||
if test $(nix-instantiate $src/nixos -A config.system.nixosRevision --eval-only) != '"ABCDEF"' ; then :;
|
|
||||||
else
|
|
||||||
echo "Unexpected re-entry without the nixos.path option defined.";
|
|
||||||
exit 1;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
export NIX_PATH="nixpkgs=$src:nixos=$src/nixos:nixos-config=${withPath}" ;
|
|
||||||
if test $(nix-instantiate $src/nixos -A config.system.nixosRevision --eval-only) = '"ABCDEF"' ; then :;
|
|
||||||
else
|
|
||||||
echo "Expected a re-entry when the nixos.path option is defined.";
|
|
||||||
exit 1;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
touch $out;
|
|
||||||
'';
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user