2020-05-03 12:34:25 +00:00
|
|
|
{ stdenv, hwdata, pkgconfig, lxc, buildGoPackage, fetchurl
|
2018-06-28 18:59:07 +00:00
|
|
|
, makeWrapper, acl, rsync, gnutar, xz, btrfs-progs, gzip, dnsmasq
|
2020-06-05 10:57:18 +00:00
|
|
|
, squashfsTools, iproute, iptables, ebtables, iptables-nftables-compat, libcap
|
|
|
|
, libco-canonical, dqlite, raft-canonical, sqlite-replication, udev
|
2018-11-20 06:36:56 +00:00
|
|
|
, writeShellScriptBin, apparmor-profiles, apparmor-parser
|
2019-07-09 16:47:19 +00:00
|
|
|
, criu
|
2019-02-04 08:19:14 +00:00
|
|
|
, bash
|
2020-04-26 03:16:56 +00:00
|
|
|
, installShellFiles
|
2020-06-05 10:57:18 +00:00
|
|
|
, nftablesSupport ? false
|
2018-03-16 09:58:54 +00:00
|
|
|
}:
|
2016-06-03 13:55:03 +00:00
|
|
|
|
2020-06-05 10:57:18 +00:00
|
|
|
let
|
|
|
|
networkPkgs = if nftablesSupport then
|
|
|
|
[ iptables-nftables-compat ]
|
|
|
|
else
|
|
|
|
[ iptables ebtables ];
|
|
|
|
|
|
|
|
in
|
2016-06-03 13:55:03 +00:00
|
|
|
buildGoPackage rec {
|
2019-03-12 17:56:47 +00:00
|
|
|
pname = "lxd";
|
2020-09-18 04:20:00 +00:00
|
|
|
version = "4.6";
|
2016-06-03 13:55:03 +00:00
|
|
|
|
|
|
|
goPackagePath = "github.com/lxc/lxd";
|
|
|
|
|
2018-03-16 09:58:54 +00:00
|
|
|
src = fetchurl {
|
2019-03-12 17:56:47 +00:00
|
|
|
url = "https://github.com/lxc/lxd/releases/download/${pname}-${version}/${pname}-${version}.tar.gz";
|
2020-09-18 04:20:00 +00:00
|
|
|
sha256 = "011fsyafmpis6j0aq7vwd56m2mcb9v3rn4f246ms5nx6zgmga0ip";
|
2016-06-03 13:55:03 +00:00
|
|
|
};
|
|
|
|
|
2020-05-03 12:34:25 +00: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
|
2019-09-29 12:02:49 +00:00
|
|
|
rm _dist/src/github.com/lxc/lxd
|
|
|
|
cp -r _dist/src/* ../../..
|
2018-03-16 09:58:54 +00:00
|
|
|
popd
|
|
|
|
'';
|
2016-06-03 13:55:03 +00:00
|
|
|
|
2018-10-13 09:44:54 +00: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
|
2020-04-28 01:50:57 +00:00
|
|
|
rm $out/bin/{deps,macaroon-identity,generate}
|
2018-03-16 09:58:54 +00:00
|
|
|
|
2020-06-05 10:57:18 +00:00
|
|
|
wrapProgram $out/bin/lxd --prefix PATH : ${stdenv.lib.makeBinPath (
|
|
|
|
networkPkgs
|
|
|
|
++ [ acl rsync gnutar xz btrfs-progs gzip dnsmasq squashfsTools iproute bash criu ]
|
|
|
|
++ [ (writeShellScriptBin "apparmor_parser" ''
|
|
|
|
exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
|
|
|
|
'') ]
|
|
|
|
)
|
|
|
|
}
|
2019-07-09 16:53:01 +00:00
|
|
|
|
2020-04-26 03:16:56 +00:00
|
|
|
installShellCompletion --bash go/src/github.com/lxc/lxd/scripts/bash/lxd-client
|
2018-03-16 09:58:54 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-26 03:16:56 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles pkgconfig makeWrapper ];
|
2019-09-29 12:02:49 +00:00
|
|
|
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 13:55:03 +00:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Daemon based on liblxc offering a REST API to manage containers";
|
2020-04-02 09:20:00 +00:00
|
|
|
homepage = "https://linuxcontainers.org/lxd/";
|
2016-06-03 13:55:03 +00:00
|
|
|
license = licenses.asl20;
|
2019-09-29 12:02:49 +00:00
|
|
|
maintainers = with maintainers; [ fpletz wucke13 ];
|
2016-06-03 13:55:03 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|