nixpkgs/pkgs/tools/admin/lxd/default.nix

73 lines
2.2 KiB
Nix
Raw Normal View History

{ lib, hwdata, pkg-config, lxc, buildGoPackage, fetchurl
2018-06-28 19:59:07 +01:00
, makeWrapper, acl, rsync, gnutar, xz, btrfs-progs, gzip, dnsmasq
2021-03-14 16:05:16 +00:00
, squashfsTools, iproute2, iptables, ebtables, iptables-nftables-compat, libcap
2020-06-05 11:57:18 +01:00
, libco-canonical, dqlite, raft-canonical, sqlite-replication, udev
, writeShellScriptBin, apparmor-profiles, apparmor-parser
2019-07-09 17:47:19 +01:00
, criu
, bash
2020-04-26 04:16:56 +01:00
, installShellFiles
2020-06-05 11:57:18 +01:00
, nftablesSupport ? false
2018-03-16 09:58:54 +00:00
}:
2016-06-03 14:55:03 +01:00
2020-06-05 11:57:18 +01:00
let
networkPkgs = if nftablesSupport then
[ iptables-nftables-compat ]
else
[ iptables ebtables ];
in
2016-06-03 14:55:03 +01:00
buildGoPackage rec {
pname = "lxd";
2021-04-12 05:20:00 +01:00
version = "4.13";
2016-06-03 14:55:03 +01:00
goPackagePath = "github.com/lxc/lxd";
2018-03-16 09:58:54 +00:00
src = fetchurl {
url = "https://github.com/lxc/lxd/releases/download/${pname}-${version}/${pname}-${version}.tar.gz";
2021-04-12 05:20:00 +01:00
sha256 = "0w2r80wf86jijgfxbkv06lgfhz4p2aaidsqd96bx3q1382nrbzcf";
2016-06-03 14:55:03 +01:00
};
postPatch = ''
substituteInPlace shared/usbid/load.go \
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
'';
2018-03-16 09:58:54 +00:00
preBuild = ''
# unpack vendor
pushd go/src/github.com/lxc/lxd
rm _dist/src/github.com/lxc/lxd
cp -r _dist/src/* ../../..
2018-03-16 09:58:54 +00:00
popd
'';
2016-06-03 14:55:03 +01:00
2018-10-13 10:44:54 +01:00
buildFlags = [ "-tags libsqlite3" ];
2018-03-16 09:58:54 +00:00
postInstall = ''
2019-02-08 06:54:38 +00:00
# test binaries, code generation
rm $out/bin/{deps,macaroon-identity,generate}
2018-03-16 09:58:54 +00:00
2021-01-15 09:19:50 +00:00
wrapProgram $out/bin/lxd --prefix PATH : ${lib.makeBinPath (
2020-06-05 11:57:18 +01:00
networkPkgs
2021-03-14 16:05:16 +00:00
++ [ acl rsync gnutar xz btrfs-progs gzip dnsmasq squashfsTools iproute2 bash criu ]
2020-06-05 11:57:18 +01:00
++ [ (writeShellScriptBin "apparmor_parser" ''
exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
'') ]
)
}
2019-07-09 17:53:01 +01:00
installShellCompletion --bash --name lxd go/src/github.com/lxc/lxd/scripts/bash/lxd-client
2018-03-16 09:58:54 +00:00
'';
nativeBuildInputs = [ installShellFiles pkg-config makeWrapper ];
buildInputs = [ lxc acl libcap libco-canonical.dev dqlite.dev
2020-02-12 01:00:33 +00:00
raft-canonical.dev sqlite-replication udev.dev ];
2016-06-03 14:55:03 +01:00
meta = with lib; {
2016-06-03 14:55:03 +01:00
description = "Daemon based on liblxc offering a REST API to manage containers";
2020-04-02 10:20:00 +01:00
homepage = "https://linuxcontainers.org/lxd/";
2016-06-03 14:55:03 +01:00
license = licenses.asl20;
maintainers = with maintainers; [ fpletz wucke13 ];
2016-06-03 14:55:03 +01:00
platforms = platforms.linux;
};
}