Skip to content

Commit

Permalink
Merge pull request #19 from nix-community/lxc
Browse files Browse the repository at this point in the history
merge lxc format
  • Loading branch information
Lassulus committed Aug 30, 2019
2 parents b7301e2 + 1575a02 commit defb4ee
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions formats/lxc-metadata.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions formats/lxc.nix
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit defb4ee

Please sign in to comment.