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

Adds support xen domU lightweight containers #33922

Closed

Conversation

angerman
Copy link
Contributor

When runnign nixOS in a xen setup without it's own
kernel (the kernel and initrd are provided by the host)
we need to use init-scripts (/sbin/init) instead of grub
and have no kernel.

Motivation for this change

This adds support to run nixOS on DomainFactorys
(df.eu) JiffyBoxs with the "PV-Kernel". It should also
allow to run nixOS on similar setups xen guest setups
where the host provides the kernel.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

When runnign nixOS in a xen setup without it's own
kernel (the kernel and initrd are provided by the host)
we need to use init-scripts (/sbin/init) instead of grub
and have no kernel.

This adds support to run nixOS on DomainFactorys
(df.eu) JiffyBoxs with the "PV-Kernel".
@Mic92
Copy link
Member

Mic92 commented Jan 16, 2018

btw. we also have a section in our wiki on how to install nixos on different providers: https://nixos.wiki/wiki/NixOS_friendly_hosters

# When being booted in as a xen domU
# with a provided kernel and initrd,
# we need the /sbin/init script.
default = config.boot.usePvKernel;
Copy link
Member

Choose a reason for hiding this comment

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

Every user with PV Kernel would now have to regenerate the manual when you override the default option.
I would rather override this in a module or profile using mkOverride.
We also have nixos/modules/virtualisation/xen-domU.nix file, how is this related to your property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this here because the same was done for grub and isContainer in
https://github.com/angerman/nixpkgs/blob/608eaeaeab10593a3f661e9e1012286febbaeb45/nixos/modules/system/boot/loader/grub/grub.nix#L92-L98

The xen-domU.nix sets up a xen guest, but expects it to have a boot loader. The situation I am in is in between what xen-domU offers and what the isContainer flags does. However the isContainer flag expects to be a container on a nixOS host.

Copy link
Member

Choose a reason for hiding this comment

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

isContainer probably was also not the best design decision, because it clutters every module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ll need some guidance here. How do I set initScripts.enabled to true if usePvKernel is set to true? Unless the user configured usePvKernel = true; initScripts.enabled = false;

usePvKernel basically implies that initScripts are used as the kernels initrd will very likely expect to find /sbin/init as the standard common entry point for the guest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The key being that nixOS has no control over the kernel or initrd; and the host has no idea about the system and as such treats it as a generic linux.

Copy link
Member

Choose a reason for hiding this comment

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

I opened that issue here to discuss the problem: #33940

Copy link
Member

@Mic92 Mic92 Jan 16, 2018

Choose a reason for hiding this comment

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

We would need for each module where isContainer is set a local option to disable this aspect and then set the same option in your pv-kernel module or in a generic container profile. In the linked issue, where I propose a kernel-less module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems to open up another whole can worms. This feels a bit outside of this PR.

@angerman
Copy link
Contributor Author

angerman commented Jan 16, 2018

btw. we also have a section in our wiki on how to install nixos on different providers: https://nixos.wiki/wiki/NixOS_friendly_hosters

Right. domainfactory is not listed. And I'm not sure I would advise to use domainfactory with nixOS right now. With the missing PV Kernel support, and their only active Xen and PV kernel offerings for their JiffyBox's it's more of a challenge to get NixOS working.

I just happen to have a JiffyBox already, otherwise I would likely have chosen digital ocean or similar.

That is not to say, that the PV Kernel support make exclusive sense for domainfactory only. It's basically what any hoster running xen without a bootloader would require.

@angerman
Copy link
Contributor Author

What's the status of this? As we are tracking the "optimization" in #33940, can we in the meantime accept and merge this?

@Mic92
Copy link
Member

Mic92 commented Jan 19, 2018

#33940 (comment) looks easy to implement to me.
If I accept this change now it will just increase technical dept and nobody will attempt to fix it.

@angerman
Copy link
Contributor Author

I've sine stopped using that host.

@angerman angerman closed this Jul 27, 2018
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