From 94b4db41750a7b6846ba57f643cb05d8bf94e1cb Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 14 Nov 2022 00:40:17 +0100 Subject: mkSandboxSystem: add tools and envVars option with printing --- lib/mk-sandbox-system.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib/mk-sandbox-system.nix') diff --git a/lib/mk-sandbox-system.nix b/lib/mk-sandbox-system.nix index a56bdab..b678399 100644 --- a/lib/mk-sandbox-system.nix +++ b/lib/mk-sandbox-system.nix @@ -3,11 +3,16 @@ flake: , name ? "sandbox" , user ? "dummy" , config ? { } +, tools ? [] +, envVars ? { } , restrictNetwork ? true # to be replaced with virtualisation.restrictNetwork , patchQemu9p ? false # until qemu 7.2.0 becomes available in nixpkgs }: -rec { +let + shellLib = flake.lib.shell { inherit pkgs; }; + +in rec { nixosConfigurations.${name} = pkgs.nixos ({ modulesPath, lib, pkgs, ... }: { imports = [ @@ -43,6 +48,19 @@ rec { ''; }; + environment = { + variables = envVars; + systemPackages = tools; + + # TODO: also print a summary of the host mount points + # TODO: also print a summary of the forwarded ports + interactiveShellInit = lib.mkBefore '' + ${lib.optionalString (envVars != {}) (shellLib.printEnvVars envVars)} + ${lib.optionalString (tools != []) (shellLib.printBins tools)} + echo + ''; + }; + virtualisation = { graphics = lib.mkDefault false; diskImage = lib.mkDefault "$TMP_DISK"; -- cgit v1.2.3