git.iko.soy/typeable/nixpkgs
on master help sign in
Revert "Merge #67232: machinectl compliant NixOS installation"

This reverts commit 66967ec7521d065f605795d64ddbbbd4fcd448c3, reversing changes made to fb6595eafdb90ef0bc7a31c2bfc9204e4cad11d9. Fixes #70442; discussion: https://github.com/NixOS/nixpkgs/pull/70027

commitf760f0ef486815bf7d7223773addc35952d270b6 authorVladimír Čunát <v@cunat.cz> dateMon 7 Oct 2019, 20:44 (7 years ago) parent56e1ea3
7 files changed+2−103
nixos/doc/manual/installation/installing-nspawn-container.xml−37 nixos/doc/manual/installation/installing.xml−3 nixos/modules/installer/tools/nixos-install.sh+1−2 nixos/modules/system/activation/activation-script.nix−7 nixos/modules/virtualisation/container-config.nix+1−1 nixos/tests/all-tests.nix−1 nixos/tests/systemd-machinectl.nix−52
nixos/doc/manual/installation/installing-nspawn-container.xmldeleted−37
@@ -1,37 +0,0 @@
1−<section xmlns="http://docbook.org/ns/docbook"
2− version="5.0"
3− xml:id="sec-installing-nspawn-container">
4− <title>Installing into a nspawn container</title>
5−
6− <para>
7− For installing a NixOS into a systemd nspawn container the NixOS installation tools are needed.
8− If you run another distribution than NixOS on your host,
9− please follow <xref linkend="sec-installing-from-other-distro"/> steps 1, 2, and 3.
10− </para>
11−
12− <para>
13− Create a NixOS configuration file <filename>/var/lib/machines/my-container/etc/nixos/configuration.nix</filename>.
14− It is important that the container root file system is under <filename>/var/lib/machines</filename>.
15− This is the standard location where <command>machinectl</command> will look for containers.
16− If you choose place the root into another location you need to start the container directly with <command>systemd-nspawn</command>.
17− The file needs to have at least following options enabled:
18−<programlisting>
19−<xref linkend="opt-boot.isContainer"/> = true;
20−<xref linkend="opt-boot.loader.initScript.enable"/> = true;
21−</programlisting>
22− If your host uses <command>systemd-networkd</command> to configure the network,
23− you can also enable <xref linkend="opt-networking.useNetworkd"/> to use networkd default network configuration for your host and container.
24− </para>
25−
26− <para>
27− Install the container by running following command:
28− <screen>nixos-install --root /var/lib/machines/my-container \
29− --no-channel-copy --no-root-passwd --no-bootloader</screen>
30− </para>
31−
32− <para>
33− Start the container by running following command:
34− <screen>machinectl start my-container</screen>
35− </para>
36−
37−</section>
nixos/doc/manual/installation/installing.xml−3
@@ -563,8 +563,5 @@ Retype new UNIX password: ***</screen>
563563 <xi:include href="installing-from-other-distro.xml" />
564564
565565 <xi:include href="installing-behind-a-proxy.xml" />
566−
567− <xi:include href="installing-nspawn-container.xml" />
568−
569566 </section>
570567</chapter>
nixos/modules/installer/tools/nixos-install.sh+1−2
@@ -132,9 +132,8 @@ if [[ -z $noBootLoader ]]; then
132132 echo "installing the boot loader..."
133133 # Grub needs an mtab.
134134 ln -sfn /proc/mounts $mountPoint/etc/mtab
135− export NIXOS_INSTALL_BOOTLOADER=1
135+ NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root "$mountPoint" -- /run/current-system/bin/switch-to-configuration boot
136136fi
137−nixos-enter --root "$mountPoint" -- /run/current-system/bin/switch-to-configuration boot
138137
139138# Ask the user to set a root password, but only if the passwd command
140139# exists (i.e. when mutable user accounts are enabled).
nixos/modules/system/activation/activation-script.nix−7
@@ -184,14 +184,7 @@ in
184184 find /var/empty -mindepth 1 -delete
185185 chmod 0555 /var/empty
186186 chown root:root /var/empty
187−
188− ${ # reasons for not setting immutable flag:
189− # 1. flag is not changeable inside a container
190− # 2. systemd-nspawn can not perform chown in case of --private-users-chown
191− # then the owner is nobody and ssh will not start
192− optionalString (!config.boot.isContainer) ''
193187 ${pkgs.e2fsprogs}/bin/chattr -f +i /var/empty || true
194− ''}
195188 '';
196189
197190 system.activationScripts.usrbinenv = if config.environment.usrbinenv != null
nixos/modules/virtualisation/container-config.nix+1−1
@@ -11,7 +11,7 @@ with lib;
1111 services.udisks2.enable = mkDefault false;
1212 powerManagement.enable = mkDefault false;
1313
14− networking.useHostResolvConf = mkDefault (!config.services.resolved.enable);
14+ networking.useHostResolvConf = mkDefault true;
1515
1616 # Containers should be light-weight, so start sshd on demand.
1717 services.openssh.startWhenNeeded = mkDefault true;
nixos/tests/all-tests.nix−1
@@ -262,7 +262,6 @@ in
262262 syncthing-relay = handleTest ./syncthing-relay.nix {};
263263 systemd = handleTest ./systemd.nix {};
264264 systemd-confinement = handleTest ./systemd-confinement.nix {};
265− systemd-machinectl = handleTest ./systemd-machinectl.nix {};
266265 systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
267266 systemd-networkd-wireguard = handleTest ./systemd-networkd-wireguard.nix {};
268267 pdns-recursor = handleTest ./pdns-recursor.nix {};
nixos/tests/systemd-machinectl.nixdeleted−52
@@ -1,52 +0,0 @@
1−import ./make-test.nix (let
2−
3− container = { ... }: {
4− boot.isContainer = true;
5−
6− # use networkd to obtain systemd network setup
7− networking.useNetworkd = true;
8−
9− # systemd-nspawn expects /sbin/init
10− boot.loader.initScript.enable = true;
11−
12− imports = [ ../modules/profiles/minimal.nix ];
13− };
14−
15− containerSystem = (import ../lib/eval-config.nix {
16− modules = [ container ];
17− }).config.system.build.toplevel;
18−
19− containerName = "container";
20− containerRoot = "/var/lib/machines/${containerName}";
21−
22−in {
23− name = "systemd-machinectl";
24−
25− machine = { lib, ... }: {
26− # use networkd to obtain systemd network setup
27− networking.useNetworkd = true;
28−
29− # open DHCP server on interface to container
30− networking.firewall.trustedInterfaces = [ "ve-+" ];
31−
32− # do not try to access cache.nixos.org
33− nix.binaryCaches = lib.mkForce [];
34−
35− virtualisation.pathsInNixDB = [ containerSystem ];
36− };
37−
38− testScript = ''
39− startAll;
40−
41− $machine->waitForUnit("default.target");
42− $machine->succeed("mkdir -p ${containerRoot}");
43− $machine->succeed("nixos-install --root ${containerRoot} --system ${containerSystem} --no-channel-copy --no-root-passwd --no-bootloader");
44−
45− $machine->succeed("machinectl start ${containerName}");
46− $machine->waitUntilSucceeds("systemctl -M ${containerName} is-active default.target");
47− $machine->succeed("ping -n -c 1 ${containerName}");
48− $machine->succeed("test `stat ${containerRoot}/var/empty -c %u%g` != 00");
49−
50− $machine->succeed("machinectl stop ${containerName}");
51− '';
52−})