When the after is removed from the service above it works as expected (activated manually). I have also trying including a requires and RequiresMountFor but this does not seem to make any difference.
I have checked systemctl list-units --type mount before and after mounting the device and it is absent / present at the correct times. I also checked the systemd service file that Nixos creates and it appears to be generated properly. So Im not really sure what is going wrong here.
Read the systemd documentation (man systemd.unit), and youâll notice âafterâ doesnât make the other service a dependency, it just determines the order if both are already part of the same transaction. You want âwantedbyâ.
Yes, you are right. But it still does not seem to be working.
I tested wantedby on a â.serviceâ unit and it works just as expected. I then go back to the â.mountâ and it fails to trigger. I tried setting to another mount and it still fails to trigger.
Do you know how i can investigate it further?
Thanks
EDIT - Huh, ok I was wrong about the above. I was including multiple triggers in the service like after = [ "mnt-localLuks.mount" "nix.mount" ];, requires ...; wantedBy ... which I thought was acceptable but it seems like for some reason this does not allow the service to run.
If I set this up to be triggered by a single mount after = [ "nix.mount" ];, requires ...; wantedBy ... then it seems to trigger just fine.
So the problem must be the mnt-localLuks.mount itself somehow. Ill continue to look into it.
Thanks
EDIT2 - Ok, so for whatever reason this appears to be happening because the mount is a LUKS encrypted device. I created two mounts; one LUKS encrypted the other unencrypted. The service seems to be only triggered by the unencrypted device.
For practicality I just created a dummy service script which I set to start within the same script that I use to descrypt the LUKS device. Ill then trigger subsequent scripts on that dummy service script. This should serve my requirements
Im curious as to why the LUKS mount is not being recognised by the wantedBy. But nevertheless you are correct by that what I was missing is the wantedBy.
I should read the man file more closely but tbh I find that man page especially difficult to do. I will try harder next time.