-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
writeShellApplication: use shellcheck only where supported #240348
writeShellApplication: use shellcheck only where supported #240348
Conversation
6f4e4ed
to
d0fe112
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/2401 |
# GHC (=> shellcheck) isn't supported on some platforms (such as risc-v) | ||
# but we still want to use writeShellApplication on those platforms | ||
let | ||
shellcheckSupported = (builtins.tryEval ghc.bootPkgs.ghc).success; |
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.
Wouldn't it make more sense to tryEval
shellcheck itself?
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 tried, but it returns true
, same for non-boot ghc. I think it's because the platform support in the ghc expression is implemented with throw
# GHC (=> shellcheck) isn't supported on some platforms (such as risc-v) | ||
# but we still want to use writeShellApplication on those platforms | ||
let | ||
shellcheckSupported = (builtins.tryEval ghc.bootPkgs.ghc).success; |
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.
something like this
shellcheckSupported = (builtins.tryEval ghc.bootPkgs.ghc).success; | |
shellcheckSupported = lib.meta.availableOn stdenv.hostPlatform ghc; |
or
shellcheckSupported = (builtins.tryEval ghc.bootPkgs.ghc).success; | |
shellcheckSupported = lib.meta.availableOn stdenv.hostPlatform shellcheck; |
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.
Don't you mean buildPlatform
? Also this evaluates to true
. I think it's because the platform support in the ghc expression is implemented with throw
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.
Can we convince the ghc people to change that to meta.platforms? Maybe it is super simple because they generate many things.
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.
@NixOS/haskell
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.
All the checks proposed here are (slightly) incorrect. That using meta.platforms
is not possible is a slight oversight, namely that (shallowly) evaluating passthru
(which mkDerivation
needs to do) forces binDistUsed
. I'll correct that separately and then it should be possible again to use meta.platforms
.
The correct check for shellcheck
's availability is lib.meta.availableOn stdenv.buildPlatform shellcheck.compiler
which checks if the compiler we would use to build shellcheck
itself is available. I need to warn you though that meta.platforms
is imperfect, so there may be some edge cases, but I'm not sure if this applies to any platforms stdenv
supports as a build platform. This is improved in #212188.
Edit: #246805
d0fe112
to
fed2c13
Compare
Ping |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
fed2c13
to
2c5990f
Compare
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.
Note that the current approach will stop working after #243619. Seems like we will need to invent a completely new approach for this sort of thing then (i.e. some way to check if GHC can be bootstrapped in the context of the current package set(s)).
#339272 will break this. Probably no other option than using |
Description of changes
GHC (=> shellcheck) isn't supported on some platforms (such as risc-v)
but we still want to use writeShellApplication on those platforms
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)