-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathnixos-shell.nix
73 lines (64 loc) · 2 KB
/
nixos-shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ lib, pkgs, modulesPath, config, options, extendModules, ... }:
{
imports = [
"${toString modulesPath}/virtualisation/qemu-vm.nix"
];
options.nixos-shell = with lib; {
mounts = let
cache = mkOption {
type = types.enum ["none" "loose" "fscache" "mmap"];
default = "loose"; # bad idea? Well, at least it is fast!1!!
description = "9p caching policy";
};
in {
mountHome = mkOption {
type = types.bool;
default = builtins.getEnv "HOME" != "";
description = "Whether to mount `$HOME`.";
};
mountNixProfile = mkOption {
type = types.bool;
# if our host os does not match the guest os, binaries in our nix profile will not work
default = options.virtualisation.host.pkgs.isDefined && config.virtualisation.host.pkgs.stdenv.hostPlatform != pkgs.stdenv.hostPlatform;
description = "Whether to mount the user's nix profile.";
};
inherit cache;
extraMounts = mkOption {
type = types.attrsOf (types.coercedTo
types.path (target: {
inherit target;
})
(types.submodule ({ config, ... }: {
options = {
target = mkOption {
type = types.path;
description = lib.mdDoc "Target on the guest.";
};
inherit cache;
tag = mkOption {
type = types.str;
internal = true;
};
};
config.tag = lib.mkDefault (
builtins.substring 0 31 ( # tags must be shorter than 32 bytes
"a" + # tags must not begin with a digit
builtins.hashString "md5" config._module.args.name
)
);
}))
);
default = {};
};
};
};
config = let
vmSystem = extendModules {
modules = [
./nixos-shell-config.nix
];
};
in {
system.build.nixos-shell = vmSystem.config.system.build.vm;
};
}