Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxd: Add VMs support #105651

Closed
wants to merge 1 commit into from
Closed

lxd: Add VMs support #105651

wants to merge 1 commit into from

Conversation

CajuM
Copy link

@CajuM CajuM commented Dec 2, 2020

Motivation for this change

LXD has support for virtual machines, but this support isn't present in nixpkgs.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@CajuM
Copy link
Author

CajuM commented Dec 2, 2020

I did not update the tests because I can't upload a VM image to tarballs.nixos.org

Comment on lines 17 to 27
[ iptables ebtables ];
lxd-agent = buildGoPackage rec {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[ iptables ebtables ];
lxd-agent = buildGoPackage rec {
[ iptables ebtables ];
lxd-agent = buildGoPackage rec {


goPackagePath = "github.com/lxc/lxd";

buildFlags = [ "-ldflags=-extldflags=-static" "-tags libsqlite3" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it hurt to add -s -w?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had trouble figuring out quotation. We could do this. Not sure if there's any better solution.

-    buildFlags = [ "-ldflags=-extldflags=-static" "-tags libsqlite3" ];
+    buildFlags = [ "-ldflags=-extldflags=-static" "-ldflags=-s" "-ldflags=-w" "-tags libsqlite3" ];

buildFlags = [ "-ldflags=-extldflags=-static" "-tags libsqlite3" ];

src = fetchurl {
url = "https://github.com/lxc/lxd/releases/download/lxd-${version}/lxd-${version}.tar.gz";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: Whats the difference with those compared to the github tarball?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't use ${pname}, because it's lxd-agent in this context. Should I put src in a let? Anyhow nix caches blobs by their hash, so it won't get downloaded twice.

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason why you did not put this into a separate package?

@CajuM
Copy link
Author

CajuM commented Dec 2, 2020

I did not think it necessary to have an independent lxd-agent available for installation. lxd takes care of mounting it on the guest. It also may not be wise to have a different version of lxd than lxd-agent.

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 105651 run on x86_64-linux 1

1 package built:
  • lxd

@CajuM
Copy link
Author

CajuM commented Dec 11, 2020

Result of nixpkgs-review pr 105651 run on x86_64-linux 1
1 package built:

Should I add lxd-agent to buildInputs? It seems to get built anyway and placed in the lxd package.
Besides this, is there anything else pending?

@CajuM
Copy link
Author

CajuM commented Apr 19, 2021

Hello, sorry for the long delay.
In #114194 gptfdisk and SeaBIOS are added as dependencies. But, they don't seem to be used in LXD. LXD 4.13 does not support any other BIOS than OVMF, as far as I can tell.
I solved the merge conflict. Should I also add a useQemu flag?


goPackagePath = "github.com/lxc/lxd";

buildFlags = [ "-ldflags=-extldflags=-static" "-ldflags=-s" "-ldflags=-w" "-tags libsqlite3" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buildFlags = [ "-ldflags=-extldflags=-static" "-ldflags=-s" "-ldflags=-w" "-tags libsqlite3" ];
buildFlags = [ "-ldflags=-extldflags=-static" "-ldflags=-s -w" "-tags libsqlite3" ];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives me a build error

@SuperSandro2000
Copy link
Member

Should I also add a useQemu flag?

I think that is a good idea because qemu is quite big.

@CajuM
Copy link
Author

CajuM commented Apr 20, 2021

Should I also add a useQemu flag?

I think that is a good idea because qemu is quite big.

In that case we'll also need an extra config flag in the virtualisation.lxd module.
Also... lxd would have to be built twice by Hydra to provide both configurations.

@SuperSandro2000
Copy link
Member

In that case we'll also need an extra config flag in the virtualisation.lxd module.

Can we change the package there already?

@CajuM
Copy link
Author

CajuM commented Apr 21, 2021

In that case we'll also need an extra config flag in the virtualisation.lxd module.

Can we change the package there already?

Yes, we can. My bad.

* Moved the code for lxd-agent into a separate file
* lxd-agent is now staically linked, as required for
  being copied into vms
* Moved the code for lxd into a separate file represeting
  the unwraped exeuctable. So that we don't have to build
  lxd more than once for various configurations
* The lxd package is now a wrapper around lxd, lxd-agent
  and various dependencies
@stale
Copy link

stale bot commented Oct 22, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 22, 2021
@ifd3f
Copy link
Contributor

ifd3f commented Mar 22, 2022

What's the status on this? I know it's marked as stale, but I'd be happy to see this feature merged. If needed, I'd be interested in contributing as well.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 22, 2022
@ifd3f
Copy link
Contributor

ifd3f commented Apr 1, 2022

I'll try building off of this and submit a different PR.

@ifd3f ifd3f mentioned this pull request Apr 1, 2022
14 tasks
@CajuM CajuM closed this Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants