Fix process quitting for sudo
processes
This commit is contained in:
parent
7f862474b4
commit
c6c793b3f3
1 changed files with 18 additions and 13 deletions
|
@ -122,37 +122,42 @@ in {
|
||||||
vm
|
vm
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
command = "${vm}/bin/run-${config.system.name}-vm";
|
originalCommand = "${vm}/bin/run-${config.system.name}-vm";
|
||||||
|
|
||||||
prefix =
|
|
||||||
lib.concatStringsSep " " (
|
|
||||||
lib.optionals config.virtualisation.runAsRoot (
|
|
||||||
["sudo"] ++
|
|
||||||
lib.optional config.virtualisation.qemu.runInBackground "-b"));
|
|
||||||
|
|
||||||
suffix =
|
suffix =
|
||||||
lib.concatStringsSep " " (
|
lib.concatStringsSep " " (
|
||||||
lib.optional
|
lib.optional config.virtualisation.qemu.runInBackground "&");
|
||||||
(!config.virtualisation.runAsRoot && config.virtualisation.qemu.runInBackground)
|
|
||||||
"&");
|
|
||||||
|
|
||||||
wrapped = pkgs.writeShellApplication {
|
shellApp = pkgs.writeShellApplication {
|
||||||
name = "run-${config.system.name}-vm";
|
name = "run-${config.system.name}-vm";
|
||||||
text = lib.strings.concatLines (
|
text = lib.strings.concatLines (
|
||||||
[
|
[
|
||||||
"${prefix} ${command} ${suffix}"
|
"${originalCommand} ${suffix}"
|
||||||
] ++ (
|
] ++ (
|
||||||
let
|
let
|
||||||
spice = config.virtualisation.qemu.spice;
|
spice = config.virtualisation.qemu.spice;
|
||||||
|
viewerPrefix = "sudo -Eu\"#$SUDO_UID\" ";
|
||||||
in
|
in
|
||||||
(
|
(
|
||||||
lib.optionals
|
lib.optionals
|
||||||
config.virtualisation.virt-viewer
|
config.virtualisation.virt-viewer
|
||||||
[
|
[
|
||||||
"${pkgs.virt-viewer}/bin/remote-viewer spice://${lib.escapeShellArg spice.bindAddress}:${toString spice.port}"
|
"${viewerPrefix}${pkgs.virt-viewer}/bin/remote-viewer spice://${lib.escapeShellArg spice.bindAddress}:${toString spice.port}"
|
||||||
"kill %1"
|
"kill %1"
|
||||||
])));
|
])));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wrapped =
|
||||||
|
if !config.virtualisation.runAsRoot
|
||||||
|
then
|
||||||
|
shellApp
|
||||||
|
else
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = shellApp.name;
|
||||||
|
text = ''
|
||||||
|
sudo -E ${shellApp}/bin/${shellApp.name}
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
pkgs.symlinkJoin {
|
pkgs.symlinkJoin {
|
||||||
name = packageName;
|
name = packageName;
|
||||||
|
|
Loading…
Reference in a new issue