-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
lib.path.append: init #208887
lib.path.append: init #208887
Conversation
f3a0229
to
263735c
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.
Otherwise looks alright.
263735c
to
680c1f0
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.
Just a few comments on cosmetics. Good stuff, and really compact thanks to a solid basis.
8b00eae
to
50d1898
Compare
Made some minor changes to the documentation. Using "path value type" when it could be ambiguous or being more precise is useful. And I'm not using any markdown syntax in the docs because it's not rendered at all. I looked into it a bit, but it's not very trivial to get it to render. |
I think it's fine to write markdown even if it's not rendered, but for now it really doesn't matter. |
50d1898
to
e4352f7
Compare
lib/path/default.nix
Outdated
*/ | ||
append = base: subpath: | ||
assert assertMsg (isPath base) '' | ||
lib.path.append: The first argument is of type ${builtins.typeOf base}, but a path was expected''; |
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'm putting ''
at the end of the string here and not on a newline because we don't want to print an extra newline (throw
adds one). Apparently it doesn't matter though, because throw
removes all trailing newlines anyways:
nix-repl> throw "hello\n\n\n\n\n"
error: hello
nix-repl>
I don't want to rely on that because it's undocumented and perhaps a bug. While I'm at it, there's a bug where throw ""
doesn't print the red error:
prefix:
nix-repl> throw ""
nix-repl>
e4352f7
to
1c2587c
Compare
I guess a good policy for now is: "Use markdown syntax when it doesn't make it significantly harder to read without being rendered". I'm using that here now |
1c2587c
to
312a8df
Compare
312a8df
to
b7f7c25
Compare
Now consistently using |
b7f7c25
to
3a10261
Compare
- Use isValid when possible instead of subpathInvalidReason: NixOS#209099 (comment) - Add documentation to function arguments - Use newlines for error messages: NixOS#208887 (comment) - Add short comments for the unit test groups: NixOS#208887 (comment) - Slight formatting improvement for laws: NixOS#209099 (comment)
3a10261
to
e4fc836
Compare
Now even more consistency with the other PRs. I think this is ready to be merged |
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 always, amazing work. ✨ Thanks a lot for your patience with the reviews.
This function can be used to append strings to Nix path values in a safe way.
e4fc836
to
eac2538
Compare
@roberth Does it also look good to you? If so I'd appreciate a mergin :) |
I'll go ahead and merge this myself since @roberth mentioned already in the beginning that it looks good :) |
- Use isValid when possible instead of subpathInvalidReason: NixOS/nixpkgs#209099 (comment) - Add documentation to function arguments - Use newlines for error messages: NixOS/nixpkgs#208887 (comment) - Add short comments for the unit test groups: NixOS/nixpkgs#208887 (comment) - Slight formatting improvement for laws: NixOS/nixpkgs#209099 (comment)
- Use isValid when possible instead of subpathInvalidReason: NixOS/nixpkgs#209099 (comment) - Add documentation to function arguments - Use newlines for error messages: NixOS/nixpkgs#208887 (comment) - Add short comments for the unit test groups: NixOS/nixpkgs#208887 (comment) - Slight formatting improvement for laws: NixOS/nixpkgs#209099 (comment)
- Use isValid when possible instead of subpathInvalidReason: NixOS#209099 (comment) - Add documentation to function arguments - Use newlines for error messages: NixOS#208887 (comment) - Add short comments for the unit test groups: NixOS#208887 (comment) - Slight formatting improvement for laws: NixOS#209099 (comment)
- Use isValid when possible instead of subpathInvalidReason: NixOS/nixpkgs#209099 (comment) - Add documentation to function arguments - Use newlines for error messages: NixOS/nixpkgs#208887 (comment) - Add short comments for the unit test groups: NixOS/nixpkgs#208887 (comment) - Slight formatting improvement for laws: NixOS/nixpkgs#209099 (comment)
Description of changes
This function can be used to append strings to Nix path values in a safe way, it's like
<path> + ("/" + <string>)
but safer. Relates to other work in the path library effort.This work is sponsored by Antithesis ✨
Things done