mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 03:43:06 +00:00
e0464e4788
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" ```
66 lines
1.5 KiB
Nix
66 lines
1.5 KiB
Nix
{ lib
|
|
, rustPlatform
|
|
, fetchFromGitHub
|
|
, cmake
|
|
, installShellFiles
|
|
, pkg-config
|
|
, zstd
|
|
, stdenv
|
|
, CoreFoundation
|
|
, libresolv
|
|
, Security
|
|
, git
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
pname = "onefetch";
|
|
version = "2.21.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "o2sh";
|
|
repo = pname;
|
|
rev = version;
|
|
hash = "sha256-KQs7b+skXQhHbfHIJkgowNY2FB6oS2V8TQFdkmElC/k=";
|
|
};
|
|
|
|
cargoHash = "sha256-gKA1MMahoaDFia8LR33GG3jRttZzHwpUpFawlCQcy7g=";
|
|
|
|
cargoPatches = [
|
|
# enable pkg-config feature of zstd
|
|
./zstd-pkg-config.patch
|
|
];
|
|
|
|
nativeBuildInputs = [ cmake installShellFiles pkg-config ];
|
|
|
|
buildInputs = [ zstd ]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreFoundation libresolv Security ];
|
|
|
|
nativeCheckInputs = [
|
|
git
|
|
];
|
|
|
|
preCheck = ''
|
|
git init
|
|
git config user.name nixbld
|
|
git config user.email nixbld@example.com
|
|
git add .
|
|
git commit -m test
|
|
'';
|
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
installShellCompletion --cmd onefetch \
|
|
--bash <($out/bin/onefetch --generate bash) \
|
|
--fish <($out/bin/onefetch --generate fish) \
|
|
--zsh <($out/bin/onefetch --generate zsh)
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Git repository summary on your terminal";
|
|
homepage = "https://github.com/o2sh/onefetch";
|
|
changelog = "https://github.com/o2sh/onefetch/blob/v${version}/CHANGELOG.md";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ Br1ght0ne figsoda kloenk ];
|
|
mainProgram = "onefetch";
|
|
};
|
|
}
|