Closed mkg20001 closed 1 year ago
Here's my quick-and-dirty patch that works
diff --git a/pkgs/tools/admin/lxd/default.nix b/pkgs/tools/admin/lxd/default.nix
index ba6f9d074b2..666d2a34dbe 100644
--- a/pkgs/tools/admin/lxd/default.nix
+++ b/pkgs/tools/admin/lxd/default.nix
@@ -7,8 +7,12 @@
, bash
, installShellFiles
, nftablesSupport ? false
+, useQemu ? true
+, OVMF, qemu_kvm, seabios, gptfdisk
}:
+# TODO: patch code so without useQemu it throws an error about useQemu=false
+
let
networkPkgs = if nftablesSupport then
[ iptables-nftables-compat ]
@@ -30,6 +34,12 @@ buildGoPackage rec {
postPatch = ''
substituteInPlace shared/usbid/load.go \
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
+ # Nuke from orbit.
+ find . -type f -exec sed -i \
+ -e s,/usr/share/OVMF,${OVMF.fd}/FV,g \
+ -e s,/usr/share/qemu,${qemu_kvm}/share/qemu,g \
+ -e s,/usr/share/seabios,${seabios},g \
+ {} +
'';
preBuild = ''
@@ -48,6 +58,7 @@ buildGoPackage rec {
wrapProgram $out/bin/lxd --prefix PATH : ${lib.makeBinPath (
networkPkgs
+ ++ (lib.optionals useQemu [ qemu_kvm gptfdisk ])
++ [ 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' "$@"
@@ -60,7 +71,7 @@ buildGoPackage rec {
nativeBuildInputs = [ installShellFiles pkg-config makeWrapper ];
buildInputs = [ lxc acl libcap libco-canonical.dev dqlite.dev
- raft-canonical.dev sqlite-replication udev.dev ];
+ raft-canonical.dev sqlite-replication udev.dev qemu_kvm ];
meta = with lib; {
description = "Daemon based on liblxc offering a REST API to manage containers";
@mkg20001 would you mind creating a PR with that patch?
I've noticed there's this PR which tries to achive the same thing https://github.com/NixOS/nixpkgs/pull/105651
Tbe other PR is missing some things, like the seabios path patch or gptfdisk in path.
Prob the best is to take the best of both and put it into one PR.
I marked this as stale due to inactivity. → More info
LXD has the ability to use env vars for many of the paths https://github.com/lxc/lxd/search?q=%2Fusr%2Fshare
func (d *qemu) ovmfPath() string {
if os.Getenv("LXD_OVMF_PATH") != "" {
return os.Getenv("LXD_OVMF_PATH")
}
return "/usr/share/OVMF"
}
Describe the bug Since lxd 4.0 lxd is able to run qemu virtual machines besides just containers https://discuss.linuxcontainers.org/t/running-virtual-machines-with-lxd-4-0/7519/1
There seem to be hardcoded locations to some /usr/share foloders that are missing, etc
Additionally not sure about qemu inclusion into lxd
A variant of lxd could be built with a flag "useQemu ? false" in the package and a configuration option to toggle it could be added
To Reproduce Steps to reproduce the behavior:
lxc init win10 --empty --vm -c security.secureboot=false -c limits.cpu=4 -c limits.memory=4GB
lxc start win10
Expected behavior It tries to boot
Screenshots
Additional context /usr/share hardcoded stuff
Notify maintainers
@fpletz @wucke13
Metadata
"x86_64-linux"
Linux 5.4.97, NixOS, 21.05pre-git (Okapi)
yes
yes
nix-env (Nix) 2.4pre20201205_a5d85d0
"nixos-21.03pre269343.758b29b5a28, nixpkgs, solaros"
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information: