#------------------------------------------------------------------------------#
#                             Flake Prerequisites                              #
#                                 (idempotent)                                 #
#------------------------------------------------------------------------------#
# Day-0 Steps (Ensure the following)
[ -f Cargo.toml ] || cargo init .; git ls-files --error-unmatch Cargo.toml >/dev/null 2>&1 || git add Cargo.toml
[ -f Cargo.lock ] || cargo generate-lockfile; git ls-files --error-unmatch Cargo.lock </dev/null 2>&1 || git add Cargo.lock

git ls-files --error-unmatch .envrc || git add .envrc
git ls-files --error-unmatch flake.nix || git add flake.nix
git ls-files --error-unmatch rust-toolchain.toml || git add rust-toolchain.toml


# .gitignore contains result and result-* as Nix will output build artifacts there.

# (optional) for direnv flake activation (does not create subprocess) devShell
use flake

#------------------------------------------------------------------------------#
#                         Post-flake activation setup                          #
#------------------------------------------------------------------------------#

git ls-files --error-unmatch flake.lock || git add flake.lock
git ls-files --error-unmatch deny.toml || {cargo deny init && git add deny.toml}
