Libvirtd hooks falsely read as non-executable

I’m trying to set up a single cpu passthrough for my windows vm using virt-manager, and I need to write some hooks for virtio to do it.

libvirtd.enable = true;
libvirtd.hooks.daemon = { 
    "pac" = pkgs.writeScriptBin "passthrough.sh" ''
        "$("${pkgs.kmod}/bin/modprobe -V")" >> /troubleshoot.txt
        exit 1
    ''; 
};

The script does not execute when the libvirt daemon starts and I get this warning:

nixos .libvirtd-wrapp[30900]: Non-executable hook script /var/lib/libvirt/hooks/daemon.d/pac 

Despite the fact that the soft link in daemon.d and the /nix/store/xxxxx/lib/pac files are executable for all users.

Am I doint something wrong or is this bugged?

Also yes i know thats not where I should put the hook but it was for testing purposes, and writeShellScriptBin does not work either

if pac is supposed to be a script you need writeShellScript the bin variant is creating a bin directory with a script in it.

1 Like

Or use lib.getExe (pkgs.writeShellApplication { ... }) which shellchecks for free (unlike writeShellScript*).

1 Like