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

Deprecate use of stdenv.lib across Nixpkgs #108938

Closed
siraben opened this issue Jan 10, 2021 · 32 comments · Fixed by #111284
Closed

Deprecate use of stdenv.lib across Nixpkgs #108938

siraben opened this issue Jan 10, 2021 · 32 comments · Fixed by #111284
Labels
3.skill: sprintable A larger issue which is split into distinct actionable tasks 6.topic: best practices
Milestone

Comments

@siraben
Copy link
Member

siraben commented Jan 10, 2021

Carry over discussion from IRC #nixos-dev and #108934. Inspired by the doc change in c06b2b3 recommending top-level usage of lib over stdenv.lib, we want to reduce confusion for newcomers and unnecessary complexity by making lib the canonical way to access the Nix library. We may still want to keep stdenv.lib to not break external code, and place a trace or similar at its definition site.

$ nix-shell -p ag --run 'ag "stdenv\.lib" -l | wc -l'
11783

There are over 11000 files where stdenv.lib occurs at least once. Beyond splitting this change across multiple PRs, in what ways can the change be automated?

Pinging @alyssais @Profpatsch @FRidh @Atemu @ehmry

@siraben siraben added the 3.skill: sprintable A larger issue which is split into distinct actionable tasks label Jan 10, 2021
@siraben
Copy link
Member Author

siraben commented Jan 10, 2021

In the short term, we could add this check in ofbrorg and nix-hammering, and update any examples in the documentation to reduce new usage of stdenv.lib.

@TredwellGit
Copy link
Member

$ rg '[sS]tdenv.*\.lib' | wc -l
45311

Don't forget things like stdenvNoCC.lib and clangStdenv.lib.

@siraben
Copy link
Member Author

siraben commented Jan 10, 2021

Ah. So 45K occurrences across 11.8K files.

$ ag '[sS]tdenv.*\.lib' -l | wc -l
11853

@Profpatsch
Copy link
Member

toplevel is done #108934

@Profpatsch
Copy link
Member

the xorg dep generator also doesn’t put it in its output anymore #108935

@Profpatsch
Copy link
Member

Profpatsch commented Jan 10, 2021

meta = with stdenv.lib; trewide rewrite in #108978

@Profpatsch
Copy link
Member

doc changes in #108979

@cole-h cole-h mentioned this issue Jan 11, 2021
10 tasks
@siraben siraben mentioned this issue Jan 11, 2021
10 tasks
Profpatsch added a commit to Profpatsch/nixpkgs that referenced this issue Jan 11, 2021
Part of: NixOS#108938

Changing the documentation to not refer to stdenv.lib is the first
step to make people use it directly.
Profpatsch added a commit that referenced this issue Jan 11, 2021
Part of: #108938

Changing the documentation to not refer to stdenv.lib is the first
step to make people use it directly.
Profpatsch added a commit to Profpatsch/nixpkgs that referenced this issue Jan 11, 2021
Part of: NixOS#108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
Profpatsch added a commit that referenced this issue Jan 11, 2021
Part of: #108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
@alyssais
Copy link
Member

alyssais commented Jan 11, 2021 via email

@siraben
Copy link
Member Author

siraben commented Jan 11, 2021

Nice! What scripts did you use to generate it?

@alyssais
Copy link
Member

alyssais commented Jan 11, 2021 via email

ggreif added a commit to dfinity/motoko that referenced this issue Jul 24, 2021
undortunatrely I still see
```
trace: Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `lib` instead. For more information see NixOS/nixpkgs#108938
```
nbp pushed a commit to mozilla/nixpkgs-mozilla that referenced this issue Jul 29, 2021
Fixes this message on nixpkgs-unstable:

trace: Warning: `stdenv.lib` is deprecated and will be removed in the
next release. Please use `pkgs.lib` instead. For more information see
NixOS/nixpkgs#108938

Signed-off-by: Anders Kaseorg <[email protected]>
mergify bot pushed a commit to dfinity/motoko that referenced this issue Aug 9, 2021
This  is in preparation for the `stdenv.lib` removal. Strangely, the warning persists. I assume it comes from some expressions that are outside of this repo and we only transitively pull in.

This is the warning we eventually want to fix:
```
trace: Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `lib` instead. For more information see NixOS/nixpkgs#108938
```
tazjin added a commit to tazjin/nix-diff that referenced this issue Sep 24, 2021
Gabriella439 pushed a commit to Gabriella439/nix-diff that referenced this issue Sep 24, 2021
@samuela
Copy link
Member

samuela commented Oct 5, 2021

I just got this warning while doing a home-manager switch, but it doesn't give me any info as to which derivations are at fault. Is there any way we could improve the message to identify culprits?

@jtojnar
Copy link
Member

jtojnar commented Oct 5, 2021

@samuela With config.nixpkgs.allowAliases = false;, you should get a hard error which will allow you to use --show-trace. Or you can update Nixpkgs, since it has been removed in d2c9f81.

pSub added a commit to pSub/pascal-wittmann.de that referenced this issue Oct 26, 2021
DeeUnderscore added a commit to DeeUnderscore/dub2nix that referenced this issue Nov 14, 2021
stdenv.lib is deprecated in nixpkgs

see NixOS/nixpkgs#108938
siraben added a commit to siraben/oxide that referenced this issue Jan 7, 2022
- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources
siraben added a commit to siraben/oxide that referenced this issue Jan 7, 2022
- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources
siraben added a commit to siraben/oxide that referenced this issue Jan 7, 2022
- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources
siraben added a commit to siraben/oxide that referenced this issue Jan 7, 2022
- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources
siraben added a commit to siraben/oxide that referenced this issue Jan 10, 2022
- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources
siraben added a commit to siraben/oxide that referenced this issue Feb 1, 2022
- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources
booniepepper pushed a commit to booniepepper/haskell.nix that referenced this issue Feb 4, 2022
Fixes:

Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `pkgs.lib` instead. For more information see NixOS/nixpkgs#108938
Profpatsch pushed a commit to Profpatsch/cabal2nix that referenced this issue Mar 7, 2022
On Nixpkgs, the work[1] for deprecating stdenv.lib has started.
This patch updates the generator, existing documentation and tests to
use the top-level lib attribute to access the standard library, instead
of stdenv.lib.

[1]: NixOS/nixpkgs#108938
sternenseemann pushed a commit to NixOS/cabal2nix that referenced this issue Jul 21, 2022
In Nixpkgs stdenv.lib is deprecated[1] and may be removed in the future.

[1]: NixOS/nixpkgs#108938
Eeems added a commit to Eeems-Org/oxide that referenced this issue Jan 25, 2023
* Nix maintenance

- stdenv.lib has been deprecated (NixOS/nixpkgs#108938)
- replace linuxkit-nix (unmaintained) with nix-docker
- updated niv sources

* Add Nix workflow

* Adjust Nix build to use oxide target

* Use auth token for cachix

Co-authored-by: Nathaniel van Diepen <[email protected]>
resonant-riches added a commit to ChorusOne/azimuth-cli that referenced this issue Feb 20, 2024
Running `nix develop` prints a warning message about using this
deprecated attribute.

See NixOS/nixpkgs#108938
resonant-riches added a commit to ChorusOne/azimuth-cli that referenced this issue Feb 21, 2024
Running `nix develop` prints a warning message about using this
deprecated attribute.

See NixOS/nixpkgs#108938

Update oldNixpkgs to the latest working version
resonant-riches added a commit to ChorusOne/azimuth-cli that referenced this issue Feb 21, 2024
Running `nix develop` prints a warning message about using this
deprecated attribute.

See NixOS/nixpkgs#108938

Update oldNixpkgs to the latest working version
resonant-riches added a commit to ChorusOne/azimuth-cli that referenced this issue Mar 1, 2024
Running `nix develop` prints a warning message about using this
deprecated attribute.

See NixOS/nixpkgs#108938

Update oldNixpkgs to the latest working version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.skill: sprintable A larger issue which is split into distinct actionable tasks 6.topic: best practices
Projects
None yet
Development

Successfully merging a pull request may close this issue.