mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-19 23:22:57 +01:00
before: ``` [root@nixos:~]# ls -la /etc/nixos total 16 drwxr-xr-x 2 root root 4096 Feb 8 00:51 . drwxr-xr-x 16 root root 4096 Feb 8 00:51 .. -r--r--r-- 1 root root 605 Feb 8 00:51 configuration.nix -rw-r--r-- 1 root root 150 Feb 8 00:51 lxd.nix ``` after: ``` [root@nixos:~]# ls -la /etc/nixos total 16 drwxr-xr-x 2 root root 4096 Feb 8 00:50 . drwxr-xr-x 16 root root 4096 Feb 8 00:50 .. -rw-r--r-- 1 root root 605 Feb 8 00:50 configuration.nix -rw-r--r-- 1 root root 149 Feb 8 00:50 lxd.nix ```
31 lines
685 B
Nix
31 lines
685 B
Nix
{ lib, pkgs, ... }:
|
|
|
|
{
|
|
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 = let
|
|
config = pkgs.substituteAll {
|
|
src = ./lxd-container-image-inner.nix;
|
|
stateVersion = lib.trivial.release;
|
|
};
|
|
in ''
|
|
if [ ! -e /etc/nixos/configuration.nix ]; then
|
|
install -m 644 -D ${config} /etc/nixos/configuration.nix
|
|
fi
|
|
'';
|
|
|
|
# Network
|
|
networking.useDHCP = false;
|
|
networking.interfaces.eth0.useDHCP = true;
|
|
}
|