-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Build-time nushell config generation #6685
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
Build-time nushell config generation #6685
Conversation
To avoid CI failing due to upstream build failures and fetching dependencies on each CI run, most packages are |
|
There was a PR to fix the nu shell integration in pay-respects but I believe it ended up getting split into separate PR and the nu shell side never got done. In most tests it doesn't download the binary so trying to do pipe it out pretty much what I said here still applies to this PR #6257 (comment) |
|
I think I more or less understand what is happening now. But that just means that the test framework of home manager is faulty. The only rational solution to this is to either make home manager test framework use real binaries or just disable nushell tests that fail because the thing they are trying to test cannot be tested correctly by the current test framework. There is no reason why home manager implementation should be limited by it's test framework, it's the test framework that should adapt to the needs of the implementation. If you disagree with me then it just means that nobody can use |
You can probably submit a PR to fix testing first then and mark this as a dependent on that PR. |
If you need access to a real binary, just pass |
190509c to
96132de
Compare
Thank you for telling me that, I thought that what was said here: #6257 (comment) is the only option. |
96132de to
49a722a
Compare
|
This change seems quite important on its own, and I'm not sure if this PR is the right place to mention this, but this change made me think about the recent addition of autoload directories in nushell. Since with this PR, we would be generating derivations for each sourced file anyways, I wonder if it's possible to generate the files in a way where they would be automatically be picked up by nushell's autoload and not have to be sourced explicitly, e.g. as described in #6434 (comment). The approach mentioned in #6434 (comment) seems like it would be quite easy to implement, but I'm not sure what people think about having to add derivations to For further reference in case anyone wants to take a look at this, autoload directories seem to be documented |
49a722a to
3e54b76
Compare
If this is indeed as easy as described in that comment then I could change the implementation to use autoloading instead of sourcing configs manually. Also any of the existing nushell tests will be irrelevant and removed. because there is nothing to check for in the config file. But I am also not sure what people think about that. |
I mean I would be for it :P |
I think the test would simply be, does the file exist in the autload directory with integration enabled. If this is a supported upstream behavior, I think it makes sense to leverage their own loading mechanisms and offload that maintenance burden. |
|
As an example I tried to do this: home.packages = [ cfg.package ] ++ lib.optionals cfg.enableNushellIntegration [
(pkgs.runCommand "carapace-nushell" { } ''
mkdir -p $out/share/nushell/vendor/autoload
${bin} _carapace nushell > $out/share/nushell/vendor/autoload/carapace.nu
'')
];but unlike nushell = lib.mkIf cfg.enableNushellIntegration {
extraConfig = ''
source ${
pkgs.runCommand "carapace-nushell-config" { } ''
${bin} _carapace nushell >> "$out"
''
}
'';
};It seems that nix still tries to build the runCommand package even when enableNushellIntegration is supposed to be false. {
carapace-bash = ./bash.nix;
carapace-zsh = ./zsh.nix;
carapace-fish = ./fish.nix;
carapace-nushell = ./nushell.nix;
}And it tries to build the runCommand package it fails to build the package because binaries are stubbed. When it shouldn't be trying to build it in the first place. I can just force real binaries in tests for other shells too but that seems wrong because it shouldn't build the package if nushell is not enabled. |
3e54b76 to
5594be5
Compare
khaneliman
left a comment
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.
LGTM for the main changes, not a fan of having to introduce realPkgs for all the tests atm since it'll introduce potential for upstream packaging breaking our CI. But, not certain of a good alternative, atm.
|
Hmm, wasn't expecting that... The others worked fine, just this one is blowing up. > Error: could not load client settings
┃ >
┃ > Caused by:
┃ > 0: could not create dir "/homeless-shelter/.config/atuin"
┃ > 1: failed to create directory `/homeless-shelter/.config/atuin`
┃ > 2: Permission denied (os error 13)
┃ >
┃ > Location:
┃ > crates/atuin-client/src/settings.rs:816:14 |
Description
Instead of running programs that print their shell config to stdout every time nushell initializes and saving their output to disk in .cache directory then sourcing it in the main config.nu file, just generate the config during nix build and source it directly from the nix store.
If you want you can implement something similar for all other shells too. It's just that for nushell this seems to be the only rational way.
also pay-respects nushell integration didn't ever work, now it generates the configuration correctly.
but even though the configuration that pay-respects generates is added to nushell config.nu correctly now it still doesn't work for me. On invocation it gives suggestions for the command that invoked it so not the last one before it that it is supposed to fix.
By the way, I have no idea why but tests fail even though I edited them according to my changes and error messages are either not helpful or I can't read them, I may know how to make nix modules but I never had to deal with home-manager test framework and am not ready to spend weeks trying to figure it out myself so help me with that.
like this for example:
full log does not say anything new because the log is 1 line long.
I don't know why tests expect
@carapace@/bin/carapacewhile generating nushell config if they are only supposed to for other shells. There are more test failures of the same kind.Checklist
Change is backwards compatible.
Code formatted with
./format.Code tested through
nix-shell --pure tests -A run.allor
nix build --reference-lock-file flake.lock ./tests#test-allusing Flakes.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
Maintainer CC
@ALameLlama @Weathercold @bobvanderlinden @water-sucks @terlar