aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mk-sandbox-system.nix86
1 files changed, 40 insertions, 46 deletions
diff --git a/lib/mk-sandbox-system.nix b/lib/mk-sandbox-system.nix
index 7514b93..5574736 100644
--- a/lib/mk-sandbox-system.nix
+++ b/lib/mk-sandbox-system.nix
@@ -7,8 +7,6 @@
7, patchQemu9p ? false 7, patchQemu9p ? false
8}: 8}:
9 9
10with nixpkgs.lib;
11
12let 10let
13 pkgs = import nixpkgs { inherit system; }; 11 pkgs = import nixpkgs { inherit system; };
14 12
@@ -26,62 +24,58 @@ let
26 24
27in rec { 25in rec {
28 26
29 nixosConfigurations.${name} = nixosSystem { 27 nixosConfigurations.${name} = pkgs.nixos
30 inherit system; 28 ({ modulesPath, lib, pkgs, ... }: with lib; {
31 29 imports = [
32 modules = [ 30 (modulesPath + "/profiles/minimal.nix")
33 (nixpkgs + "/nixos/modules/profiles/minimal.nix")
34 { environment.noXlibs = false; } # avoid mass rebuild 31 { environment.noXlibs = false; } # avoid mass rebuild
35 32
36 (nixpkgs + "/nixos/modules/profiles/qemu-guest.nix") 33 (modulesPath + "/profiles/qemu-guest.nix")
37 (nixpkgs + "/nixos/modules/virtualisation/qemu-vm.nix") 34 (modulesPath + "/virtualisation/qemu-vm.nix")
38
39 ({ config, lib, pkgs, ... }: {
40 35
41 system.stateVersion = mkDefault pkgs.lib.trivial.release; 36 config
37 ];
42 38
43 networking = { 39 system.stateVersion = mkDefault trivial.release;
44 hostName = name;
45 firewall.enable = mkDefault false;
46 };
47 40
48 users.users.${user} = { 41 networking = {
49 isNormalUser = mkDefault true; 42 hostName = name;
50 password = mkDefault ""; 43 firewall.enable = mkDefault false;
51 extraGroups = mkDefault [ "wheel" ]; 44 };
52 };
53 45
54 security.sudo.wheelNeedsPassword = mkDefault false; 46 users.users.${user} = {
47 isNormalUser = mkDefault true;
48 password = mkDefault "";
49 extraGroups = mkDefault [ "wheel" ];
50 };
55 51
56 services.getty = { 52 security.sudo.wheelNeedsPassword = mkDefault false;
57 autologinUser = mkDefault user;
58 helpLine = mkDefault ''
59 Press <CTRL-a> <x> to terminate the virtual machine.
60 The working directory on the host is mounted to /mnt.
61 '';
62 };
63 53
64 virtualisation = { 54 services.getty = {
65 graphics = mkDefault false; 55 autologinUser = mkDefault user;
66 diskImage = mkDefault "$(mktemp).qcow2"; 56 helpLine = mkDefault ''
57 Press <CTRL-a> <x> to terminate the virtual machine.
58 The working directory on the host is mounted to /mnt.
59 '';
60 };
67 61
68 sharedDirectories.host = { 62 virtualisation = {
69 source = "$SHARED_CWD"; 63 graphics = mkDefault false;
70 target = "/mnt"; 64 diskImage = mkDefault "$(mktemp).qcow2";
71 };
72 65
73 # Uncomment when this is merged: 66 sharedDirectories.host = {
74 # https://github.com/NixOS/nixpkgs/pull/200225 67 source = "$SHARED_CWD";
75 #restrictNetwork = mkDefault true; 68 target = "/mnt";
69 };
76 70
77 qemu.package = mkDefault 71 # Uncomment when this is merged:
78 (if patchQemu9p then qemu_kvm_patched_9p else pkgs.qemu_kvm); 72 # https://github.com/NixOS/nixpkgs/pull/200225
79 }; 73 #restrictNetwork = mkDefault true;
80 })
81 74
82 config 75 qemu.package = mkDefault
83 ]; 76 (if patchQemu9p then qemu_kvm_patched_9p else pkgs.qemu_kvm);
84 }; 77 };
78 });
85 79
86 packages.${name} = nixosConfigurations.${name}.config.system.build.vm; 80 packages.${name} = nixosConfigurations.${name}.config.system.build.vm;
87 81