nixos-module/server/lxc-containers: add prebuilt containers

This commit is contained in:
Astro 2021-04-30 22:38:57 +02:00
parent 110f5c0ae3
commit 5c8fa22ca8
2 changed files with 28 additions and 3 deletions

View File

@ -138,6 +138,13 @@ let
};
hostOpts = { name, ... }: {
options = {
prebuilt = mkOption {
type = types.bool;
default = false;
description = ''
Include the container system in the server's `build-container` script.
'';
};
role = mkOption {
type = types.enum [ "ap" "switch" "server" "container" "client" ];
default = "client";

View File

@ -70,9 +70,27 @@ let
mkdir -p /nix/var/nix/gcroots/lxc
for c in $@; do
echo Building $c
nix build -o /nix/var/nix/gcroots/lxc/$c zentralwerk-network#$c-rootfs
SYSTEM=$(readlink /nix/var/nix/gcroots/lxc/$c)
unset SYSTEM
case "$c" in
${builtins.concatStringsSep "\n" (
map (ctName: ''
${ctName})
echo Using prebuilt system for container $c
SYSTEM=${self.packages.x86_64-linux."${ctName}-rootfs"}
;;
'') (
builtins.attrNames (
lib.filterAttrs (_: { prebuilt, ... }: prebuilt)
containers
))
)}
*)
echo Building $c
nix build -o /nix/var/nix/gcroots/lxc/$c zentralwerk-network#$c-rootfs
SYSTEM=$(readlink /nix/var/nix/gcroots/lxc/$c)
;;
esac
echo Installing $c
for d in \