Skip to content

Commit

Permalink
feat: also search for nested flake.nix files (fixes #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed Feb 26, 2024
1 parent 1471129 commit ac73aac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ writeShellScriptBin "agenix" ''
echo ' generate Automatically generates secrets that have generators'
}
USER_FLAKE_DIR=$(git rev-parse --show-toplevel 2>/dev/null || pwd) \
USER_GIT_TOPLEVEL=$(realpath -e "$(git rev-parse --show-toplevel 2>/dev/null || pwd)") \
|| die "Could not determine current working directory. Something went very wrong."
USER_FLAKE_DIR=$(realpath -e "$(pwd)") \
|| die "Could not determine current working directory. Something went very wrong."
# Search from $(pwd) upwards to $USER_GIT_TOPLEVEL until we find a flake.nix
while [[ ! -e "$USER_FLAKE_DIR/flake.nix" ]] && [[ "$USER_FLAKE_DIR" != "$USER_GIT_TOPLEVEL" ]] && [[ "$USER_FLAKE_DIR" != "/" ]]; do
USER_FLAKE_DIR="$(dirname "$USER_FLAKE_DIR")"
done
[[ -e "$USER_FLAKE_DIR/flake.nix" ]] \
|| die "Could not determine location of your project's flake.nix. Please run this at or below your main directory containing the flake.nix."
cd "$USER_FLAKE_DIR"
Expand Down

0 comments on commit ac73aac

Please sign in to comment.