Nixpkgs: libvirtd: impossible to add hooks

Created on 28 Nov 2018  路  7Comments  路  Source: NixOS/nixpkgs

Issue description

Placing files in /etc/libvirt/hooks as is normal has no effect. It seems that the libvirt package is built with $(out)/var/lib as sysconfdir, and hooks are run from the sysconfdir folder.

Steps to reproduce

Place a script designed to run on vm start in /etc/libvirt/hooks.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.19.2, NixOS, 19.03.git.4f1a831 (Koi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.1.3
  • channels(root): ""
  • nixpkgs: /etc/nixos/nixpkgs

Most helpful comment

This is still important to me.

All 7 comments

Which makes the most sense:

  1. Have libvirtd execute hooks from /etc/libvirt/hooks (or another location outside of the Nix store).
  2. Have configuration options which can be used from configuration.nix to set up the hooks.

Which makes the most sense:

. Have libvirtd execute hooks from /etc/libvirt/hooks (or another location outside of the Nix store).

. Have configuration options which can be used from configuration.nix to set up the hooks.

Both can work simulteniously

libvirt is to read /etc/libvirt/hooks

and libvirt nixos module could have hooks option which unfolds into
environment.etc."libvirt/hooks/blablabla".text = ...

Yes, I agree -- that's what I was thinking as well.

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

This is still important to me.

For anyone stumbling on this issue, put your hooks at /var/lib/libvirt/hooks

The issue is, you can't do that simply with configuration.nix, I believe it requires a custom builder or just manually dumping the files there.
I could be very wrong, but I can't see anything in Nix that let's me easily make a file in configuration.nix.

I'm also having limited success in getting the hooks to work manually, it seems you need to restart libvirt/qemu for the hooks to be detected, so just writing the files manually doesn't seem to do anything without restarting the service / system.

Having the hooks exposed for a VM definition or libvirt globally would be helpful here.

Was this page helpful?
0 / 5 - 0 ratings