nixpkgs/pkgs/by-name/tu/tup/package.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

77 lines
2.3 KiB
Nix

{ lib, stdenv, fetchFromGitHub, fuse3, macfuse-stubs, pkg-config, sqlite, pcre2 }:
let
fuse = if stdenv.hostPlatform.isDarwin then macfuse-stubs else fuse3;
in stdenv.mkDerivation rec {
pname = "tup";
version = "0.8";
outputs = [ "bin" "man" "out" ];
src = fetchFromGitHub {
owner = "gittup";
repo = "tup";
rev = "v${version}";
hash = "sha256-biVR932wHiUG56mvXoKWFzrzpkclbW9RWM4vY1+OMZ0=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ fuse pcre2 sqlite ];
patches = [ ./fusermount-setuid.patch ];
configurePhase = ''
substituteInPlace src/tup/link.sh --replace '`git describe' '`echo ${version}'
cat << EOF > tup.config
CONFIG_CC=${stdenv.cc.targetPrefix}cc
CONFIG_AR=${stdenv.cc.targetPrefix}ar
CONFIG_TUP_USE_SYSTEM_SQLITE=y
EOF
'';
# Regular tup builds require fusermount to have suid, which nix cannot
# currently provide in a build environment, so we bootstrap and use 'tup
# generate' instead
buildPhase = ''
runHook preBuild
./build.sh
./build/tup init
./build/tup generate script.sh
./script.sh
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -D tup -t $bin/bin/
install -D tup.1 -t $man/share/man/man1/
runHook postInstall
'';
setupHook = ./setup-hook.sh;
meta = with lib; {
description = "Fast, file-based build system";
mainProgram = "tup";
longDescription = ''
Tup is a file-based build system for Linux, OSX, and Windows. It inputs a list
of file changes and a directed acyclic graph (DAG), then processes the DAG to
execute the appropriate commands required to update dependent files. Updates are
performed with very little overhead since tup implements powerful build
algorithms to avoid doing unnecessary work. This means you can stay focused on
your project rather than on your build system.
'';
homepage = "https://gittup.org/tup/";
license = licenses.gpl2;
maintainers = with maintainers; [ ehmry ];
platforms = platforms.unix;
# TODO: Remove once nixpkgs uses newer SDKs that supports '*at' functions.
# Probably MacOS SDK 10.13 or later. Check the current version in
# ../../../../os-specific/darwin/apple-sdk/default.nix
#
# https://github.com/gittup/tup/commit/3697c74
broken = stdenv.hostPlatform.isDarwin;
};
}