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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

116 lines
2.6 KiB
Nix
Raw Normal View History

2022-09-30 02:14:19 +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
2022-09-30 02:14:19 +00:00
, udev
, writeShellScriptBin
, apparmor-profiles
, apparmor-parser
2019-07-09 16:47:19 +00:00
, criu
, bash
2020-04-26 03:16:56 +00:00
, installShellFiles
2020-12-06 08:59:59 +00:00
, nixosTests
2023-05-27 18:57:27 +00:00
, gitUpdater
2018-03-16 09:58:54 +00:00
}:
2016-06-03 13:55:03 +00:00
2022-09-30 02:14:19 +00:00
buildGoModule rec {
pname = "lxd";
2023-06-21 04:20:00 +00:00
version = "5.15";
2016-06-03 13:55:03 +00:00
2018-03-16 09:58:54 +00:00
src = fetchurl {
urls = [
"https://linuxcontainers.org/downloads/lxd/lxd-${version}.tar.gz"
"https://github.com/lxc/lxd/releases/download/lxd-${version}/lxd-${version}.tar.gz"
];
2023-06-21 04:20:00 +00:00
hash = "sha256-ez/875yu0XYu5ORf4ak6RN1jWGxuGk0n9023zJkoluM=";
2016-06-03 13:55:03 +00:00
};
vendorHash = null;
2022-09-30 02:14:19 +00:00
postPatch = ''
substituteInPlace shared/usbid/load.go \
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
'';
excludedPackages = [ "test" "lxd/db/generate" ];
2022-09-30 02:14:19 +00:00
nativeBuildInputs = [ installShellFiles pkg-config makeWrapper ];
buildInputs = [
lxc
acl
libcap
dqlite.dev
raft-canonical.dev
sqlite
2022-09-30 02:14:19 +00:00
udev.dev
];
ldflags = [ "-s" "-w" ];
tags = [ "libsqlite3" ];
2018-03-16 09:58:54 +00:00
preBuild = ''
2021-07-14 04:20:00 +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)"
'';
2018-10-13 09:44:54 +00:00
2022-09-30 02:14:19 +00:00
preCheck =
let skippedTests = [
"TestValidateConfig"
"TestConvertNetworkConfig"
"TestConvertStorageConfig"
"TestSnapshotCommon"
"TestContainerTestSuite"
]; in
''
# Disable tests requiring local operations
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
2018-03-16 09:58:54 +00:00
postInstall = ''
2021-01-15 09:19:50 +00:00
wrapProgram $out/bin/lxd --prefix PATH : ${lib.makeBinPath (
[ iptables ]
2021-09-04 23:29:55 +00:00
++ [ acl rsync gnutar xz btrfs-progs gzip dnsmasq squashfsTools iproute2 bash criu attr ]
2020-06-05 10:57:18 +00:00
++ [ (writeShellScriptBin "apparmor_parser" ''
exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
'') ]
)
}
2019-07-09 16:53:01 +00:00
2022-09-30 02:14:19 +00:00
installShellCompletion --bash --name lxd ./scripts/bash/lxd-client
2018-03-16 09:58:54 +00:00
'';
2020-12-06 08:59:59 +00:00
passthru.tests.lxd = nixosTests.lxd;
passthru.tests.lxd-nftables = nixosTests.lxd-nftables;
2023-05-27 18:57:27 +00:00
passthru.updateScript = gitUpdater {
url = "https://github.com/lxc/lxd.git";
rev-prefix = "lxd-";
};
2020-12-06 08:59:59 +00:00
meta = with lib; {
2016-06-03 13:55:03 +00:00
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/";
changelog = "https://github.com/lxc/lxd/releases/tag/lxd-${version}";
2016-06-03 13:55:03 +00:00
license = licenses.asl20;
2023-01-25 14:17:17 +00:00
maintainers = with maintainers; [ marsam adamcstephens ];
2016-06-03 13:55:03 +00:00
platforms = platforms.linux;
};
}