- Make tests/lxd.nix use NixOS's lxdMeta & lxdImage to avoid relying on 3rd party containers such as Alpine Linux for testing purposes. - Merge tests/lxd-image.nix into tests/lxd.nix, since now both have a similar structure. - Extract duplicated inline LXD configuration into a separate file, - Add passthru.lxd-nftables & passthru.lxd-image-server.
35 lines
937 B
Nix
35 lines
937 B
Nix
{ lib, config, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
imports = [
|
|
../../../modules/virtualisation/lxc-container.nix
|
|
];
|
|
|
|
virtualisation.lxc.templates.nix = {
|
|
enable = true;
|
|
target = "/etc/nixos/lxd.nix";
|
|
template = ./nix.tpl;
|
|
when = [ "create" "copy" ];
|
|
};
|
|
|
|
# copy the config for nixos-rebuild
|
|
system.activationScripts.config = ''
|
|
if [ ! -e /etc/nixos/configuration.nix ]; then
|
|
mkdir -p /etc/nixos
|
|
cat ${./lxd-image-inner.nix} > /etc/nixos/configuration.nix
|
|
sed 's|../../../modules/virtualisation/lxc-container.nix|<nixpkgs/nixos/modules/virtualisation/lxc-container.nix>|g' -i /etc/nixos/configuration.nix
|
|
fi
|
|
'';
|
|
|
|
# Network
|
|
networking.useDHCP = false;
|
|
networking.interfaces.eth0.useDHCP = true;
|
|
|
|
# As this is intended as a standalone image, undo some of the minimal profile stuff
|
|
documentation.enable = true;
|
|
documentation.nixos.enable = true;
|
|
environment.noXlibs = false;
|
|
}
|