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

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

134 lines
3 KiB
Nix
Raw Normal View History

2023-06-30 04:53:51 +02:00
{ lib
, lxd-unwrapped
, linkFarm
2023-06-30 04:53:51 +02:00
, makeWrapper
, stdenv
2023-06-30 04:53:51 +02:00
, symlinkJoin
, writeShellScriptBin
, acl
, apparmor-parser
, apparmor-profiles
, attr
, bash
, btrfs-progs
2023-09-04 19:02:48 +02:00
, cdrkit
2023-06-30 04:53:51 +02:00
, criu
, dnsmasq
2023-09-04 19:02:48 +02:00
, e2fsprogs
, getent
2023-06-30 04:53:51 +02:00
, gnutar
, gptfdisk
2023-06-30 04:53:51 +02:00
, gzip
, iproute2
, iptables
2023-09-04 19:02:48 +02:00
, kmod
, lvm2
, minio
, nftables
, OVMF
, qemu_kvm
, qemu-utils
2023-06-30 04:53:51 +02:00
, rsync
, spice-gtk
2023-06-30 04:53:51 +02:00
, squashfsTools
2023-09-04 19:02:48 +02:00
, thin-provisioning-tools
, util-linux
, virtiofsd
2023-06-30 04:53:51 +02:00
, xz
}:
let
binPath = lib.makeBinPath [
acl
attr
bash
btrfs-progs
2023-09-04 19:02:48 +02:00
cdrkit
2023-06-30 04:53:51 +02:00
criu
dnsmasq
2023-09-04 19:02:48 +02:00
e2fsprogs
getent
2023-06-30 04:53:51 +02:00
gnutar
gptfdisk
2023-06-30 04:53:51 +02:00
gzip
iproute2
iptables
2023-09-04 19:02:48 +02:00
kmod
lvm2
minio
nftables
qemu_kvm
qemu-utils
2023-06-30 04:53:51 +02:00
rsync
squashfsTools
2023-09-04 19:02:48 +02:00
thin-provisioning-tools
util-linux
virtiofsd
2023-06-30 04:53:51 +02:00
xz
(writeShellScriptBin "apparmor_parser" ''
exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@"
'')
];
clientBinPath = [
spice-gtk
];
ovmf-2mb = OVMF.override {
secureBoot = true;
csmSupport = false;
fdSize2MB = true;
};
ovmf-4mb = OVMF.override {
secureBoot = true;
csmSupport = false;
fdSize4MB = true;
};
ovmf-4mb-csm = OVMF.override {
secureBoot = true;
csmSupport = false;
fdSize2MB = false;
fdSize4MB = true;
};
ovmf-prefix = if stdenv.hostPlatform.isAarch64 then "AAVMF" else "OVMF";
# mimic ovmf from https://github.com/canonical/lxd-pkg-snap/blob/3abebe1dfeb20f9b7729556960c7e9fe6ad5e17c/snapcraft.yaml#L378
# also found in /snap/lxd/current/share/qemu/ on a snap install
ovmf = linkFarm "lxd-ovmf" [
{ name = "OVMF_CODE.2MB.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_CODE.fd"; }
{ name = "OVMF_CODE.4MB.CSM.fd"; path = "${ovmf-4mb-csm.fd}/FV/${ovmf-prefix}_CODE.fd"; }
{ name = "OVMF_CODE.4MB.fd"; path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_CODE.fd"; }
{ name = "OVMF_CODE.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_CODE.fd"; }
{ name = "OVMF_VARS.2MB.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
{ name = "OVMF_VARS.2MB.ms.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
{ name = "OVMF_VARS.4MB.CSM.fd"; path = "${ovmf-4mb-csm.fd}/FV/${ovmf-prefix}_VARS.fd"; }
{ name = "OVMF_VARS.4MB.fd"; path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
{ name = "OVMF_VARS.4MB.ms.fd"; path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
{ name = "OVMF_VARS.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
{ name = "OVMF_VARS.ms.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
];
2023-06-30 04:53:51 +02:00
in
symlinkJoin {
name = "lxd-${lxd-unwrapped.version}";
paths = [ lxd-unwrapped ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/lxd --prefix PATH : ${lib.escapeShellArg binPath}:${qemu_kvm}/libexec:$out/bin --set LXD_OVMF_PATH ${ovmf}
wrapProgram $out/bin/lxc --prefix PATH : ${lib.makeBinPath clientBinPath}
2023-06-30 04:53:51 +02:00
'';
passthru = {
inherit (lxd-unwrapped) tests ui;
2023-06-30 04:53:51 +02:00
};
inherit (lxd-unwrapped) meta pname version;
}