diff --git a/vm/cleanup.sh b/vm/cleanup.sh deleted file mode 100755 index ec906f4..0000000 --- a/vm/cleanup.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -rm -v nixos.qcow2 -rm -vfr result diff --git a/vm/configuration.nix b/vm/configuration.nix index fa89dfc..4afa1ad 100644 --- a/vm/configuration.nix +++ b/vm/configuration.nix @@ -1,4 +1,10 @@ -{ config, pkgs, modulesPath, hostname, ... }: +{ + config, + pkgs, + modulesPath, + hostname, + ... +}: { imports = [ diff --git a/vm/flake.nix b/vm/flake.nix index fff73d0..1cfb2c5 100644 --- a/vm/flake.nix +++ b/vm/flake.nix @@ -47,14 +47,37 @@ apps = forAllSystems ( system: let - vm = { - type = "app"; - program = "${self.packages.${system}.vm}/bin/run-${hostname}-vm"; - programArgs = [ "-enable-kvm" ]; - }; + pkgs = import nixpkgs { inherit system; }; + lib = pkgs.lib; + selfPkgs = self.packages.${system}; in - { - inherit vm; + rec { + vm = + let + scriptName = "run-${hostname}-vm"; + script = pkgs.writeShellScriptBin "${scriptName}" '' + ${selfPkgs.vm}/bin/run-${hostname}-vm \ + -enable-kvm \ + -virtfs local,path=$(${pkgs.coreutils}/bin/pwd)/..,mount_tag=host0,security_model=passthrough,id=host0 + ''; + in + { + type = "app"; + program = "${script}/bin/${scriptName}"; + }; + + clean = + let + scriptName = "clean-${hostname}-vm"; + script = pkgs.writeShellScriptBin "${scriptName}" '' + ${pkgs.coreutils}/bin/rm -rfv result ${hostname}.qcow2 + ''; + in + { + type = "app"; + program = "${script}/bin/${scriptName}"; + }; + default = vm; } ); diff --git a/vm/run.sh b/vm/run.sh deleted file mode 100755 index 82cc610..0000000 --- a/vm/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -nix run . -- -virtfs local,path=$(pwd)/..,mount_tag=host0,security_model=passthrough,id=host0