-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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-support: add new hooks #370869
base: master
Are you sure you want to change the base?
build-support: add new hooks #370869
Conversation
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/request-for-comments-adding-two-new-hooks/58282/1 |
mutableHomeDirHook
mutableHomeDirHook
tmpdirAsHome
9e45c4c
to
c30ae4a
Compare
c30ae4a
to
1a6ea00
Compare
tmpdirAsHome
1a6ea00
to
48ddab5
Compare
48ddab5
to
2246ddf
Compare
2246ddf
to
e45fb8f
Compare
Will this hook also be avaliable in preConfig or some thing like this? Here is some example: nixpkgs/pkgs/by-name/af/affine/package.nix Line 109 in 1a685a9
nixpkgs/pkgs/by-name/af/affine/package.nix Line 156 in 1a685a9
|
It can actually be added to any phase hooks, so yeah. |
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 like the Idea overall.
I also have two feedback Points:
- This could be two PRs.
- For my taste the amount of documentation is not enough. Especially i wouldn like to know stuff that happens internally, like what value is. $HOME set to and when?
While I'm all for splitting PR, make sure that they have a clear scope, I really don't understand why I would need to split this one. The scope is clear, even the commits are correctly split. So I'm sorry but no, I won't split this PR in two.
OK I will improve it. |
e45fb8f
to
e8e0a8d
Compare
4823191
to
881d72c
Compare
Planning to merge this tomorrow morning, feel free to raise your voice if you believe it is a bad idea. |
I'd like to see some examples of packages helped by these hooks, at the very least. |
Here's some Github search where it would be used:
|
doc/stdenv/stdenv.chapter.md
Outdated
@@ -1375,6 +1375,26 @@ This hook only runs when compiling for Linux. | |||
|
|||
This sets `SOURCE_DATE_EPOCH` to the modification time of the most recent file. | |||
|
|||
### `add-bin-to-path.sh` {#add-bin-to-path.sh} | |||
|
|||
This setup hook adds the `./bin/` directory to the `PATH` environment variable, |
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.
This should probably at least explicitly mention it's adding $out/bin
and not $sourceRoot/bin
or whatever. Honestly, this is my big concern with this hook: it's not immediately obvious what exactly it does, and the thing it does comes with a bunch of weird caveats (what if there are multiple outputs? what if the binaries are in sbin? etc).
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.
Thank you, I just updated the documentation. Let me know if this resolves this feedback.
881d72c
to
f811073
Compare
Hello everyone,
During the holidays, I spent some time packaging Python packages and noticed that some of them require a valid and mutable home directory to build or function properly.
Currently, the default behavior of the Nix stdenv is to set the
HOME
environment variable to/homeless-shelter
, a read-only directory. While this approach is consistent, it can cause issues for packages that expect a writable home directory.After performing a treewide search in
nixpkgs
, I found approximately 500 instances whereexport HOME
is used (rg -c "export HOME" | wc -l
) and 300 whereexport PATH
is used (rg -c "export PATH" | wc -l
). These repetitive patterns inspired me to propose a solution adhering to the DRY principle.I created custom hooks,
tmpdirAsHomeHook
, which sets up a mutable home directory automatically when added tonativeBuildInputs
or another appropriate place. Additionally,addBinToPath
, which modifies thePATH
environment variable to includebin/
if available.I’d appreciate your feedback on this approach and have a few questions:
nixpkgs
?tmpdirAsHomeHook
tomutableHomeDirHook
for better clarity. What do you think?addEnvHooks "$targetOffset" addBinToPath
. I’m not entirely confident about the best way to implement this. Could you provide some guidance?Thanks for taking the time to review this. I look forward to hearing your thoughts and suggestions!
Best regards
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.