-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
doc: improve documentation for writeText* functions #277171
Conversation
Suggested improvements at https://gist.github.com/mcdonc/978487ae51fa1cf4d305bbebcdf40f86 |
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.
Nice improvement, left some suggestions, but LGTM.
Note that the output of `writeText` is a derivation, which will coerce to the store path of its output, | ||
which will not match the path of the actual file if `destination` is set. | ||
|
||
Many more functions wrap `writeTextFile`, including `writeText`, `writeTextDir`, `writeScript`, and `writeScriptBin`. |
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 know this is already like this in the manual, but instead of including, could we list them all?
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.
Oh no! This documentation has been duplicated across
doc/build-helpers/trivial-build-helpers.chapter.md
, andpkgs/build-support/trivial-builders/default.nix
We should either use nixdoc (like lib/
), or replace all the doc comments by # See doc/build-helpers/trivial-build-helpers.chapter.md
.
There's no point doing anything without addressing this duplication first.
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.
There's no point doing anything without addressing this duplication first.
Maybe I should tone that down, but it is a very very serious problem nonetheless.
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.
As much as I don't want to throw this over the fence, I'm not sure I have it in me right now to handle a large scale cleanup like this. If anyone's interested, feel free to take over.
destination = "some/subpath/my-cool-script"; | ||
|
||
# (Optional) Commands to run after generating the file, e.g. lints. | ||
# Defaults to ""; |
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.
# Defaults to ""; | |
# Defaults to "". |
# (Optional) Commands to run after generating the file, e.g. lints. | ||
# Defaults to ""; | ||
checkPhase = '' | ||
${pkgs.shellcheck}/bin/shellcheck $out/some/subpath/my-cool-script |
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 use destination
here to avoid duplication?
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.
Make sure to test it if you do.
|
||
# (Optional) Whether to prefer building locally, even if faster remote builders are available. | ||
# Defaults to true for similar reasons. | ||
preferLocalBuild = false; |
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.
So does this take precedence on the above, so that if e.g. allowSubstitutes = true && preferLocalBuild = true
, the build is kept local?
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 refer to the Nix manual and not copy the explanation.
It may be subject to change and documenting it here would suggest that it's unique.
``` | ||
|
||
Note that the output of `writeText` is a derivation, which will coerce to the store path of its output, | ||
which will not match the path of the actual file if `destination` is set. |
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.
An example could be nice here IMO.
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.
Description of changes
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.