Change the way NixOS handles environment variables, NixOSize environment configuration, make it possible not to use Bash, add support for Zsh. #256
Conversation
Just to note. I somewhat like the "features" idea in #138 by @MarcWeber, but I think this patch handles environment variables better and doesn't change anything else except for one option name. |
# FIXME: This variable is no longer needed, but we'll keep it | ||
# around for a while for applications linked against old | ||
# fontconfig builds. | ||
environment.variables."FONTCONFIG_FILE".value = "/etc/fonts/fonts.conf"; |
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.
Are the quotes in that line necessary? Wouldn't environment.variables.FONTCONFIG_FILE.value = ...
work just the same way? Or am I missing something?
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.
It would, I did not think much about the cosmetics.
Is there any way to get rid of
seems simpler and more intuitive. |
@peti, yep, in principle, it looks nicer without the |
@oxij "but I think this patch handles environment variables better" |
@MarcWeber I don't like the whole idea of setting up the variables by typing sh code. Current nixos does this everywhere and your patch doesn't change that (AFAICS, it more or less duplicates this setup for zsh). My point is that this version of my patch doesn't (at least shouldn't) change anything for current users, but makes environment setup more modular and reusable (and it could get even better when nixpkgs is fixed, see NixOS/nixpkgs#986). |
@oxij: This looks interesting. But I didn't quite get your explanation of why you want/need .value and .list. I understand that you don't get one explicit type without them, but why is that important? Could you elaborate? IMHO, just |
@bjornfor Yes, I would like to have something prettier (algebraic data types!) too, but I did not find any other way to define the type of a variable to be |
@oxij: Thanks for explaining. |
@oxij: Yes, I duplicated the implementation because I felt ZSH is different, and sharing is hard (unless you start changing default behaviour of ZSH a lot). How do you cope with system vs user profile and merging both exactly? I dislike code duplication myself, but in that case it somehow looked easier to me to provide one implementation for each shell, because they have different features. What I did change is that I added primitives which allow you to mix arbitrary environments the way you want. /etc/{bash,zsh}/setup-all is just the system default. People can either opt-out or put the code they want in their own rc files reusing the primitives defined in /etc/{bash,zsh}/SHELL_NAME_lib files. So if you don't like shell, which is your proposal, how to merge system/user envs in a sane way without using the shell? Can you explicitly explain how your version differs in this aspect? |
NERDFIGHT! :) Please, can we just merge this if nobody has any real objections? Discussions about whose solution is better do not really matter to me, because this is a solution that has been put forward as a pull request, seems to be backward compatible and doesn't have any clear drawbacks. @MarcWeber if your solution is much better, you should have made a pull request! As I remember correctly, I asked about nixos zsh support on nix-dev like 2 years ago, where you mentioned your patches. I asked if you were going to push them upstream, but you didn't feel they were ready yet or had seen enough testing. Now, consider this pull request as a start, where people will actually be able to use zsh and start testing its interaction with nix. Then if this solution proves lacking, we can probably port your stuff/ideas. So unless @MarcWeber makes a pull request too (without regressions from the way things are now), I'd say we merge this, instead of arguing over differences to some hypothetical solution that was never put forward. |
For what it's worth, I too think this patch should be merged. I don't see a reason not to ... |
@bluescreen303 NERDFIGHT is wrong word. You can assemble env vars in nix, and I even see some advantages. My current (more or less) up to date patch #138. (Updated version which has been in use by me since 2 years) is on my github page. @bluescreen303 What you say is that you expect regressions. Maybe that's unfair without having tested my patches. My comments about the patch: COMMENT 1: So at least this should be fixed before merging IMHO. How to fix? COMMENT 2:
COMMENT 3:
COMMENT 4:
This code was dropped in favor of a nix only solution. The Nix only solution has pro and cons: cons:
Thus this means a major change in the behaviur ? Please don't be that lazy calling this a "NERD FIGHT". I may be a NERD, but sometimes its worth thinking about what I say or suggest. I'm human, I fail. So forgive me if I'm mistaken. I didn't test it. So I expect info failing to find info pages of user installed packages? So please also adjust the comment accordingly so that everybody A global list of profiles cannot replace user profiles, can it? Thanks. |
As for patch comment, well, I'll think about it, but I'm not sure it's possible to explain how the patch changes environment handling without simply retyping this change in English. (Also, NixOS saw much bigger changes with much shorter comments.) |
@MarcWeber I know it's the wrong word, as us nixers don't fight :) What I mean is: these commits do 1 thing, and 1 thing only. With your patch, as you mention yourself, you change a lot at once (not just the environment), adding lots of new features. Also, I cannot simply verify (by looking at the changes and within 10 minutes) that things will end up in the same state for all cases. Don't get me wrong, I like most ideas you propose/mention, but I don't like big all-or-nothing blobs. Furthermore, @oxij mentioned he had seen your work, so no unnecesarry duplication of work, which would have been my only concern if people propose similar stuff to what others have been working on. So instead of turning this into a vote of which solution is more flexible (a nerdfight:)), can't you just accept this proposal (as it is a light change) and work together on sanding off the rough edges to get your additional stuff applied? Like I said: I would like those, just not all at once. |
Simply pointing me to environment.profiles would have been enough. So only COMMENT 1 is left which I'd change. Another question: Why is there no easy way to configure aspell behavior? Could this be handled by adding a reverse property to profileVariables items ? I ask because I have a similar case for XML_CATALOG_FILES @bluescreen303 You could have asked for trying to create smaller patches. I've written to the mailinglist in order to find out which additional changes could be |
How exactly? I don't like the idea of guessing Because you could have installed dictionaries with |
… it possible not to use Bash as the default interactive shell. This change does two things: * "NixOSizes" environment variables generation. This allows some more error-checking and opens possibilities for a modular environment configuration. From now on the most of environment variables are generated directly by the nix code. Generating sh code that generates environment variables is left in a few places where nontrivial access to a local environment state is needed. * By doing the first change this patch untangles bash from the environment configuration and makes it trivial to add a support for other non bash-compatible shells. Now to the sad part. This change is quite large (and I'm not sure it's possible to split it) and yet is not quite complete, it needs some changes to nixpkgs to be perfect. See !!! comments in modules/config/shells-environment.nix. Main principle behind this change is "change environment generation and nothing else". In particular, shell configuration principles stay exactly the same as before.
Okay, I think I fixed all the issues which are fixable with current nixpkgs. (Would be nice if someone except me tested this.) |
I tested the previous "version" and found my environment to be exactly the same. Let's start discussing possible extensions/improvements somewhere else. For now it's a nice improvement.
I tested the previous "version" and found my environment to be exactly the same. Let's start discussing possible extensions/improvements somewhere else. For now it's a nice improvement. |
And thanks :) |
Yes, thanks! I've tweaked this a bit to unify "list" and "value" as @peti suggested. So now you can just say |
@edolstra Variables don't seem to merge well. |
@rickynils: use mkOverride, grep nixos for mkOverride usage examples |
@edolstra I think the issue @rickynils mentions suggests that this |
I've fixed this by adding a merge function that takes overrides into account. It gives an error message if there are multiple string values with the same priority. |
Ah, ok then. |
This PR changed some options without adding them to |
@shlevy I thought I did check that. What did I miss? |
See commit messages.