Open adamlwgriffiths opened 4 years ago
FWIW, I work around this by simply excluding the shebang(s):
Not really a solution, but a(nother) workaround for the time being.
I marked this as stale due to inactivity. → More info
Still important to me
I just came across the same issue. Thank you cole-h for the reference nix configuration.
FWIW, I've slightly changed how I do this: https://github.com/cole-h/nixos-config/blob/61d17a3355288872e4b765ddce1700654a9accc8/hosts/scadrial/modules/libvirt/default.nix#L5-L16
Thanks @cole-h, I didn't realise modprobe would also be unavailable to my hooks. I've now gotten them working with the following mod from your linked nix files. Super awesome, since I've been trying to get this working for over a year.
systemd.services.libvirtd = {
path = let
env = pkgs.buildEnv {
name = "qemu-hook-env";
paths = with pkgs; [
bash
libvirt
kmod
systemd
];
};
in [ env ];
};
I marked this as stale due to inactivity. → More info
Describe the bug This bug is partially related to #51152, in that a declarative method of adding the hooks would solve this.
Hooks (eg
/var/lib/libvirt/hooks/qemu
) normally start with#!/usr/bin/env bash
. It seems this isn't valid within the libvirt context and causes the hook execution - and therefore the vm - to fail.Instead I have had to work around this by using
#!/run/current-system/sw/bin/bash
.To Reproduce Steps to reproduce the behavior:
Expected behavior VM starts without error
Screenshots
Additional context
#!/usr/bin/env bash
does not fix the issue#!/run/current-system/sw/bin/bash
does fix the issue.This also applies to all hook scripts that are in turn executed by the hook itself. Eg.
qemu.d/<vm>/prepare/begin/start.sh
.Notify maintainers @fpletz
Metadata $ nix-shell -p nix-info --run "nix-info -m"
"x86_64-linux"
Linux 5.4.62, NixOS, 20.03.2913.4bd1938e03e (Markhor)
yes
yes
nix-env (Nix) 2.3.6
"home-manager-20.03, nixos-20.03.2913.4bd1938e03e"
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information: