nixos/lxd: Add service
This commit is contained in:
parent
3c25c42e74
commit
c2e4fb29c6
|
@ -231,6 +231,7 @@
|
|||
gateone = 207;
|
||||
namecoin = 208;
|
||||
dnschain = 209;
|
||||
#lxd = 210; # unused
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||
|
||||
|
@ -440,6 +441,7 @@
|
|||
gateone = 207;
|
||||
namecoin = 208;
|
||||
#dnschain = 209; #unused
|
||||
lxd = 210; # unused
|
||||
|
||||
# When adding a gid, make sure it doesn't match an existing
|
||||
# uid. Users and groups with the same name should have equal
|
||||
|
|
|
@ -487,6 +487,7 @@
|
|||
./virtualisation/docker.nix
|
||||
./virtualisation/libvirtd.nix
|
||||
./virtualisation/lxc.nix
|
||||
./virtualisation/lxd.nix
|
||||
./virtualisation/amazon-options.nix
|
||||
./virtualisation/openvswitch.nix
|
||||
./virtualisation/parallels-guest.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; } ];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue