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

feat(step): nix-helper #1045

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

dtomvan
Copy link
Contributor

@dtomvan dtomvan commented Feb 17, 2025

What does this PR do

Add support for viperML/nh. See #1044.

Two decisions I've made upfront in this PR:

  1. I added the whoami crate. I found this practical as I don't want to implement these functions myself for multiple platforms. They say they support at least MacOS and Linux, and those are the two Unices that NixOS and nh are targetting anyways, so I think we're good here.
  2. I wrote run_nix_helper in a way that never dry-runs the two nix eval commands, which are used to figure out which configs are available in the flake. I added a comment to explain it at line 640, but in short I want to run these in both dry and wet runs so that the outcome of wet runs can be determined in a dry run.

I've run hyperfine on the nix eval command in my not-so-small nix flake (https://github.com/dtomvan/puntbestanden) and found that it doesn't cost a lot of time:

Benchmark 1: nix eval --json ~/puntbestanden#homeConfigurations --apply builtins.attrNames
  Time (mean ± σ):     155.3 ms ±   6.7 ms    [User: 51.8 ms, System: 57.9 ms]
  Range (min … max):   143.0 ms … 170.0 ms    19 runs
 
Benchmark 2: nix eval --json ~/puntbestanden#nixosConfigurations --apply builtins.attrNames
  Time (mean ± σ):     154.9 ms ±   7.5 ms    [User: 50.8 ms, System: 59.3 ms]
  Range (min … max):   135.6 ms … 166.2 ms    18 runs

So together this is only a slowdown of ~310 ms... I hope that's okay even for dry runs.

Standards checklist

  • The PR title is descriptive
  • I have read CONTRIBUTING.md
  • Optional: I have tested the code myself
  • If this PR introduces new user-facing messages they are translated

For new steps

  • Optional: Topgrade skips this step where needed
  • Optional: The --dry-run option works with this step
  • Optional: The --yes option works with this step if it is supported by
    the underlying command

If you developed a feature or a bug fix for someone else and you do not have the
means to test it, please tag this person here.

@dtomvan dtomvan marked this pull request as ready for review February 17, 2025 15:02
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

Successfully merging this pull request may close these issues.

1 participant