nixpkgs/pkgs/by-name/sn/snyk/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

52 lines
1.2 KiB
Nix

{
lib,
buildNpmPackage,
fetchFromGitHub,
stdenv,
testers,
snyk,
}:
let
version = "1.1293.1";
in
buildNpmPackage {
pname = "snyk";
inherit version;
src = fetchFromGitHub {
owner = "snyk";
repo = "cli";
rev = "refs/tags/v${version}";
hash = "sha256-Vgt9h0LLIC5I9NZZKKWD9b1xnNOSkxApLxSGf2C0ODk=";
};
npmDepsHash = "sha256-1YtyQg14vj85KtOXP93vLkqIMmT+8DAJdG/ql+1ooyU=";
postPatch = ''
substituteInPlace package.json \
--replace-fail '"version": "1.0.0-monorepo"' '"version": "${version}"'
'';
env.NIX_CFLAGS_COMPILE =
# Fix error: no member named 'aligned_alloc' in the global namespace
lib.optionalString (
stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64
) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
npmBuildScript = "build:prod";
passthru.tests.version = testers.testVersion {
package = snyk;
};
meta = {
description = "Scans and monitors projects for security vulnerabilities";
homepage = "https://snyk.io";
changelog = "https://github.com/snyk/cli/releases/tag/v${version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ momeemt ];
mainProgram = "snyk";
};
}