mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
virtualisation/lxc-container: use system.build.image
This commit is contained in:
parent
f3563c996e
commit
06ad3811a8
2 changed files with 109 additions and 80 deletions
|
@ -1,4 +1,9 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
meta = {
|
||||
|
@ -8,18 +13,27 @@
|
|||
imports = [
|
||||
./lxc-instance-common.nix
|
||||
|
||||
(lib.mkRemovedOptionModule [ "virtualisation" "lxc" "nestedContainer" ] "")
|
||||
(lib.mkRemovedOptionModule [ "virtualisation" "lxc" "privilegedContainer" ] "")
|
||||
(lib.mkRemovedOptionModule [
|
||||
"virtualisation"
|
||||
"lxc"
|
||||
"nestedContainer"
|
||||
] "")
|
||||
(lib.mkRemovedOptionModule [
|
||||
"virtualisation"
|
||||
"lxc"
|
||||
"privilegedContainer"
|
||||
] "")
|
||||
];
|
||||
|
||||
options = { };
|
||||
|
||||
config = let
|
||||
config =
|
||||
let
|
||||
initScript = if config.boot.initrd.systemd.enable then "prepare-root" else "init";
|
||||
in {
|
||||
in
|
||||
{
|
||||
boot.isContainer = true;
|
||||
boot.postBootCommands =
|
||||
''
|
||||
boot.postBootCommands = ''
|
||||
# After booting, register the contents of the Nix store in the Nix
|
||||
# database.
|
||||
if [ -f /nix-path-registration ]; then
|
||||
|
@ -47,7 +61,13 @@
|
|||
};
|
||||
};
|
||||
|
||||
system.nixos.tags = lib.mkOverride 99 [ "lxc" ];
|
||||
image.extension = "tar.xz";
|
||||
image.filePath = "tarball/${config.image.fileName}";
|
||||
system.build.image = lib.mkOverride 99 config.system.build.tarball;
|
||||
|
||||
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
|
||||
fileName = config.image.baseName;
|
||||
extraArgs = "--owner=0";
|
||||
|
||||
storeContents = [
|
||||
|
@ -80,7 +100,7 @@
|
|||
noStrip = true; # keep directory structure
|
||||
comp = "zstd -Xcompression-level 6";
|
||||
|
||||
storeContents = [config.system.build.toplevel];
|
||||
storeContents = [ config.system.build.toplevel ];
|
||||
|
||||
pseudoFiles = [
|
||||
"/sbin d 0755 0 0"
|
||||
|
@ -97,7 +117,7 @@
|
|||
'';
|
||||
|
||||
# networkd depends on this, but systemd module disables this for containers
|
||||
systemd.additionalUpstreamSystemUnits = ["systemd-udev-trigger.service"];
|
||||
systemd.additionalUpstreamSystemUnits = [ "systemd-udev-trigger.service" ];
|
||||
|
||||
systemd.packages = [ pkgs.distrobuilder.generator ];
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ let
|
|||
else { files = []; properties = {}; };
|
||||
|
||||
in {
|
||||
imports = [
|
||||
../image/file-options.nix
|
||||
];
|
||||
|
||||
meta = {
|
||||
maintainers = lib.teams.lxc.members;
|
||||
};
|
||||
|
@ -87,7 +91,12 @@ in {
|
|||
};
|
||||
|
||||
config = {
|
||||
system.nixos.tags = [ "lxc" "metadata" ];
|
||||
image.extension = "tar.xz";
|
||||
image.filePath = "tarball/${config.image.fileName}";
|
||||
system.build.image = config.system.build.metadata;
|
||||
system.build.metadata = pkgs.callPackage ../../lib/make-system-tarball.nix {
|
||||
fileName = config.image.baseName;
|
||||
contents = [
|
||||
{
|
||||
source = toYAML "metadata.yaml" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue