Add a role for mounting the nix store over 9pfs.
This is useful for virtual machines since we can have a persistent /nix/store on the host machine.
This commit is contained in:
77
nix/configuration/roles/9pfs_nix_store/default.nix
Normal file
77
nix/configuration/roles/9pfs_nix_store/default.nix
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
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"
|
||||
];
|
||||
};
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
networking.dhcpcd.enable = false;
|
||||
networking.useDHCP = false;
|
||||
networking.dhcpcd.enable = lib.mkDefault false;
|
||||
networking.useDHCP = lib.mkDefault false;
|
||||
networking.nameservers = [
|
||||
"194.242.2.2#doh.mullvad.net"
|
||||
"2a07:e340::2#doh.mullvad.net"
|
||||
|
||||
@@ -24,7 +24,15 @@
|
||||
environment.systemPackages = with pkgs; [
|
||||
wabt
|
||||
wasm-bindgen-cli
|
||||
pkgs-unoptimized.binaryen # for wasm-opt
|
||||
binaryen # for wasm-opt
|
||||
];
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
inherit (pkgs-unoptimized)
|
||||
binaryen
|
||||
;
|
||||
})
|
||||
];
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user