···
1
-
{ lib, config, pkgs, ... }:
···
./lxc-instance-common.nix
11
-
(lib.mkRemovedOptionModule [ "virtualisation" "lxc" "nestedContainer" ] "")
12
-
(lib.mkRemovedOptionModule [ "virtualisation" "lxc" "privilegedContainer" ] "")
16
+
(lib.mkRemovedOptionModule [
21
+
(lib.mkRemovedOptionModule [
24
+
"privilegedContainer"
18
-
initScript = if config.boot.initrd.systemd.enable then "prepare-root" else "init";
20
-
boot.isContainer = true;
21
-
boot.postBootCommands =
32
+
initScript = if config.boot.initrd.systemd.enable then "prepare-root" else "init";
35
+
boot.isContainer = true;
36
+
boot.postBootCommands = ''
# After booting, register the contents of the Nix store in the Nix
if [ -f /nix-path-registration ]; then
···
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
34
-
# supplement 99-ethernet-default-dhcp which excludes veth
35
-
systemd.network = lib.mkIf config.networking.useDHCP {
36
-
networks."99-lxc-veth-default-dhcp" = {
48
+
# supplement 99-ethernet-default-dhcp which excludes veth
49
+
systemd.network = lib.mkIf config.networking.useDHCP {
50
+
networks."99-lxc-veth-default-dhcp" = {
60
+
networkConfig.IPv6PrivacyExtensions = "kernel";
46
-
networkConfig.IPv6PrivacyExtensions = "kernel";
50
-
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
51
-
extraArgs = "--owner=0";
64
+
system.nixos.tags = lib.mkOverride 99 [ "lxc" ];
65
+
image.extension = "tar.xz";
66
+
image.filePath = "tarball/${config.image.fileName}";
67
+
system.build.image = lib.mkOverride 99 config.system.build.tarball;
55
-
object = config.system.build.toplevel;
69
+
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
70
+
fileName = config.image.baseName;
71
+
extraArgs = "--owner=0";
62
-
source = config.system.build.toplevel + "/${initScript}";
63
-
target = "/sbin/init";
65
-
# Technically this is not required for lxc, but having also make this configuration work with systemd-nspawn.
66
-
# Nixos will setup the same symlink after start.
68
-
source = config.system.build.toplevel + "/etc/os-release";
69
-
target = "/etc/os-release";
75
+
object = config.system.build.toplevel;
73
-
extraCommands = "mkdir -p proc sys dev";
82
+
source = config.system.build.toplevel + "/${initScript}";
83
+
target = "/sbin/init";
85
+
# Technically this is not required for lxc, but having also make this configuration work with systemd-nspawn.
86
+
# Nixos will setup the same symlink after start.
88
+
source = config.system.build.toplevel + "/etc/os-release";
89
+
target = "/etc/os-release";
76
-
system.build.squashfs = pkgs.callPackage ../../lib/make-squashfs.nix {
77
-
fileName = "nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}";
93
+
extraCommands = "mkdir -p proc sys dev";
79
-
hydraBuildProduct = true;
80
-
noStrip = true; # keep directory structure
81
-
comp = "zstd -Xcompression-level 6";
96
+
system.build.squashfs = pkgs.callPackage ../../lib/make-squashfs.nix {
97
+
fileName = "nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}";
83
-
storeContents = [config.system.build.toplevel];
99
+
hydraBuildProduct = true;
100
+
noStrip = true; # keep directory structure
101
+
comp = "zstd -Xcompression-level 6";
103
+
storeContents = [ config.system.build.toplevel ];
87
-
"/sbin/init s 0555 0 0 ${config.system.build.toplevel}/${initScript}"
107
+
"/sbin/init s 0555 0 0 ${config.system.build.toplevel}/${initScript}"
94
-
system.build.installBootLoader = pkgs.writeScript "install-lxc-sbin-init.sh" ''
95
-
#!${pkgs.runtimeShell}
96
-
${pkgs.coreutils}/bin/ln -fs "$1/${initScript}" /sbin/init
114
+
system.build.installBootLoader = pkgs.writeScript "install-lxc-sbin-init.sh" ''
115
+
#!${pkgs.runtimeShell}
116
+
${pkgs.coreutils}/bin/ln -fs "$1/${initScript}" /sbin/init
99
-
# networkd depends on this, but systemd module disables this for containers
100
-
systemd.additionalUpstreamSystemUnits = ["systemd-udev-trigger.service"];
119
+
# networkd depends on this, but systemd module disables this for containers
120
+
systemd.additionalUpstreamSystemUnits = [ "systemd-udev-trigger.service" ];
102
-
systemd.packages = [ pkgs.distrobuilder.generator ];
122
+
systemd.packages = [ pkgs.distrobuilder.generator ];
104
-
system.activationScripts.installInitScript = lib.mkForce ''
105
-
ln -fs $systemConfig/${initScript} /sbin/init
124
+
system.activationScripts.installInitScript = lib.mkForce ''
125
+
ln -fs $systemConfig/${initScript} /sbin/init