Shutdown vm at app close, initial support for args

This commit is contained in:
Mikhail Klementev 2020-01-02 17:44:46 +00:00
parent 8baa1ff73b
commit 3e8a08d638
No known key found for this signature in database
GPG Key ID: BE44DA8C062D87DC

View File

@ -14,14 +14,23 @@ import (
var template = `
{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 = [
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
<nix/base.nix>
];
services.xserver.displayManager.sessionCommands =
"while [ 1 ]; do ${pkgs.%s}/bin/%s; done &";
services.xserver.displayManager.sessionCommands = "${appRunner}/bin/app &";
}
`