nixos-module/server/lxc-containers: resolve lxc interface name issue by ensuring the type key comes first
it took very long to find this
This commit is contained in:
parent
eb6e47e505
commit
8d671d8dee
|
@ -1,16 +1,6 @@
|
||||||
{ hostName, self, config, lib, pkgs, ... }:
|
{ hostName, self, config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Downgrade: lxc-4.0.9 names network interfaces in containers eth0,
|
|
||||||
# and eth1 despite configured differently.
|
|
||||||
lxc = pkgs.lxc.overrideAttrs (_: rec {
|
|
||||||
version = "4.0.6";
|
|
||||||
src = pkgs.fetchurl {
|
|
||||||
url = "https://linuxcontainers.org/downloads/lxc/lxc-${version}.tar.gz";
|
|
||||||
sha256 = "0qz4l7mlhq7hx53q606qgvkyzyr01glsw290v8ppzvxn1fydlrci";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
# Containers that are run on this host
|
# Containers that are run on this host
|
||||||
containers =
|
containers =
|
||||||
lib.filterAttrs (_: { role, model, ... }:
|
lib.filterAttrs (_: { role, model, ... }:
|
||||||
|
@ -54,12 +44,17 @@ let
|
||||||
})
|
})
|
||||||
) (builtins.attrNames interfaces);
|
) (builtins.attrNames interfaces);
|
||||||
|
|
||||||
|
attrNamesOrdered = attrs:
|
||||||
|
if attrs ? type
|
||||||
|
then [ "type" ] ++ lib.remove "type" (builtins.attrNames attrs)
|
||||||
|
else builtins.attrNames attrs;
|
||||||
|
|
||||||
serialize = name: x:
|
serialize = name: x:
|
||||||
if builtins.isString x
|
if builtins.isString x
|
||||||
then "${name} = ${x}\n"
|
then "${name} = ${x}\n"
|
||||||
else if builtins.isAttrs x
|
else if builtins.isAttrs x
|
||||||
then builtins.concatStringsSep "" (
|
then builtins.concatStringsSep "" (
|
||||||
map (n: serialize "${name}.${n}" x.${n}) (builtins.attrNames x)
|
map (n: serialize "${name}.${n}" x.${n}) (attrNamesOrdered x)
|
||||||
)
|
)
|
||||||
else if builtins.isList x
|
else if builtins.isList x
|
||||||
then
|
then
|
||||||
|
@ -176,7 +171,7 @@ in
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
# `lxc-attach` et al
|
# `lxc-attach` et al
|
||||||
lxc build-script
|
pkgs.lxc build-script
|
||||||
# User scripts
|
# User scripts
|
||||||
enable-script disable-script
|
enable-script disable-script
|
||||||
];
|
];
|
||||||
|
@ -234,14 +229,14 @@ in
|
||||||
"/var/lib/lxc/%i/rootfs/init"
|
"/var/lib/lxc/%i/rootfs/init"
|
||||||
"/etc/start-containers"
|
"/etc/start-containers"
|
||||||
];
|
];
|
||||||
serviceConfig = {
|
serviceConfig = with pkgs; {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${lxc}/bin/lxc-start -F -C -n %i";
|
ExecStart = "${lxc}/bin/lxc-start -F -C -n %i";
|
||||||
ExecStop = "${lxc}/bin/lxc-stop -n %i";
|
ExecStop = "${lxc}/bin/lxc-stop -n %i";
|
||||||
ExecReload =
|
ExecReload =
|
||||||
let
|
let
|
||||||
script = pkgs.writeScript "reload-lxc-container.sh" ''
|
script = writeScript "reload-lxc-container.sh" ''
|
||||||
#! ${pkgs.runtimeShell} -e
|
#! ${runtimeShell} -e
|
||||||
|
|
||||||
SYSTEM=$(dirname $(readlink /var/lib/lxc/$1/rootfs/init))
|
SYSTEM=$(dirname $(readlink /var/lib/lxc/$1/rootfs/init))
|
||||||
exec ${lxc}/bin/lxc-attach -n $1 $SYSTEM/bin/switch-to-configuration switch
|
exec ${lxc}/bin/lxc-attach -n $1 $SYSTEM/bin/switch-to-configuration switch
|
||||||
|
|
Loading…
Reference in New Issue