Commit e0464e47 authored by Artturin's avatar Artturin
Browse files

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
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"
```
parent aaa7fb58
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@
      checks = forAllSystems (system: {
        tarball = jobs.${system}.tarball;
        # Exclude power64 due to "libressl is not available on the requested hostPlatform" with hostPlatform being power64
      } // lib.optionalAttrs (self.legacyPackages.${system}.stdenv.isLinux && !self.legacyPackages.${system}.targetPlatform.isPower64) {
      } // lib.optionalAttrs (self.legacyPackages.${system}.stdenv.hostPlatform.isLinux && !self.legacyPackages.${system}.targetPlatform.isPower64) {
        # Test that ensures that the nixosSystem function can accept a lib argument
        # Note: prefer not to extend or modify `lib`, especially if you want to share reusable modules
        #       alternatives include: `import` a file, or put a custom library in an option or in `_module.args.<libname>`
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}" {
  nativeBuildInputs = [
    nix
    pkgs.gitMinimal
  ] ++ lib.optional pkgs.stdenv.isLinux pkgs.inotify-tools;
  ] ++ lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.inotify-tools;
  strictDeps = true;
} ''
  datadir="${nix}/share"
+1 −1
Original line number Diff line number Diff line
@@ -13,5 +13,5 @@ mkShell {
      clippy
      rustfmt
    ]
    ++ lib.optional stdenv.isDarwin pkgs.libiconv;
    ++ lib.optional stdenv.hostPlatform.isDarwin pkgs.libiconv;
}
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ let
        ${lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
        <!-- Pre-generated font caches -->
        <cachedir>${cache}</cachedir>
        ${lib.optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) ''
        ${lib.optionalString (pkgs.stdenv.hostPlatform.isx86_64 && cfg.cache32Bit) ''
          <cachedir>${cache32}</cachedir>
        ''}
        ''}
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ in {

  config = {
    assertions = [
      { assertion = isNull config.environment.ldso32 || pkgs.stdenv.isx86_64;
      { assertion = isNull config.environment.ldso32 || pkgs.stdenv.hostPlatform.isx86_64;
        message = "Option environment.ldso32 currently only works on x86_64.";
      }
    ];
@@ -44,7 +44,7 @@ in {
        "d /${libDir} 0755 root root - -"
        "L+ /${libDir}/${ldsoBasename} - - - - ${config.environment.ldso}"
      ]
    ) ++ optionals pkgs.stdenv.isx86_64 (
    ) ++ optionals pkgs.stdenv.hostPlatform.isx86_64 (
      if isNull config.environment.ldso32 then [
        "r /${libDir32}/${ldsoBasename32} - - - - -"
      ] else [
Loading