2022-09-30 11:47:45 +00:00
|
|
|
{ lib
|
|
|
|
, hwdata
|
|
|
|
, pkg-config
|
|
|
|
, lxc
|
|
|
|
, buildGoModule
|
|
|
|
, fetchurl
|
|
|
|
, makeWrapper
|
|
|
|
, acl
|
|
|
|
, rsync
|
|
|
|
, gnutar
|
|
|
|
, xz
|
|
|
|
, btrfs-progs
|
|
|
|
, gzip
|
|
|
|
, dnsmasq
|
|
|
|
, attr
|
|
|
|
, squashfsTools
|
|
|
|
, iproute2
|
|
|
|
, iptables
|
|
|
|
, libcap
|
|
|
|
, dqlite
|
|
|
|
, raft-canonical
|
|
|
|
, sqlite-replication
|
|
|
|
, udev
|
|
|
|
, writeShellScriptBin
|
|
|
|
, apparmor-profiles
|
|
|
|
, apparmor-parser
|
2020-04-24 23:36:52 +00:00
|
|
|
, 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
|
|
|
}:
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
buildGoModule rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "lxd";
|
2022-09-30 11:47:45 +00:00
|
|
|
version = "5.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2022-06-16 17:23:12 +00:00
|
|
|
urls = [
|
|
|
|
"https://linuxcontainers.org/downloads/lxd/lxd-${version}.tar.gz"
|
|
|
|
"https://github.com/lxc/lxd/releases/download/lxd-${version}/lxd-${version}.tar.gz"
|
|
|
|
];
|
2022-09-30 11:47:45 +00:00
|
|
|
sha256 = "sha256-bLKl9OpvxXozmqjX8hY2xIiVectBiohDxTzd5du5w+4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
vendorSha256 = null;
|
|
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
excludedPackages = [ "test" "lxd/db/generate" ];
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles pkg-config makeWrapper ];
|
|
|
|
buildInputs = [
|
|
|
|
lxc
|
|
|
|
acl
|
|
|
|
libcap
|
|
|
|
dqlite.dev
|
|
|
|
raft-canonical.dev
|
|
|
|
sqlite-replication
|
|
|
|
udev.dev
|
|
|
|
];
|
|
|
|
|
|
|
|
ldflags = [ "-s" "-w" ];
|
|
|
|
tags = [ "libsqlite3" ];
|
|
|
|
|
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
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
preCheck =
|
|
|
|
let skippedTests = [
|
|
|
|
"TestValidateConfig"
|
|
|
|
"TestConvertNetworkConfig"
|
|
|
|
"TestConvertStorageConfig"
|
|
|
|
"TestSnapshotCommon"
|
|
|
|
"TestContainerTestSuite"
|
|
|
|
]; in
|
|
|
|
''
|
|
|
|
# Disable tests requiring local operations
|
|
|
|
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
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
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
installShellCompletion --bash --name 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;
|
2022-05-18 14:49:53 +00:00
|
|
|
passthru.tests.lxd-nftables = nixosTests.lxd-nftables;
|
2021-06-06 07:54:09 +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/";
|
2022-06-26 10:26:21 +00:00
|
|
|
changelog = "https://github.com/lxc/lxd/releases/tag/lxd-${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
2022-08-12 12:06:08 +00:00
|
|
|
maintainers = with maintainers; [ marsam ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|