diff options
author | William A. Kennington III <william@wkennington.com> | 2015-09-13 23:27:31 -0700 |
---|---|---|
committer | William A. Kennington III <william@wkennington.com> | 2015-09-13 23:27:31 -0700 |
commit | c2e4fb29c6bca8fcfd20b834502d5755f9cf7a22 (patch) | |
tree | d7e449835682df8e12a4755fd597d8f5fb494e8f /nixos/modules/virtualisation | |
parent | 3c25c42e74a720f999a351f3a8b972e783d2abde (diff) |
nixos/lxd: Add service
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r-- | nixos/modules/virtualisation/lxd.nix | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/lxd.nix b/nixos/modules/virtualisation/lxd.nix new file mode 100644 index 0000000000000..488153334bc1b --- /dev/null +++ b/nixos/modules/virtualisation/lxd.nix @@ -0,0 +1,64 @@ +# Systemd services for lxd. + +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.virtualisation.lxd; + +in + +{ + ###### interface + + options = { + + virtualisation.lxd.enable = + mkOption { + type = types.bool; + default = false; + description = + '' + This option enables lxd, a daemon that manages + containers. Users in the "lxd" group can interact with + the daemon (e.g. to start or stop containers) using the + <command>lxc</command> command line tool, among others. + ''; + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + environment.systemPackages = + [ pkgs.lxd ]; + + systemd.services.lxd = + { description = "LXD Container Management Daemon"; + + wantedBy = [ "multi-user.target" ]; + after = [ "systemd-udev-settle.service" ]; + + # TODO(wkennington): Add lvm2 and thin-provisioning-tools + path = with pkgs; [ acl rsync gnutar xz btrfsProgs ]; + + serviceConfig.ExecStart = "@${pkgs.lxd}/bin/lxd lxd --syslog --group lxd"; + serviceConfig.Type = "simple"; + serviceConfig.KillMode = "process"; # when stopping, leave the containers alone + }; + + users.extraGroups.lxd.gid = config.ids.gids.lxd; + + users.extraUsers.root = { + subUidRanges = [ { startUid = 1000000; count = 65536; } ]; + subGidRanges = [ { startGid = 1000000; count = 65536; } ]; + }; + + }; + +} |