I am trying to create a secrets.yaml file in a host machine directory like nix-main/hosts/desktop/secrets.yaml
when I run from my nix config root directory
sops hosts/desktop/secrets.yaml
it will open up the nano editor, I will make the changes I want on the boiler plate that comes up and I try to save/exit and it always gives the following error:
Could not open in-place file for writing: open /hosts/desktop/secrets.yaml: no such file or directory
I thought that by running the sops command it could create the file, I didn’t need to have a pre-existing one.
If I do create an empty one first, it will still open up it’s own boiler plate one instead of the one I created and will give the same error after editing and saving
I see an important one-character difference between these lines:
sops hosts/desktop/secrets.yaml
open /hosts/desktop/secrets.yaml: no such file or directory
^ this character
You told it to create a file at a relative path – hosts/desktop/secrets.yaml below your NixOS config root – but it’s trying to write to the absolute path /hosts/desktop/secrets.yaml instead, and failing, because that’s the wrong place.
That strikes me as a bug. I have sops 3.9.4 and it handles relative paths correctly, maybe you have a different version?
You may be able to work around the bug by giving sops an absolute path instead: try this command