nixpkgs/pkgs/tools/system/fakeroot/default.nix
Artturin e0464e4788 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"
```
2024-09-25 00:04:37 +03:00

88 lines
2.5 KiB
Nix

{ lib
, coreutils
, stdenv
, fetchFromGitLab
, fetchpatch
, getopt
, libcap
, gnused
, nixosTests
, testers
, autoreconfHook
, po4a
}:
stdenv.mkDerivation (finalAttrs: {
version = "1.32.2";
pname = "fakeroot";
src = fetchFromGitLab {
owner = "clint";
repo = "fakeroot";
rev = "upstream/${finalAttrs.version}";
domain = "salsa.debian.org";
hash = "sha256-j1qSMPNCtAxClqYqWkRNQmtxkitYi7g/9KtQ5XqcX3w=";
};
patches = lib.optionals stdenv.hostPlatform.isLinux [
./einval.patch
# patches needed for musl libc, borrowed from alpine packaging.
# it is applied regardless of the environment to prevent patchrot
(fetchpatch {
name = "do-not-redefine-id_t.patch";
url = "https://git.alpinelinux.org/aports/plain/main/fakeroot/do-not-redefine-id_t.patch?id=f68c541324ad07cc5b7f5228501b5f2ce4b36158";
sha256 = "sha256-i9PoWriSrQ7kLZzbvZT3Kq1oXzK9mTyBqq808BGepOw=";
})
(fetchpatch {
name = "fakeroot-no64.patch";
url = "https://git.alpinelinux.org/aports/plain/main/fakeroot/fakeroot-no64.patch?id=f68c541324ad07cc5b7f5228501b5f2ce4b36158";
sha256 = "sha256-NCDaB4nK71gvz8iQxlfaQTazsG0SBUQ/RAnN+FqwKkY=";
})
] ++ [
(fetchpatch {
name = "addendum-charset-conversion.patch";
url = "https://salsa.debian.org/clint/fakeroot/-/commit/b769fb19fd89d696a5e0fd70b974f833f6a0655a.patch";
hash = "sha256-3z1g+xzlyTpa055kpsoumP/E8srDlZss6B7Fv5A0QkU=";
})
];
nativeBuildInputs = [ autoreconfHook po4a ];
buildInputs = lib.optional (!stdenv.hostPlatform.isDarwin) libcap;
postUnpack = ''
sed -i \
-e 's@getopt@${getopt}/bin/getopt@g' \
-e 's@sed@${gnused}/bin/sed@g' \
-e 's@kill@${coreutils}/bin/kill@g' \
-e 's@/bin/ls@${coreutils}/bin/ls@g' \
-e 's@cut@${coreutils}/bin/cut@g' \
source/scripts/fakeroot.in
'';
postConfigure = ''
pushd doc
po4a -k 0 --variable "srcdir=../doc/" po4a/po4a.cfg
popd
'';
passthru = {
tests = {
version = testers.testVersion {
package = finalAttrs.finalPackage;
};
# A lightweight *unit* test that exercises fakeroot and fakechroot together:
nixos-etc = nixosTests.etc.test-etc-fakeroot;
};
};
meta = {
homepage = "https://salsa.debian.org/clint/fakeroot";
description = "Give a fake root environment through LD_PRELOAD";
mainProgram = "fakeroot";
license = lib.licenses.gpl2Plus;
maintainers = [ ];
platforms = lib.platforms.unix;
};
})