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

73 lines
2.2 KiB
Nix
Raw Normal View History

{ stdenv, hwdata, pkgconfig, lxc, buildGoPackage, fetchurl
2018-06-28 20:59:07 +02:00
, makeWrapper, acl, rsync, gnutar, xz, btrfs-progs, gzip, dnsmasq
2020-06-05 12:57:18 +02:00
, squashfsTools, iproute, iptables, ebtables, iptables-nftables-compat, libcap
, libco-canonical, dqlite, raft-canonical, sqlite-replication, udev
, writeShellScriptBin, apparmor-profiles, apparmor-parser
2019-07-09 18:47:19 +02:00
, criu
, bash
2020-04-26 05:16:56 +02:00
, installShellFiles
2020-06-05 12:57:18 +02:00
, nftablesSupport ? false
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 {
pname = "lxd";
2020-12-12 01:00:00 +01:00
version = "4.9";
2016-06-03 15:55:03 +02:00
goPackagePath = "github.com/lxc/lxd";
2018-03-16 10:58:54 +01:00
src = fetchurl {
url = "https://github.com/lxc/lxd/releases/download/${pname}-${version}/${pname}-${version}.tar.gz";
2020-12-12 01:00:00 +01:00
sha256 = "0sq3avgsrdzkbsil0xsri60xxi0bzf4l6w43w23lbhacrby1spj4";
2016-06-03 15:55:03 +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
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
2018-10-13 11:44:54 +02:00
buildFlags = [ "-tags libsqlite3" ];
2018-03-16 10:58:54 +01:00
postInstall = ''
2019-02-08 07:54:38 +01:00
# test binaries, code generation
rm $out/bin/{deps,macaroon-identity,generate}
2018-03-16 10:58:54 +01:00
2020-06-05 12:57:18 +02:00
wrapProgram $out/bin/lxd --prefix PATH : ${stdenv.lib.makeBinPath (
networkPkgs
++ [ acl rsync gnutar xz btrfs-progs gzip dnsmasq squashfsTools iproute bash criu ]
++ [ (writeShellScriptBin "apparmor_parser" ''
exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
'') ]
)
}
2019-07-09 18:53:01 +02:00
2020-04-26 05:16:56 +02:00
installShellCompletion --bash go/src/github.com/lxc/lxd/scripts/bash/lxd-client
2018-03-16 10:58:54 +01:00
'';
2020-04-26 05:16:56 +02:00
nativeBuildInputs = [ installShellFiles pkgconfig makeWrapper ];
buildInputs = [ lxc acl libcap libco-canonical.dev dqlite.dev
2020-02-12 02:00:33 +01:00
raft-canonical.dev sqlite-replication udev.dev ];
2016-06-03 15:55:03 +02:00
meta = with stdenv.lib; {
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;
maintainers = with maintainers; [ fpletz wucke13 ];
2016-06-03 15:55:03 +02:00
platforms = platforms.linux;
};
}