I made progress but still haven’t solved this. I could still use help.
I’m successfully able to create the temp files I need:
systemd.tmpfiles.rules = [
"d /run/pipewire-shared 0550 1000 qemu-libvirtd"
"f /run/pipewire-shared/pipewire-0 0555 root root"
];
I’m also successfully able to configure the bind mount I need in /etc/fstab
by doing this:
fileSystems."/run/pipewire-shared/pipewire-0" = {
device = "/run/user/1000/pipewire-0";
options = [ "bind" "noauto" "user" "rw" ];
fsType = "none";
};
The final, unsolved, step is to actually perform the mount. I can do this manually by running:
mount /run/pipewire-shared/pipewire-0
Great! But, I don’t want to have to run this manually. Also, I don’t think I can simply configure the mount as an auto-mount, because the source file which I’m bind-mounting from, /run/user/1000/pipewire-0
, first must be available, and it’s initialized in a user-mode systemd socket: pipewire.socket
.
So, I need the command mount /run/pipewire-shared/pipewire-0
to be run, immediately time after the systemd pipewire.socket
is initialized. I tried the following:
systemd.user.services."pipewire-shared-mount" = {
after = [ "pipewire.socket" ];
script = ''
#!/bin/sh
exec 2>&1
${pkgs.mount}/bin/mount /run/pipewire-shared/pipewire-0
'';
};
The service is created, but its script exits with exit code 32
, and the error message: “mount: /run/pipewire-shared/pipewire-0: must be superuser to use mount
”. Interestingly, this command works fine when I run it manually.
Here are the systemd logs:
$ journalctl --user-unit pipewire-shared-mount
Jun 01 00:20:09 nixos systemd[1784]: Started pipewire-shared-mount.service.
Jun 01 10:28:23 nixos pipewire-shared-mount-start[197439]: mount: /run/pipewire-shared/pipewire-0: must be superuser to use mount.
Jun 01 10:28:23 nixos systemd[1784]: pipewire-shared-mount.service: Main process exited, code=exited, status=32/n/a
Jun 01 10:28:23 nixos systemd[1784]: pipewire-shared-mount.service: Failed with result 'exit-code'.