Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set custom environment variables in packages and devShells #312

Open
vbrandl opened this issue Nov 10, 2023 · 1 comment
Open

Set custom environment variables in packages and devShells #312

vbrandl opened this issue Nov 10, 2023 · 1 comment

Comments

@vbrandl
Copy link

vbrandl commented Nov 10, 2023

I want to convert a Rust project into a flake, that uses the vergen crate to create version metadata from the git repository at build time. I use the git ref and git describe output. vergen is somehow aware of nix and will return VERGEN_IDEMPOTENT_OUTPUT if .git is not present and the metadata cannot be obtained (e.g. in a nix build).

To fully convert the project into a flake, I'd like to set both ${self.rev or self.dirtyRev or "dirty"} and ${self.version} as environment in the nix build and fallback on something like env!("NIX_FLAKE_REF") if vergen cannot calculate metadata from the git repo.

How can I set custom environment variables, that are available when building the project (and possibly also in devShells) when using the template flake?

@samuela
Copy link

samuela commented Apr 16, 2024

I'm facing the same issue trying to load my sqlite schema at build time for sqlx...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants