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(common): add functionality to query the nix config #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jalil-salame
Copy link
Contributor

@jalil-salame jalil-salame commented Oct 19, 2024

This allows us to tackle issue #4 (nix cache detection).

This is intended to be used as follows:

use common::nix_conf;

// Helper that invokes `nix config show` and retrieves the stdout
let conf: String = nix_conf::nix_conf_get_from_cli().unwrap();

// Query the config for the "substituters" key (auto-merges extra-substituters, but it is not required)
let value: String = nix_conf::get_value(&conf, "substituters").unwrap();

// substituters is a list of URLs, parse the value like that
let substituters: Vec<&str> = value.split(' ').collect();

Some shortcuts were taken as we assume we are parsing nix config show's output. Specifically:

  • include and !include are not resolved.
  • We don't query the nix.conf search path for where to find the configuration files
  • We don't have functionality to parse the whole configuration (as only substituters is needed for issue #4)

If the above mentioned complexity is needed I can implement it here or in a separate PR.

This allows us to tackle issue cafkafk#4 (nix cache detection)
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