Merge pull request #227881 from NixOS/qemu-vm/mount-host-nix-store

nixos/qemu-vm: introduce `virtualisation.mountHostNixStore` option

authored by

Ryan Lahfa and committed by
GitHub
7812abd3 0afeb09b

+20 -2
+20 -2
nixos/modules/virtualisation/qemu-vm.nix
··· 574 virtualisation.writableStore = 575 mkOption { 576 type = types.bool; 577 - default = true; # FIXME 578 description = 579 lib.mdDoc '' 580 If enabled, the Nix store in the VM is made writable by 581 layering an overlay filesystem on top of the host's Nix 582 store. 583 ''; 584 }; 585 ··· 713 For applications which do a lot of reads from the store, 714 this can drastically improve performance, but at the cost of 715 disk space and image build time. 716 ''; 717 }; 718 ··· 933 virtualisation.additionalPaths = [ config.system.build.toplevel ]; 934 935 virtualisation.sharedDirectories = { 936 - nix-store = mkIf (!cfg.useNixStoreImage) { 937 source = builtins.storeDir; 938 target = "/nix/store"; 939 };
··· 574 virtualisation.writableStore = 575 mkOption { 576 type = types.bool; 577 + default = cfg.mountHostNixStore; 578 + defaultText = literalExpression "cfg.mountHostNixStore"; 579 description = 580 lib.mdDoc '' 581 If enabled, the Nix store in the VM is made writable by 582 layering an overlay filesystem on top of the host's Nix 583 store. 584 + 585 + By default, this is enabled if you mount a host Nix store. 586 ''; 587 }; 588 ··· 716 For applications which do a lot of reads from the store, 717 this can drastically improve performance, but at the cost of 718 disk space and image build time. 719 + 720 + As an alternative, you can use a bootloader which will provide you 721 + with a full NixOS system image containing a Nix store and 722 + avoid mounting the host nix store through 723 + {option}`virtualisation.mountHostNixStore`. 724 + ''; 725 + }; 726 + 727 + virtualisation.mountHostNixStore = 728 + mkOption { 729 + type = types.bool; 730 + default = !cfg.useNixStoreImage && !cfg.useBootLoader; 731 + defaultText = literalExpression "!cfg.useNixStoreImage && !cfg.useBootLoader"; 732 + description = lib.mdDoc '' 733 + Mount the host Nix store as a 9p mount. 734 ''; 735 }; 736 ··· 951 virtualisation.additionalPaths = [ config.system.build.toplevel ]; 952 953 virtualisation.sharedDirectories = { 954 + nix-store = mkIf cfg.mountHostNixStore { 955 source = builtins.storeDir; 956 target = "/nix/store"; 957 };