eval: remove is_test and embed mock-nixpkgs.nix#86
Merged
infinisil merged 1 commit intoNixOS:mainfrom Jul 26, 2024
Merged
Conversation
This commit does the following things: 1. Purify the environment variables entirely when calling `nix-instantiate`. Opt in to the five environment variables needed in order to run `nix-instantiate` in the Nix sandbox. 2. Remove the hard-coded `NIX_PATH` environment variables in `default.nix` and `package.nix`. These were implicitly sent through to `nix-instantiate`, along with `-I` arguments. Now, only `-I` is used. 3. Replace the `is_test` argument with `#[cfg(test)]` applied to `mutate_nix_instatiate_arguments_based_on_cfg`. While this is slightly more lines of code that the combination of Nix and Rust that it replaces, there is less Nix logic and more Rust logic. Additionally, the Rust logic that is test-only is contained to `cargo check` only rather than being present in the production binary.
infinisil
approved these changes
Jul 26, 2024
Member
infinisil
left a comment
There was a problem hiding this comment.
Very neat, this is much cleaner!
| "NIX_LOCALSTATE_DIR", | ||
| "NIX_LOG_DIR", | ||
| "NIX_STATE_DIR", | ||
| "NIX_STORE_DIR", |
Member
There was a problem hiding this comment.
Note for the future: These probably aren't all needed, because we don't do any building, just evaluation. I suspect only NIX_STATE_DIR is necessary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Similar to #84, reducing the amount of needed machinery in Nix in favor of Rust code. In particular, remove
NIX_PATHmanipulation in Nix derivations!Things Done
This commit does the following things:
nix-instantiate. Opt in to the five environment variables needed in order to runnix-instantiatein the Nix sandbox.NIX_PATHenvironment variables indefault.nixandpackage.nix. These were implicitly sent through tonix-instantiate, along with-Iarguments. Now, only-Iis used.is_testargument with#[cfg(test)]applied tomutate_nix_instatiate_arguments_based_on_cfg.While this is slightly more lines of code that the combination of Nix and Rust that it replaces, there is less Nix logic and more Rust logic.
Additionally, the Rust logic that is test-only is contained to
cargo checkonly rather than being present in the production binary.