{ config, lib, pkgs, ... }: { imports = [ ]; options.me = { _9pfs_nix_store.enable = lib.mkOption { type = lib.types.bool; default = false; example = true; description = "Whether we want to mount /nix/store over 9pfs (useful in virtual machines to share a directory from the host as a persistent nix store."; }; _9pfs_nix_store.is_iso = lib.mkOption { type = lib.types.bool; default = false; example = true; description = "Whether this build is for an ISO. It changes how we mount the nix store."; }; }; config = lib.mkIf config.me._9pfs_nix_store.enable ( lib.mkMerge [ (lib.mkIf config.me._9pfs_nix_store.is_iso { # fileSystems = { # "/nix/store" = lib.mkForce { # fsType = "overlay"; # device = "overlay"; # options = [ # "lowerdir=/nix/.ro-store" # "upperdir=/store" # "workdir=/work" # ]; # depends = [ # "/nix/.ro-store" # "/store" # "/work" # ]; # }; # "/store" = lib.mkForce { # fsType = "9p"; # device = "nixstore"; # options = [ # "trans=virtio" # "version=9p2000.L" # "x-systemd.requires=modprobe@9pnet_virtio.service" # "msize=16384" # Maximum packet size. Increasing this should improve performance at the cost of increased memory usage. # "cache=loose" # ]; # }; # }; }) (lib.mkIf (!config.me._9pfs_nix_store.is_iso) { fileSystems = { "/nix/store" = lib.mkForce { fsType = "9p"; device = "nixstore"; neededForBoot = true; options = [ "trans=virtio" "version=9p2000.L" "x-systemd.requires=modprobe@9pnet_virtio.service" "msize=16384" # Maximum packet size. Increasing this should improve performance at the cost of increased memory usage. "cache=loose" ]; }; }; }) ] ); }