nixos/maintainers/scripts/lxd: simplify config generation
Use modulesPath so we don't have to magically rewrite paths in activation script, set stateVersion to the one this was built with (which should approximate "first install")
This commit is contained in:
parent
100931cca6
commit
67f87ecc27
4 changed files with 20 additions and 12 deletions
|
@ -2,13 +2,13 @@
|
|||
# your system. Help is available in the configuration.nix(5) man page
|
||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||
|
||||
{ config, pkgs, lib, ... }:
|
||||
{ config, pkgs, lib, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
# Include the default lxd configuration.
|
||||
../../../modules/virtualisation/lxc-container.nix
|
||||
"${modulesPath}/modules/virtualisation/lxc-container.nix"
|
||||
# Include the container-specific autogenerated configuration.
|
||||
./lxd.nix
|
||||
];
|
||||
|
@ -16,5 +16,5 @@
|
|||
networking.useDHCP = false;
|
||||
networking.interfaces.eth0.useDHCP = true;
|
||||
|
||||
system.stateVersion = "21.05"; # Did you read the comment?
|
||||
system.stateVersion = "@stateVersion@"; # Did you read the comment?
|
||||
}
|
||||
|
|
|
@ -13,11 +13,15 @@
|
|||
};
|
||||
|
||||
# copy the config for nixos-rebuild
|
||||
system.activationScripts.config = ''
|
||||
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
|
||||
mkdir -p /etc/nixos
|
||||
cat ${./lxd-container-image-inner.nix} > /etc/nixos/configuration.nix
|
||||
${lib.getExe pkgs.gnused} 's|../../../modules/virtualisation/lxc-container.nix|<nixpkgs/nixos/modules/virtualisation/lxc-container.nix>|g' -i /etc/nixos/configuration.nix
|
||||
cp ${config} /etc/nixos/configuration.nix
|
||||
fi
|
||||
'';
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
# your system. Help is available in the configuration.nix(5) man page
|
||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||
|
||||
{ config, pkgs, lib, ... }:
|
||||
{ config, pkgs, lib, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
# Include the default lxd configuration.
|
||||
../../../modules/virtualisation/lxd-virtual-machine.nix
|
||||
"${modulesPath}/virtualisation/lxd-virtual-machine.nix"
|
||||
# Include the container-specific autogenerated configuration.
|
||||
./lxd.nix
|
||||
];
|
||||
|
@ -16,5 +16,5 @@
|
|||
networking.useDHCP = false;
|
||||
networking.interfaces.eth0.useDHCP = true;
|
||||
|
||||
system.stateVersion = "23.05"; # Did you read the comment?
|
||||
system.stateVersion = "@stateVersion@"; # Did you read the comment?
|
||||
}
|
||||
|
|
|
@ -13,11 +13,15 @@
|
|||
};
|
||||
|
||||
# copy the config for nixos-rebuild
|
||||
system.activationScripts.config = ''
|
||||
system.activationScripts.config = let
|
||||
config = pkgs.substituteAll {
|
||||
src = ./lxd-virtual-machine-image-inner.nix;
|
||||
stateVersion = lib.trivial.release;
|
||||
};
|
||||
in ''
|
||||
if [ ! -e /etc/nixos/configuration.nix ]; then
|
||||
mkdir -p /etc/nixos
|
||||
cat ${./lxd-virtual-machine-image-inner.nix} > /etc/nixos/configuration.nix
|
||||
${lib.getExe pkgs.gnused} 's|../../../modules/virtualisation/lxd-virtual-machine.nix|<nixpkgs/nixos/modules/virtualisation/lxd-virtual-machine.nix>|g' -i /etc/nixos/configuration.nix
|
||||
cp ${config} /etc/nixos/configuration.nix
|
||||
fi
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue