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

treewide: replace stdenv.is with stdenv.hostPlatform.is #341407

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

Artturin
Copy link
Member

@Artturin Artturin commented Sep 12, 2024

Approve or thumbs up to show that you approve of the idea, or request changes on the first file to discuss why you don't think it's a good idea.

Join https://matrix.to/#/#stdenv:nixos.org to discuss

I'll reset to master and rerun the commands before merge.
Further replacements can be done in the PR where the warnings are added.
The commits can be added to .git-blame-ignore-revs in a separate PR

treewide: replace stdenv.is with stdenv.hostPlatform.is

In preparation for the deprecation of stdenv.isX.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of stdenv.isDarwin will get in the way

One example of why this is bad and especially affects compiler packages
#343059

There are too many files to go through manually but a treewide should
get users thinking when they see a hostPlatform.isX in a place where it
doesn't make sense.

fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd  "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd  "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd  "originalStdenv.is" "originalStdenv.hostPlatform.is"

The rebuilds are due to src ./. or similar

image

https://gist.github.com/Artturin/4cc1e73fc612cb7a79459a9bb6bc27a3

@github-actions github-actions bot added 6.topic: python 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: haskell 6.topic: qt/kde 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: rust 6.topic: golang 6.topic: ruby 6.topic: vim 6.topic: erlang 6.topic: ocaml 6.topic: nodejs 6.topic: lua 6.topic: agda "A dependently typed programming language / interactive theorem prover" 6.topic: nim Nim programing language 6.topic: LXQt The Lightweight Qt Desktop Environment 6.topic: Enlightenment DE The Enlightenment Desktop Environment 6.topic: mate The MATE Desktop Environment 6.topic: vscode 6.topic: flakes The experimental Nix feature 6.topic: lib The Nixpkgs function library 6.topic: zig 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: julia 6.topic: php 6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: dotnet Language: .NET 6.topic: flutter labels Sep 12, 2024
@Ericson2314
Copy link
Member

Excited this is finally happening. Thanks @Artturin!

In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
`treewide: replace stdenv.is with stdenv.hostPlatform.is`
@emilazy
Copy link
Member

emilazy commented Sep 24, 2024

Reproduced the commits locally, ofborg has reported low build numbers on previous rebases, seems impossible to race ofborg and merge conflicts. Merging now and will take responsibility for the revert if ofborg throws up a scary result.

@emilazy emilazy merged commit 492e917 into NixOS:master Sep 24, 2024
10 of 11 checks passed
msfjarvis added a commit to msfjarvis/dotfiles that referenced this pull request Sep 26, 2024
sternenseemann added a commit that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
imincik added a commit to imincik/geospatial-nix that referenced this pull request Sep 27, 2024
msfjarvis added a commit to msfjarvis/dotfiles that referenced this pull request Sep 30, 2024
@nim65s nim65s mentioned this pull request Oct 27, 2024
13 tasks
Rhys-T added a commit to Rhys-T/nur-packages that referenced this pull request Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: agda "A dependently typed programming language / interactive theorem prover" 6.topic: dotnet Language: .NET 6.topic: emacs Text editor 6.topic: Enlightenment DE The Enlightenment Desktop Environment 6.topic: erlang 6.topic: flakes The experimental Nix feature 6.topic: flutter 6.topic: golang 6.topic: haskell 6.topic: julia 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: lua 6.topic: LXQt The Lightweight Qt Desktop Environment 6.topic: mate The MATE Desktop Environment 6.topic: nim Nim programing language 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: nodejs 6.topic: ocaml 6.topic: php 6.topic: python 6.topic: qt/kde 6.topic: ruby 6.topic: rust 6.topic: vim 6.topic: vscode 6.topic: zig 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants