Yes, writeShellApplication
is a good solution. But instead of altering your path, put the result right in the environment.systemPackages
list, or in users.users.your-user.packages
.
writeShellApplication
produces a derivation (a value that will be turned into a store path when it's "instantiated"). Basically it's already a package. You can use the derivation the same way you would use a package from nixpkgs.
You're likely already aware, but when you get secrets from sops those are paths to files in /var/run/
generated at runtime; so your scripts will need to run with sufficient privileges to read the secrets files.
Edit: Sorry, I meant "instantiated", not "realized"