Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxc #19

Merged
merged 1 commit into from
Aug 30, 2019
Merged

lxc #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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";
}