-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Support $NIRI_CONFIG
environment variable.
#400
Conversation
I love this change and am very excited for it. This will greatly simplify my nixOS setup. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what the problem is. You mentioned that some programs have a config environment variable for this reason. However, I'd like to know, how do other compositors handle this? Since compositors have unique questions in this regard, namely:
Should NIRI_CONFIG
be propagated to children?
- If yes, other programs developed on NixOS may start relying on the presence of this. We might need to start force setting the variable then.
- If not, running nested development niri (i.e.
./target/debug/niri
) won't pick it up.
With Sway, the Hyprland works similarly: the Wayfire supports "last passed Reworking the CLI arguments such that a prefix of
Intuitively, I'd say no. Ideally, if
If other programs need to read from the niri config, i reckon it'd make more sense to implement as a
If we don't propagate it, but it is desired to use for a nested dev niri, it is fairly easy (on NixOS at least) to pass the config path as a variable. If we say that the config lives a Note that i did not say this is trivial; it requires some restructuring in I would however argue that the nested compositor not picking it up is desirable in some cases too. I've personally been working on a branch once or twice that is based on an older version of niri, where my current configuration is invalid. It would honestly be fine for such a use case to have Ultimately, i don't think it's a significant problem either way. It doesn't affect my use case. The two main arguments in favor of either way are: We don't want other programs to rely on this environment variable => unset it and We do want nested development niri to be able to rely on it => propagate it. (note that general "nested niri" doesn't apply really, at least not on NixOS, because in that case it would still be executed in the wrapper and get the config no matter what) As for adding a |
Thanks for the detailed explanation! Hmm, there's probably a relatively straightforward way to always accept
Could be added if anyone needs it I guess.
I agree it's kinda strange; don't think it's necessary. |
I don't wish to implement this personally, as it's kind of annoying to restructure the entire cli for what is seemingly one use case. I also think that for niri in particular, it's not the most intuitive solution, because then you can pass That being said, if it were implemented and |
On NixOS, it is a common pattern for config files to be in the read-only
/nix/store/
. With my current niri-flake, that is where it ends up, and it is symlinked to~/.config/niri/config.kdl
.There are various reasons to not symlink that, mainly if you need multiple configs for a single user. When supplying config files from the nix store, it is standard practice to pass them with an environment variable using the standard
makeWrapper
helper function (example inopenrefine
). This is because the CLI options on most programs are not flexible enough.it is easy to use a custom config by passing the
--config
flag, to eitherniri
orniri validate
, but it becomes a problem to prefix it to all commands. This is because (1) it will be rejected when invoking subcommands, so you can no longer callniri validate
orniri msg
, and (2) it cannot be passed multiple times, so prefixing it like this is essentially disabling the--config
flag for all users of this wrapper. Essentially, it will cause all niri commands to be invalid exceptniri
andniri --session
.Instead of bodging something strange onto the cli arguments, i've instead added an environment variable. Then, it can be easily substituted with the standard wrapper approach.
This allows me to easily create a
pkgs.niri-unstable.with-config
function that can add this in a wrapper. I've been thinking of doing this for a long time, but didn't implement anything because i was unsure of any real use cases for it. Since then, i've started using niri on my login screen, something which currently relies heavily on implementation details ofniri-flake
. Additionally, i believe such a function (for which this environment variable is necessary) would also resolve sodiboo/niri-flake#278.