Revert "Merge #67232: machinectl compliant NixOS installation"
This reverts commitwip/yesman66967ec752
, reversing changes made tofb6595eafd
. Fixes #70442; discussion: https://github.com/NixOS/nixpkgs/pull/70027
parent
56e1ea32f4
commit
f760f0ef48
@ -1,37 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
version="5.0" |
||||
xml:id="sec-installing-nspawn-container"> |
||||
<title>Installing into a nspawn container</title> |
||||
|
||||
<para> |
||||
For installing a NixOS into a systemd nspawn container the NixOS installation tools are needed. |
||||
If you run another distribution than NixOS on your host, |
||||
please follow <xref linkend="sec-installing-from-other-distro"/> steps 1, 2, and 3. |
||||
</para> |
||||
|
||||
<para> |
||||
Create a NixOS configuration file <filename>/var/lib/machines/my-container/etc/nixos/configuration.nix</filename>. |
||||
It is important that the container root file system is under <filename>/var/lib/machines</filename>. |
||||
This is the standard location where <command>machinectl</command> will look for containers. |
||||
If you choose place the root into another location you need to start the container directly with <command>systemd-nspawn</command>. |
||||
The file needs to have at least following options enabled: |
||||
<programlisting> |
||||
<xref linkend="opt-boot.isContainer"/> = true; |
||||
<xref linkend="opt-boot.loader.initScript.enable"/> = true; |
||||
</programlisting> |
||||
If your host uses <command>systemd-networkd</command> to configure the network, |
||||
you can also enable <xref linkend="opt-networking.useNetworkd"/> to use networkd default network configuration for your host and container. |
||||
</para> |
||||
|
||||
<para> |
||||
Install the container by running following command: |
||||
<screen>nixos-install --root /var/lib/machines/my-container \ |
||||
--no-channel-copy --no-root-passwd --no-bootloader</screen> |
||||
</para> |
||||
|
||||
<para> |
||||
Start the container by running following command: |
||||
<screen>machinectl start my-container</screen> |
||||
</para> |
||||
|
||||
</section> |
@ -1,52 +0,0 @@ |
||||
import ./make-test.nix (let |
||||
|
||||
container = { ... }: { |
||||
boot.isContainer = true; |
||||
|
||||
# use networkd to obtain systemd network setup |
||||
networking.useNetworkd = true; |
||||
|
||||
# systemd-nspawn expects /sbin/init |
||||
boot.loader.initScript.enable = true; |
||||
|
||||
imports = [ ../modules/profiles/minimal.nix ]; |
||||
}; |
||||
|
||||
containerSystem = (import ../lib/eval-config.nix { |
||||
modules = [ container ]; |
||||
}).config.system.build.toplevel; |
||||
|
||||
containerName = "container"; |
||||
containerRoot = "/var/lib/machines/${containerName}"; |
||||
|
||||
in { |
||||
name = "systemd-machinectl"; |
||||
|
||||
machine = { lib, ... }: { |
||||
# use networkd to obtain systemd network setup |
||||
networking.useNetworkd = true; |
||||
|
||||
# open DHCP server on interface to container |
||||
networking.firewall.trustedInterfaces = [ "ve-+" ]; |
||||
|
||||
# do not try to access cache.nixos.org |
||||
nix.binaryCaches = lib.mkForce []; |
||||
|
||||
virtualisation.pathsInNixDB = [ containerSystem ]; |
||||
}; |
||||
|
||||
testScript = '' |
||||
startAll; |
||||
|
||||
$machine->waitForUnit("default.target"); |
||||
$machine->succeed("mkdir -p ${containerRoot}"); |
||||
$machine->succeed("nixos-install --root ${containerRoot} --system ${containerSystem} --no-channel-copy --no-root-passwd --no-bootloader"); |
||||
|
||||
$machine->succeed("machinectl start ${containerName}"); |
||||
$machine->waitUntilSucceeds("systemctl -M ${containerName} is-active default.target"); |
||||
$machine->succeed("ping -n -c 1 ${containerName}"); |
||||
$machine->succeed("test `stat ${containerRoot}/var/empty -c %u%g` != 00"); |
||||
|
||||
$machine->succeed("machinectl stop ${containerName}"); |
||||
''; |
||||
}) |
Loading…
Reference in new issue