|
1 | | -# Xen Project Hypervisor (Dom0) support. |
2 | | - |
3 | 1 | { |
4 | 2 | config, |
5 | 3 | lib, |
|
8 | 6 | }: |
9 | 7 |
|
10 | 8 | let |
11 | | - inherit (builtins) readFile; |
12 | | - inherit (lib.meta) hiPrio; |
13 | | - inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule mkIf; |
14 | | - inherit (lib.options) |
15 | | - mkOption |
16 | | - mkEnableOption |
| 9 | + inherit (lib) |
| 10 | + boolToString |
| 11 | + getExe |
| 12 | + hasSuffix |
| 13 | + hiPrio |
17 | 14 | literalExpression |
| 15 | + mkEnableOption |
| 16 | + mkIf |
| 17 | + mkOption |
18 | 18 | mkPackageOption |
| 19 | + mkRemovedOptionModule |
| 20 | + mkRenamedOptionModule |
| 21 | + optional |
| 22 | + optionalAttrs |
| 23 | + optionalString |
| 24 | + optionals |
| 25 | + singleton |
| 26 | + teams |
| 27 | + types |
19 | 28 | ; |
20 | | - inherit (lib.types) |
21 | | - listOf |
22 | | - str |
23 | | - ints |
24 | | - lines |
25 | | - enum |
26 | | - path |
27 | | - submodule |
| 29 | + inherit (types) |
28 | 30 | addCheck |
29 | | - float |
30 | 31 | bool |
| 32 | + enum |
| 33 | + float |
31 | 34 | int |
| 35 | + ints |
| 36 | + lines |
| 37 | + listOf |
32 | 38 | nullOr |
| 39 | + path |
| 40 | + str |
| 41 | + submodule |
33 | 42 | ; |
34 | | - inherit (lib.lists) optional optionals; |
35 | | - inherit (lib.strings) hasSuffix optionalString; |
36 | | - inherit (lib.meta) getExe; |
37 | | - inherit (lib.attrsets) optionalAttrs; |
38 | | - inherit (lib.trivial) boolToString; |
39 | | - inherit (lib.teams.xen) members; |
40 | 43 |
|
41 | 44 | cfg = config.virtualisation.xen; |
42 | 45 |
|
|
59 | 62 | diffutils |
60 | 63 | ] |
61 | 64 | ); |
62 | | - runtimeEnv = { |
63 | | - efiMountPoint = config.boot.loader.efi.efiSysMountPoint; |
64 | | - }; |
| 65 | + runtimeEnv.efiMountPoint = config.boot.loader.efi.efiSysMountPoint; |
65 | 66 |
|
66 | 67 | # We disable SC2016 because we don't want to expand the regexes in the sed commands. |
67 | 68 | excludeShellChecks = [ "SC2016" ]; |
68 | 69 |
|
69 | | - text = readFile ./xen-boot-builder.sh; |
| 70 | + text = builtins.readFile ./xen-boot-builder.sh; |
70 | 71 | }; |
71 | 72 | in |
72 | 73 |
|
|
224 | 225 | boot = { |
225 | 226 | params = mkOption { |
226 | 227 | default = [ ]; |
227 | | - example = '' |
| 228 | + example = literalExpression '' |
228 | 229 | [ |
229 | 230 | "iommu=force:true,qinval:true,debug:true" |
230 | 231 | "noreboot=true" |
|
234 | 235 | type = listOf str; |
235 | 236 | description = '' |
236 | 237 | Xen Command Line parameters passed to Domain 0 at boot time. |
237 | | - Note: these are different from `boot.kernelParams`. See |
| 238 | +
|
| 239 | + ::: {.note} |
| 240 | + Note: these are different from {option}`boot.kernelParams`. See |
238 | 241 | the [Xen documentation](https://xenbits.xenproject.org/docs/unstable/misc/xen-command-line.html) for more information. |
| 242 | + ::: |
239 | 243 | ''; |
240 | 244 | }; |
241 | 245 | builderVerbosity = mkOption { |
|
267 | 271 | type = path; |
268 | 272 | default = "${cfg.package.boot}/${cfg.package.multiboot}"; |
269 | 273 | defaultText = literalExpression "\${config.virtualisation.xen.package.boot}/\${config.virtualisation.xen.package.multiboot}"; |
270 | | - example = literalExpression "\${config.virtualisation.xen.package}/boot/xen-\${config.virtualisation.xen.package.version}"; |
| 274 | + example = literalExpression "\${config.virtualisation.xen.package}/boot/xen-\${config.virtualisation.xen.package.upstreamVersion}"; |
271 | 275 | description = '' |
272 | 276 | Path to the Xen `multiboot` binary used for BIOS booting. |
273 | 277 | Unless you're building your own Xen derivation, you should leave this |
|
280 | 284 | type = path; |
281 | 285 | default = "${cfg.package.boot}/${cfg.package.efi}"; |
282 | 286 | defaultText = literalExpression "\${config.virtualisation.xen.package.boot}/\${config.virtualisation.xen.package.efi}"; |
283 | | - example = literalExpression "\${config.virtualisation.xen.package}/boot/efi/efi/nixos/xen-\${config.virtualisation.xen.package.version}.efi"; |
| 287 | + example = literalExpression "\${config.virtualisation.xen.package}/boot/efi/efi/nixos/xen-\${config.virtualisation.xen.package.upstreamVersion}.efi"; |
284 | 288 | description = '' |
285 | 289 | Path to xen.efi. `pkgs.xen` is patched to install the xen.efi file |
286 | 290 | on `$boot/boot/xen.efi`, but an unpatched Xen build may install it |
|
333 | 337 | extraConfig = mkOption { |
334 | 338 | type = lines; |
335 | 339 | default = ""; |
336 | | - example = '' |
| 340 | + example = literalExpression '' |
337 | 341 | XENDOMAINS_SAVE=/persist/xen/save |
338 | 342 | XENDOMAINS_RESTORE=false |
339 | 343 | XENDOMAINS_CREATE_USLEEP=10000000 |
|
674 | 678 | } |
675 | 679 | { |
676 | 680 | assertion = config.boot.initrd.systemd.enable; |
677 | | - message = "Xen does not support the legacy script-based Stage 1 initrd."; |
| 681 | + message = '' |
| 682 | + Xen does not support the legacy script-based stage 1 initial ramdisk. |
| 683 | + Please set 'boot.initrd.systemd.enable' to 'true'. |
| 684 | + ''; |
678 | 685 | } |
679 | 686 | { |
680 | 687 | assertion = cfg.dom0Resources.maxMemory >= cfg.dom0Resources.memory; |
681 | 688 | message = '' |
682 | | - You have allocated more memory to dom0 than virtualisation.xen.dom0Resources.maxMemory |
| 689 | + You have allocated more memory to dom0 than 'virtualisation.xen.dom0Resources.maxMemory' |
683 | 690 | allows for. Please increase the maximum memory limit, or decrease the default memory allocation. |
684 | 691 | ''; |
685 | 692 | } |
|
690 | 697 | { |
691 | 698 | assertion = cfg.store.settings.quota.maxWatchEvents >= cfg.store.settings.quota.maxOutstanding; |
692 | 699 | message = '' |
693 | | - Upstream Xen recommends that maxWatchEvents be equal to or greater than maxOutstanding, |
| 700 | + Upstream Xen recommends that 'virtualisation.xen.store.settings.quota.maxWatchEvents' |
| 701 | + be equal to or greater than 'virtualisation.xen.store.settings.quota.maxOutstanding', |
694 | 702 | in order to mitigate denial of service attacks from malicious frontends. |
695 | 703 | ''; |
696 | 704 | } |
697 | 705 | ]; |
698 | 706 |
|
| 707 | + warnings = lib.optional ((config.boot ? lanzaboote) && config.boot.lanzaboote.enable) '' |
| 708 | + Xen support has not yet been merged into Lanzaboote. |
| 709 | + Ensure that your Lanzaboote configuration includes PR #387: |
| 710 | + https://github.com/nix-community/lanzaboote/pull/387 |
| 711 | + ''; |
| 712 | + |
699 | 713 | virtualisation.xen.boot.params = |
700 | 714 | optionals cfg.trace [ |
701 | 715 | "loglvl=all" |
|
752 | 766 | }; |
753 | 767 |
|
754 | 768 | # See the `xenBootBuilder` script in the main `let...in` statement of this file. |
755 | | - loader.systemd-boot.extraInstallCommands = '' |
756 | | - ${getExe xenBootBuilder} ${cfg.boot.builderVerbosity} |
757 | | - ''; |
| 769 | + loader.systemd-boot.extraInstallCommands = "${getExe xenBootBuilder} ${cfg.boot.builderVerbosity}"; |
758 | 770 | }; |
759 | 771 |
|
760 | 772 | # Domain 0 requires a pvops-enabled kernel. |
|
854 | 866 | # Xen provides systemd units. |
855 | 867 | packages = [ cfg.package ]; |
856 | 868 |
|
857 | | - mounts = [ |
858 | | - { |
859 | | - description = "Mount /proc/xen files"; |
860 | | - what = "xenfs"; |
861 | | - where = "/proc/xen"; |
862 | | - type = "xenfs"; |
863 | | - unitConfig = { |
864 | | - ConditionPathExists = "/proc/xen"; |
865 | | - RefuseManualStop = "true"; |
866 | | - }; |
867 | | - } |
868 | | - ]; |
| 869 | + mounts = singleton { |
| 870 | + description = "Mount /proc/xen files"; |
| 871 | + what = "xenfs"; |
| 872 | + where = "/proc/xen"; |
| 873 | + type = "xenfs"; |
| 874 | + unitConfig = { |
| 875 | + ConditionPathExists = "/proc/xen"; |
| 876 | + RefuseManualStop = "true"; |
| 877 | + }; |
| 878 | + }; |
869 | 879 |
|
870 | 880 | services = { |
871 | | - |
872 | 881 | # While this service is installed by the `xen` package, it shouldn't be used in dom0. |
873 | 882 | xendriverdomain.enable = false; |
874 | 883 |
|
|
926 | 935 | }; |
927 | 936 | }; |
928 | 937 | }; |
929 | | - meta.maintainers = members; |
| 938 | + meta.maintainers = teams.xen.members; |
930 | 939 | } |
0 commit comments