-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
Port over the NixOS fish module #50
Conversation
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.
Looks great!
modules/programs/fish.nix
Outdated
set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $__fish_datadir/functions | ||
|
||
# For "reasons not remembered," setEnvironment does not set PATH, so do it here | ||
set PATH ${replaceStrings [":"] [" "] config.environment.systemPath} |
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 think it was something related to ordering, but I guess it's actually useful in this case. How is the separator handled on nixos?
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.
Since setting the PATH happens inside fenv
's temporary bash environment, the foreign-env plugin for Oh My Fish! handles converting the separator for us. This applies just as well to nix-darwin since we're also using fenv. :-)
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.
Ah, interesting. I might change it to just set environment.variables.PATH
at some point then.
modules/programs/fish.nix
Outdated
set PATH ${replaceStrings [":"] [" "] config.environment.systemPath} | ||
|
||
# source the NixOS environment config | ||
fenv source ${config.system.build.setEnvironment} |
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 inlined this in the other modules since nothing actually needed a separate file. But I can change this to a writeText
and use the text attribute instead.
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.
Thanks for this. I’m reading the diff on my phone and it looks like you’ve done away with |
modules/programs/fish.nix
Outdated
|
||
${concatStringsSep "\n" fishVariables} | ||
# if we haven't sourced the general config, do it | ||
if not set -q __fish_nixos_general_config_sourced |
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.
do we care that references to NixOS have now ended up in the module? Would it be worth adding a PR to Nixpkgs which changes these to generic names, perhaps substituting nix
for nixos
and makes a note that this path is depended-on in nix-darwin and potentially other declarative configuration/module systems for Nix and not just NixOS?
Is it worth it just for the name change? Is it worth it to leave a note to Nixpkgs/NixOS developers so they know to at least ping people should that change?
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.
Good point. I'm down with changing the names to nix_darwin
instead of nixos
. How do others feel?
modules/programs/fish.nix
Outdated
environment.etc."fish/foreign-env/interactiveShellInit".text = cfge.interactiveShellInit; | ||
environment.etc."fish/foreign-env/extraInit".text= cfge.extraInit; | ||
|
||
environment.etc."fish/nixos-env-preinit.fish".text = '' |
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.
In the Fish package in Nixpkgs, Fish looks for this file, /etc/fish/nixos-env-preinit.fish
. This is fine for us, but it means that we have to 'own' /etc/fish
in nix-darwin
. If we changed the Fish package to refer to /etc/static/fish/nixos-env-preinit.fish
or something like that, this piece (and other pieces, if we changed them accordingly) would work even if nix-darwin
can't or doesn't write directly to /etc/fish
. Is that desirable? I don't think it would disrupt the way things work on NixOS.
tl;dr: Can we safely assume that /etc/static
is where both nix-darwin and NixOS will write Fish config files to, and if so, should we change the modules (on both) to refer to those paths instead of the ones that live under /etc
?
@yurrriq Good catch. I think maybe it would be best if we could use a global 'variables' attribute in config.environment and make sure that those variable changes are represented in I don't think that the foreign-env plugin currently applies aliases, but I think if we could enhance it to do so that would be ideal, because then we could put all of this stuff in generically as POSIX shell scripts and have If this got through as it is now, you could set those variables with export directives inside I don't think you should have to, though. Being able to set aliases and variables directly, without worrying about the logic of when those things get sourced seems like it should be a feature. It looks like it's missing in the NixOS module, so I will seek to update that as well according to what we decide is a good idea here. |
Thanks for all the comments! I'll take a look at addressing them tonight hopefully, sometime this week for sure. |
Hey y'all. I just submitted a PR for Fish in Nixpkgs which makes it so that Fish installed via Nix takes care of NIxifying the environment automatically and transparently, regardless of whether you're using Fish on NixOS, Nix with GNU+Linux, Nix on macOS, or with nix-darwin. It still needs more manual testing and probably other work (I think we should add some tests for initialization behavior as well), but it's ready for your comments. I'm using it with nix-darwin (a version similar to this PR (slightly modified and based on @LnL7 's recent updates) on this laptop and I'll be testing it on macOS without nix-darwin tonight, as well as on NixOS. I may not have a non-NixOS GNU+Linux machine online to test on until tomorrow. It would impact this PR, if only to simplify it. The global shell configuration stuff is still new functionality, and we also still want to restore the functionality for setting variables and possibly add alias-setting support to |
@therealpxc I agree that better alias support would be good. FWIW as of 2.5.0, fish seems to operate much closer to bash wrt. aliases. (e.g. typing |
So I hadn't got back to this, but the way this is currently set up, does it actually translates all the system-wide aliases correctly so that |
Ah yeah, I forgot to bring back adding variables (thanks for the heads up @yurrriq) EDIT: Ah yeah nevermind we're using the normal setEnvironment stuff now, so that should all Just Work™ |
Looking into the test failure… |
Looks like that test will have to be adjusted. Also pxc had an interesting idea for how to make much of this work on non-nix versions of fish. I have some local nix usage related issues / confusion I need to untangle as well. Putting [WIP] tag back on |
I’ve amended my config so it’s moot for me, but @therealpxc and I have been working though reinstalling Nix and testing all this cleanly. I’ve borked my work machine now and it’s rebuilding the nix-darwin system manually (curl error 77 x a million) while I’m at a show... here’s hoping it’s all good when I get home / by tomorrow morning.. |
Update: Both my personal and work machines now have fully-functioning, fresh installs of Nix and nix-darwin and I can test out fish changes on Saturday. |
(If you try to test these changes and my Nixpkgs changes at the same time, your system will be broken. Eventually we will make sure that the changes in Nixpkgs are met with whatever changes are needed in nix-darwin to make things work, but we're not letting one PR hold up the other for now.) |
@yurrriq Have you had a chance to test this with your configuration, did anything break? |
Last I checked it didn't break anything. FWIW I stopped using |
@LnL7 This should be ready to go now! |
🎉 I’ll try this out again on my personal machine shortly. |
This has potentially introduced an issue on my system:
I'm trying to find the cause, but also doing a |
This is a cosmetic issue and a side effect of using fenv with the
setEnvironment script. It's being addressed in our fenv patch in the
fish-foreign-env package in Nixpkgs. I think Colin recently opened a PR for
it.
…On Thu, Nov 16, 2017, 12:35 AM Eric Bailey ***@***.***> wrote:
This has potentially introduced an issue on my system:
set: Tried to change the read-only variable '_'
I'm trying to find the cause, but also doing a nix-channel --update now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#50 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADCJbolsLM1srd6R3CnNHQHQ5HzlkHl3ks5s2-XcgaJpZM4PxM1K>
.
|
Correct. I've been busy with a class and have been neglecting Nix. I aim to make progress on this next week as I'm off from work. |
This PR essentially replaces this file with the nixos fish module. The only difference between the two now is nuking the reference to
environment.shells
🎉The NixOS fish module has a number of nice features that we're gaining, such as more customizable initialization.