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