♻️ refactor: better vm handling, no more scripts, we're true nix elitists here

Signed-off-by: xtrm <oss@xtrm.me>
This commit is contained in:
xtrm
2025-02-19 14:25:05 +01:00
parent e9f538ed92
commit 0fb19bbbe0
4 changed files with 37 additions and 17 deletions

View File

@ -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;
}
);