mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-26 22:23:01 +00:00
Shutdown vm at app close, initial support for args
This commit is contained in:
parent
8baa1ff73b
commit
3e8a08d638
15
generate.go
15
generate.go
@ -14,14 +14,23 @@ import (
|
|||||||
|
|
||||||
var template = `
|
var template = `
|
||||||
{pkgs, ...}:
|
{pkgs, ...}:
|
||||||
{
|
let
|
||||||
|
application = "${pkgs.%s}/bin/%s";
|
||||||
|
appRunner = pkgs.writeShellScriptBin "app" ''
|
||||||
|
ARGS_FILE=/home/user/.args
|
||||||
|
ARGS=$(cat $ARGS_FILE)
|
||||||
|
rm $ARGS_FILE
|
||||||
|
|
||||||
|
${application} $ARGS
|
||||||
|
systemctl poweroff
|
||||||
|
'';
|
||||||
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||||
<nix/base.nix>
|
<nix/base.nix>
|
||||||
];
|
];
|
||||||
|
|
||||||
services.xserver.displayManager.sessionCommands =
|
services.xserver.displayManager.sessionCommands = "${appRunner}/bin/app &";
|
||||||
"while [ 1 ]; do ${pkgs.%s}/bin/%s; done &";
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user