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 = ` 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 &";
} }
` `