Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2dfc3e525459
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8a14852fd34a
Choose a head ref
  • 3 commits
  • 1 file changed
  • 3 contributors

Commits on Dec 23, 2019

  1. nixos/lxd: add package options for LXC, LXD and ZFS

    Currently, LXD always use pkgs.zfs, even if boot.zfs.enableUnstable is set. This
    change provides the option to change the LXC, LXD and ZFS packages, and
    determines the default ZFS package based on zfs.enableUnstable.
    pstch committed Dec 23, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    etu Elis Hirwing
    Copy the full SHA
    665d863 View commit details

Commits on Jan 30, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    etu Elis Hirwing
    Copy the full SHA
    ccb3846 View commit details
  2. nixos/lxd: add package options for LXC, LXD and ZFS (#73902)

    nixos/lxd: add package options for LXC, LXD and ZFS
    Mic92 authored Jan 30, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    etu Elis Hirwing
    Copy the full SHA
    8a14852 View commit details
Showing with 37 additions and 7 deletions.
  1. +37 −7 nixos/modules/virtualisation/lxd.nix
44 changes: 37 additions & 7 deletions nixos/modules/virtualisation/lxd.nix
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ with lib;
let

cfg = config.virtualisation.lxd;
zfsCfg = config.boot.zfs;

in

@@ -26,11 +27,40 @@ in
<command>lxc</command> command line tool, among others.
'';
};

package = mkOption {
type = types.package;
default = pkgs.lxd;
defaultText = "pkgs.lxd";
description = ''
The LXD package to use.
'';
};

lxcPackage = mkOption {
type = types.package;
default = pkgs.lxc;
defaultText = "pkgs.lxc";
description = ''
The LXC package to use with LXD (required for AppArmor profiles).
'';
};

zfsPackage = mkOption {
type = types.package;
default = with pkgs; if zfsCfg.enableUnstable then zfsUnstable else zfs;
defaultText = "pkgs.zfs";
description = ''
The ZFS package to use with LXD.
'';
};

zfsSupport = mkOption {
type = types.bool;
default = false;
description = ''
enables lxd to use zfs as a storage for containers.
Enables lxd to use zfs as a storage for containers.
This option is enabled by default if a zfs pool is configured
with nixos.
'';
@@ -54,15 +84,15 @@ in

config = mkIf cfg.enable {

environment.systemPackages = [ pkgs.lxd ];
environment.systemPackages = [ cfg.package ];

security.apparmor = {
enable = true;
profiles = [
"${pkgs.lxc}/etc/apparmor.d/usr.bin.lxc-start"
"${pkgs.lxc}/etc/apparmor.d/lxc-containers"
"${cfg.lxcPackage}/etc/apparmor.d/usr.bin.lxc-start"
"${cfg.lxcPackage}/etc/apparmor.d/lxc-containers"
];
packages = [ pkgs.lxc ];
packages = [ cfg.lxcPackage ];
};

systemd.services.lxd = {
@@ -71,14 +101,14 @@ in
wantedBy = [ "multi-user.target" ];
after = [ "systemd-udev-settle.service" ];

path = lib.optional cfg.zfsSupport pkgs.zfs;
path = lib.optional cfg.zfsSupport cfg.zfsPackage;

preStart = ''
mkdir -m 0755 -p /var/lib/lxc/rootfs
'';

serviceConfig = {
ExecStart = "@${pkgs.lxd.bin}/bin/lxd lxd --group lxd";
ExecStart = "@${cfg.package.bin}/bin/lxd lxd --group lxd";
Type = "simple";
KillMode = "process"; # when stopping, leave the containers alone
LimitMEMLOCK = "infinity";