Merge pull request #19 from nix-community/lxc

merge lxc format
This commit is contained in:
Lassulus 2019-08-30 19:09:36 +02:00 committed by GitHub
commit defb4eed14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -36,6 +36,8 @@ install-iso | Installer ISO
iso | ISO
kexec | kexec tarball (extract to / and run /kexec_nixos)
kexec-bundle | same as before, but it's just an executable
lxc | create a tarball which is importable as an lxc container, use together with lxc-metadata
lxc-metadata | the necessary metadata for the lxc image to start, usage: lxc image import $(nixos-generate -f lxc-metadata) $(nixos-generate -f lxc)
openstack | qcow2 image for openstack
cloudstack | qcow2 image for cloudstack
qcow2 | qcow2 image

18
formats/lxc-metadata.nix Normal file
View File

@ -0,0 +1,18 @@
{ config, pkgs, modulesPath, ... }:
{
system.build.metadata = pkgs.callPackage <nixpkgs/nixos/lib/make-system-tarball.nix> {
contents = [{
source = pkgs.writeText "metadata.yaml" ''
architecture: x86_64
creation_date: 1424284563
properties:
description: NixOS
os: NixOS
release: ${config.system.stateVersion}
'';
target = "/metadata.yaml";
}];
};
formatAttr = "metadata";
}

22
formats/lxc.nix Normal file
View File

@ -0,0 +1,22 @@
{ config, pkgs, lib, modulesPath, ... }: let
pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;
in {
imports = [
"${toString modulesPath}/virtualisation/lxc-container.nix"
];
system.build.tarball = lib.mkForce (pkgs.callPackage <nixpkgs/nixos/lib/make-system-tarball.nix> {
contents = [];
extraArgs = "--owner=0";
storeContents = [
{
object = config.system.build.toplevel + "/init";
symlink = "/sbin/init";
}
] ++ (pkgs2storeContents [ pkgs.stdenv ]);
extraCommands = "mkdir -p proc sys dev";
});
formatAttr = "tarball";
}