Allow setting nested attributes via --arg/--argstr				#496
		
		
	
	
		Labels
		
	
	
	
	No labels
	
		
			
	
	Affects/CppNix
		
			Affects/Nightly
		
			Affects/Only nightly
		
			Affects/Stable
		
			Area/build-packaging
		
			Area/cli
		
			Area/evaluator
		
			Area/fetching
		
			Area/flakes
		
			Area/language
		
			Area/lix ci
		
			Area/nix-eval-jobs
		
			Area/profiles
		
			Area/protocol
		
			Area/releng
		
			Area/remote-builds
		
			Area/repl
		
			Area/repl/debugger
		
			Area/store
		
			bug
		
			Context
contributors
		
			Context
drive-by
		
			Context
maintainers
		
			Context
RFD
		
			crash 💥
		
			Cross Compilation
		
			devx
		
			docs
		
			Downstream Dependents
		
			E/easy
		
			E/hard
		
			E/help wanted
		
			E/reproducible
		
			E/requires rearchitecture
		
			Feature/S3
		
			imported
		
			Language/Bash
		
			Language/C++
		
			Language/NixLang
		
			Language/Python
		
			Language/Rust
		
			Needs Langver
		
			OS/Linux
		
			OS/macOS
		
			performance
		
			regression
		
			release-blocker
		
			stability
		
			Status
blocked
		
			Status
invalid
		
			Status
postponed
		
			Status
wontfix
		
			testing
		
			testing/flakey
		
			Topic/Large Scale Installations
		
			ux
		
		
	
		No milestone
		
			
		
	No project
	
		
	
	
	
	
		No assignees
		
	
	
	
	
		4 participants
	
	
		
		
	Notifications
	
		
	
	
	
		
	
	
	Due date
No due date set.
	
		Dependencies
		
		
	
	
	No dependencies set.
	
	
		
	
	
		
			Reference
		
	
	
		
	
	
			lix-project/lix#496
			
		
	
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	
	No description provided.
		
		Delete branch "%!s()"
	 
	Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is your feature request related to a problem? Please describe.
Yes,
nix-build -A foo --arg config '{allowAliases=true;}'is quite annoying to type out.Describe the solution you'd like
I intuitively assume that I can do
nix-build --arg config.allowAliases trueand then realize that this isn't the case. Would be kinda neat if this would be possible.Describe alternatives you've considered
The nixpkgs
configarguments are prettynixpkgs-specific. I briefly considered allowing via CLI to do stuff such asallowAliases/allowUnfree/..., but couldn't think of a reasonable way.My proposal isn't the prettiest either, but makes the usability notably better, in my opinion at least.
If somebody has a better idea for that problem I'd be happy to discuss. If people agree on that, I'd give this a shot soonish.
Additional context
What needs to be discussed is how we want to do set merging then. I could think of:
--arg config '{ ... }' --arg config.foo '...'works. So doesrec config {}.--arg config.foo.baris set, one/few must not specify--arg configor--arg config.foo. This is a CLI and not Nixlang after all.This might be a regression to fix since it would break users who are setting an arg that has dots in it.
Good point!
The first question is if you think it's worth making the change, but with a deprecation period (i.e. Lix 2.92 will give a warning when using dots in
--arg, 2.93 may error out, then the change). Alternatively, we could add another CLI arg for that, but that may be even more confusing. I can't remember having seen--argwith dotted attribute names anywhere whereas the--arg config.Xis a thing for nixpkgs, so doing that might be an option, IMHO at least.With that said, we'd want to interpret CLI args as identifiers then, correct (assuming we want to explore that further)? I.e. you can still specify dotted args by
--arg '"foo.bar"', same for all other things that cannot be part of an identifier, right?yyyyyyeah, I really don't like interpreting things as identifiers in the CLI. it makes scripts have to think about what an identifier is to Nix and escape it properly, whereas if it's passed straight-through as a string, they don't have to worry about any such thing.
Whether this is a big deal for
--argis another question; I don't know how many instances there are of people putting non-identifiers into there because who the heck puts illegal identifiers into function args? I would be fine if we emitted a warning if the --arg value was an illegal identifier, linking to this issue and asking for people to report their use case, then we could probably find out if this is going to break anyone before actually breaking them. Then in a future version we could turn it into an identifier.But accepting identifiers in here feels kind of sketchy, and we would have to think about how the merging rules would work for multiple
--arg config.foo(not trivial; consider--arg config.foo.bar 2and--arg config.foo '{meow = 4;}').Yeah, that's even better than starting a deprecation right now, agreed!
So my two suggestions are flat out prohibiting that or copying the behavior of the Nix language (i.e.
--arg config.foo "{ ... }"can be merged with any--arg config.foo.X, including all the weirdness such as #329).My gut feeling prefers the former.
wdyt?
Yeah I am inclined to want to be more strict, since you can be looser later on. I think @piegames would thank us for doing that, if we take such an approach, since they have been deep in knowing too much of the merging rules.
I am nothing but the right arm of @pennae, who is also the primary source of my knowledge. I haven't fallen down the rabbit hole of attribute merging yet (it's on my TODO list though), but AFAIK the issues with merging come up with recursive attrsets and other interactions with language features. Moreover, attrset merging is merely syntactic sugar within the parser, so outside of that one has to explicitly define some semantics anyways.
This issue was mentioned on Gerrit on the following CLs:
--argisn't a valid Nix identifier")--argisn't a valid Nix identifier")--arg/--argstrisn't an a valid identifier")Given that we'll probably skip 2.92 in nixpkgs, I'd suggest we defer the plan for a release: i.e. 2.94 should error out, 2.95 should contain the change.