oddlama / agenix-rekey

An agenix extension adding secret generation and automatic rekeying using a YubiKey or master-identity
MIT License
197 stars 16 forks source link

Agenix wrapper errors out for flakes that exist as a subdirectory in a git repository #12

Closed JustinLex closed 6 months ago

JustinLex commented 7 months ago

My homelab infrastructure monorepo has the "nodes" nix.flake under the nodes/ subdirectory. When I try to run the agenix wrapper in this subdirectory, it dies and gives the error "error: Could not determine location of your project's flake.nix. Please run this at or below your main directory containing the flake.nix." This is happening even though my pwd is the nodes/ directory with the nix.flake in it.

The bug seems to be here:

https://github.com/oddlama/agenix-rekey/blob/e02a57e08224422934974f19853d4d70ed7eaaaa/nix/package.nix#L21

USER_FLAKE_DIR is being set to the output of git rev-parse --show-toplevel, which is the parent git repository, not the subdirectory with my flake.

The agenix wrapper should either:

oddlama commented 7 months ago

Sounds good, I can add that when I have some time next month :)

oddlama commented 6 months ago

I've implemented recursive upward search, can you try whether that solves your problem?