mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-19 02:24:30 +00:00

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" ```
61 lines
1.7 KiB
Nix
61 lines
1.7 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchFromGitHub
|
|
, fetchpatch
|
|
, cmake
|
|
, ninja
|
|
, installCompatHeader ? false
|
|
, installLegacyHeaders ? false
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "gsl-lite";
|
|
version = "0.41.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "gsl-lite";
|
|
repo = "gsl-lite";
|
|
rev = "v${version}";
|
|
hash = "sha256-cuuix302bVA7dWa7EJoxJ+otf1rSzjWQK8DHJsVkQio=";
|
|
};
|
|
|
|
patches = [
|
|
(fetchpatch {
|
|
name = "type-limits-cast-fix.patch";
|
|
url = "https://github.com/gsl-lite/gsl-lite/commit/13475be0e5bf5f464c398f4a07ef5c7684bc57c5.patch";
|
|
hash = "sha256-rSz7OBmgQ3KcQ971tS3Z3QNC+U4XmrPjgmuOyG7J6Bo=";
|
|
})
|
|
];
|
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
|
|
|
cmakeFlags = lib.mapAttrsToList
|
|
(name: value: ''-DGSL_LITE_OPT_${name}:BOOL=${if value then "ON" else "OFF"}'')
|
|
{
|
|
INSTALL_COMPAT_HEADER = installCompatHeader;
|
|
INSTALL_LEGACY_HEADERS = installLegacyHeaders;
|
|
BUILD_TESTS = doCheck;
|
|
};
|
|
|
|
# Building tests is broken on Darwin.
|
|
doCheck = !stdenv.hostPlatform.isDarwin;
|
|
|
|
meta = with lib; {
|
|
description = ''
|
|
A single-file header-only version of ISO C++ Guidelines Support Library
|
|
(GSL) for C++98, C++11, and later
|
|
'';
|
|
longDescription = ''
|
|
gsl-lite is a single-file header-only implementation of the C++ Core
|
|
Guidelines Support Library originally based on Microsoft GSL and adapted
|
|
for C++98, C++03. It also works when compiled as C++11, C++14, C++17,
|
|
C++20.
|
|
'';
|
|
homepage = "https://github.com/gsl-lite/gsl-lite";
|
|
changelog = "https://github.com/gsl-lite/gsl-lite/blob/${src.rev}/CHANGES.txt";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ azahi ];
|
|
platforms = platforms.all;
|
|
};
|
|
}
|