python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / admin / lxd / default.nix
blobc15861ed69d4837b26ce3b8c7bb3c6f4c8b65783
1 { lib
2 , hwdata
3 , pkg-config
4 , lxc
5 , buildGoModule
6 , fetchurl
7 , makeWrapper
8 , acl
9 , rsync
10 , gnutar
11 , xz
12 , btrfs-progs
13 , gzip
14 , dnsmasq
15 , attr
16 , squashfsTools
17 , iproute2
18 , iptables
19 , libcap
20 , dqlite
21 , raft-canonical
22 , sqlite-replication
23 , udev
24 , writeShellScriptBin
25 , apparmor-profiles
26 , apparmor-parser
27 , criu
28 , bash
29 , installShellFiles
30 , nixosTests
33 buildGoModule rec {
34   pname = "lxd";
35   version = "5.7";
37   src = fetchurl {
38     urls = [
39       "https://linuxcontainers.org/downloads/lxd/lxd-${version}.tar.gz"
40       "https://github.com/lxc/lxd/releases/download/lxd-${version}/lxd-${version}.tar.gz"
41     ];
42     sha256 = "sha256-TZeF/VPrP4qRAVezJwQWtfypsxBJpnTrST0uDdw3WVI=";
43   };
45   vendorSha256 = null;
47   postPatch = ''
48     substituteInPlace shared/usbid/load.go \
49       --replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
50   '';
52   excludedPackages = [ "test" "lxd/db/generate" ];
54   nativeBuildInputs = [ installShellFiles pkg-config makeWrapper ];
55   buildInputs = [
56     lxc
57     acl
58     libcap
59     dqlite.dev
60     raft-canonical.dev
61     sqlite-replication
62     udev.dev
63   ];
65   ldflags = [ "-s" "-w" ];
66   tags = [ "libsqlite3" ];
68   preBuild = ''
69     # required for go-dqlite. See: https://github.com/lxc/lxd/pull/8939
70     export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
71   '';
73   preCheck =
74     let skippedTests = [
75       "TestValidateConfig"
76       "TestConvertNetworkConfig"
77       "TestConvertStorageConfig"
78       "TestSnapshotCommon"
79       "TestContainerTestSuite"
80     ]; in
81     ''
82       # Disable tests requiring local operations
83       buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
84     '';
86   postInstall = ''
87     wrapProgram $out/bin/lxd --prefix PATH : ${lib.makeBinPath (
88       [ iptables ]
89       ++ [ acl rsync gnutar xz btrfs-progs gzip dnsmasq squashfsTools iproute2 bash criu attr ]
90       ++ [ (writeShellScriptBin "apparmor_parser" ''
91              exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
92            '') ]
93       )
94     }
96     installShellCompletion --bash --name lxd ./scripts/bash/lxd-client
97   '';
99   passthru.tests.lxd = nixosTests.lxd;
100   passthru.tests.lxd-nftables = nixosTests.lxd-nftables;
102   meta = with lib; {
103     description = "Daemon based on liblxc offering a REST API to manage containers";
104     homepage = "https://linuxcontainers.org/lxd/";
105     changelog = "https://github.com/lxc/lxd/releases/tag/lxd-${version}";
106     license = licenses.asl20;
107     maintainers = with maintainers; [ marsam ];
108     platforms = platforms.linux;
109   };