Skip to content
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.warn: Use or behave like builtins.warn #306481

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

roberth
Copy link
Member

@roberth roberth commented Apr 24, 2024

Description of changes

Base lib.warn on builtins.warn when available.
Behave like it when it's not available.

A variation of trace, but

  • with the correct log level

  • no ANSI codes in expressions

  • can be debugged without stopping for actual trace calls (ie intentional "info level" or trace logging).

  • logs warnings without trace: in front of it

  • follows the Nix color scheme.

Alternative to, and

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@roberth roberth requested a review from infinisil as a code owner April 24, 2024 09:19
@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Apr 24, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Apr 24, 2024
@infinisil infinisil marked this pull request as draft April 24, 2024 20:39
lib/trivial.nix Outdated Show resolved Hide resolved
@roberth roberth marked this pull request as ready for review July 5, 2024 11:50
@Aleksanaa
Copy link
Member

image

The color seems not the same?

lib/trivial.nix Outdated Show resolved Hide resolved
@Aleksanaa
Copy link
Member

After editing it to 35 and moving the hidden character (\x1b? Just copied it, forgot how to input it) in front of ${msg}

Old nix:

image

New nix:

image

roberth and others added 2 commits July 16, 2024 15:54
Co-authored-by: Aleksana <[email protected]>
This aligns with Nix and makes it more readable.
The prefix still stands out.
@roberth roberth force-pushed the lib-builtins-warn branch from b4d7556 to 7d4a9a5 Compare July 16, 2024 13:56
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation is looking good to me, but the docs of the function need to be updated a bit.

- Bring up to date
- Give meaning to the metavariables
- Use italics for metavariables (just like the Nix manual)
- Don't abbreviate
  - No hard feelings, Val.
@roberth
Copy link
Member Author

roberth commented Jul 23, 2024

docs

Done:

  • Bring up to date
  • Give meaning to the metavariables
  • Use italics for metavariables (just like the Nix manual)
  • Don't abbreviate
    • No hard feelings, Val.

@roberth roberth requested a review from infinisil July 23, 2024 10:51
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@roberth roberth merged commit db77328 into NixOS:master Jul 23, 2024
23 checks passed
@roberth
Copy link
Member Author

roberth commented Jul 23, 2024

Thanks!

@infinisil infinisil deleted the lib-builtins-warn branch July 23, 2024 16:34
@infinisil infinisil restored the lib-builtins-warn branch July 23, 2024 16:34
@infinisil
Copy link
Member

Weird to see the "Delete branch" button on somebody else's PR, instinctively clicked it, not sure if you want to keep it around :P

@roberth roberth deleted the lib-builtins-warn branch July 23, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants