2021-12-06 16:07:01 +00:00
|
|
|
{ lib, hwdata, pkg-config, lxc, buildGoPackage, fetchurl, fetchpatch
|
2021-09-18 10:52:07 +00:00
|
|
|
, makeWrapper, acl, rsync, gnutar, xz, btrfs-progs, gzip, dnsmasq, attr
|
2021-12-06 16:07:01 +00:00
|
|
|
, squashfsTools, iproute2, iptables, libcap
|
2021-05-28 09:39:13 +00:00
|
|
|
, dqlite, raft-canonical, sqlite-replication, udev
|
2020-04-24 23:36:52 +00:00
|
|
|
, writeShellScriptBin, apparmor-profiles, apparmor-parser
|
|
|
|
, criu
|
|
|
|
, bash
|
2020-05-03 17:38:23 +00:00
|
|
|
, installShellFiles
|
2021-06-06 07:54:09 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoPackage rec {
|
|
|
|
pname = "lxd";
|
2022-01-22 01:22:15 +00:00
|
|
|
version = "4.22";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
goPackagePath = "github.com/lxc/lxd";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-05-20 23:08:51 +00:00
|
|
|
url = "https://linuxcontainers.org/downloads/lxd/lxd-${version}.tar.gz";
|
2022-01-22 01:22:15 +00:00
|
|
|
sha256 = "119345936fcm1vv06k82k9hvj5yjf9jdrwqm9ccphhl5mswf8xq9";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace shared/usbid/load.go \
|
|
|
|
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preBuild = ''
|
2021-07-16 19:40:57 +00:00
|
|
|
# required for go-dqlite. See: https://github.com/lxc/lxd/pull/8939
|
|
|
|
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
makeFlagsArray+=("-tags libsqlite3")
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# test binaries, code generation
|
2020-05-15 21:57:56 +00:00
|
|
|
rm $out/bin/{deps,macaroon-identity,generate}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
wrapProgram $out/bin/lxd --prefix PATH : ${lib.makeBinPath (
|
2021-12-06 16:07:01 +00:00
|
|
|
[ iptables ]
|
2021-09-18 10:52:07 +00:00
|
|
|
++ [ acl rsync gnutar xz btrfs-progs gzip dnsmasq squashfsTools iproute2 bash criu attr ]
|
2020-06-18 07:06:33 +00:00
|
|
|
++ [ (writeShellScriptBin "apparmor_parser" ''
|
|
|
|
exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
|
|
|
|
'') ]
|
|
|
|
)
|
|
|
|
}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
installShellCompletion --bash --name lxd go/src/github.com/lxc/lxd/scripts/bash/lxd-client
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
passthru.tests.lxd = nixosTests.lxd;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles pkg-config makeWrapper ];
|
2021-05-28 09:39:13 +00:00
|
|
|
buildInputs = [ lxc acl libcap dqlite.dev raft-canonical.dev
|
|
|
|
sqlite-replication udev.dev ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Daemon based on liblxc offering a REST API to manage containers";
|
|
|
|
homepage = "https://linuxcontainers.org/lxd/";
|
|
|
|
license = licenses.asl20;
|
2021-08-08 23:34:03 +00:00
|
|
|
maintainers = with maintainers; [ fpletz wucke13 marsam ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|