Why is`--arg` and `--argstr` incompatible with flakes?

Recently I’m trying to create a common home-manager configuration in my personal flake that can be deployed on multiple dev environment. Since the $USER and $HOME of these env is not controlled by myself, they have to be passed externally. The only reasonable way I’ve found so far is pass --impure and use builtins.getEnv to fetch these info, which is not ideal to me.

I already know that --arg and --argstr cannot be used in company with flakes, but now I really feel the pain. What’s the reason behind this design choice? Is there a saner way to EXPLICITLY pass external inputs in the above case?

4 Likes

https://github.com/NixOS/nix/issues/3843#issuecomment-661710951

1 Like

Then do we have anything that may support my use case without using --impure (which IMO is not necessary in this case)?

Though determine the evaluation result based on the evaluating platform may be implicity and thus not acceptable, what’s the problem of determine the result EXPLICITLY by commandline arguments? What’s the huge difference between passing args through URL (like github:some/repo?dir=someflake) and through commandline?

2 Likes