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

How to specify several lines via extra-conf in /etc/nix/nix.conf ? #427

Closed
teto opened this issue Apr 25, 2023 · 1 comment · Fixed by #456
Closed

How to specify several lines via extra-conf in /etc/nix/nix.conf ? #427

teto opened this issue Apr 25, 2023 · 1 comment · Fixed by #456

Comments

@teto
Copy link

teto commented Apr 25, 2023

maybe a duplicate of #425 but how to add several lines to nix.conf ?

I would like a better example in README/builtin help: I tried
sh ./nix-rust-installer.sh install --extra-conf "experimental-features = nix-command flakes" --extra-conf "extra-substituters = XXX"
but it fails.
I've tried sh ./nix-rust-installer.sh install --extra-conf 'experimental-features = nix-command flakes\nextra-substituters = XXX' but only 'experimental-features = nix-command flakes' got written to /etc/nix/nix.conf, the line after\n` got ignored.

Supporting several --extra-conf would be cleaner + be closer to nix --extra-XXX flags

@Hoverbear
Copy link
Contributor

You may have found a bug!

You should be able to set --extra-conf multiple times:

#[cfg_attr(feature = "cli", clap(long, action = ArgAction::Set, num_args = 0.., value_delimiter = ',', env = "NIX_INSTALLER_EXTRA_CONF", global = true))]
pub extra_conf: Vec<String>,

And we should join those together:

let extra_conf = extra_conf.join("\n");
let mut nix_config = nix_config_parser::NixConfig::parse_string(extra_conf, None)
.map_err(CreateOrMergeNixConfigError::ParseNixConfig)
.map_err(Self::error)?;

My suspicion is that this is a bug in the nix-config-parser we've been developing. We already set --extra-conf "experimental-features = nix-command flakes" so it's possible the parser is somehow dropping part of the input in it's deduplication process. Could you try not passing that and just passing the extra-substitutors one?

@cole-h maybe this is something you'd be interested in looking at?

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 a pull request may close this issue.

2 participants