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 574 virtualisation.writableStore = 575 575 mkOption { 576 576 type = types.bool; 577 - default = true; # FIXME 577 + default = cfg.mountHostNixStore; 578 + defaultText = literalExpression "cfg.mountHostNixStore"; 578 579 description = 579 580 lib.mdDoc '' 580 581 If enabled, the Nix store in the VM is made writable by 581 582 layering an overlay filesystem on top of the host's Nix 582 583 store. 584 + 585 + By default, this is enabled if you mount a host Nix store. 583 586 ''; 584 587 }; 585 588 ··· 713 716 For applications which do a lot of reads from the store, 714 717 this can drastically improve performance, but at the cost of 715 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. 716 734 ''; 717 735 }; 718 736 ··· 933 951 virtualisation.additionalPaths = [ config.system.build.toplevel ]; 934 952 935 953 virtualisation.sharedDirectories = { 936 - nix-store = mkIf (!cfg.useNixStoreImage) { 954 + nix-store = mkIf cfg.mountHostNixStore { 937 955 source = builtins.storeDir; 938 956 target = "/nix/store"; 939 957 };