1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs synced 2024-10-19 03:47:13 -04:00
nixpkgs/pkgs/tools/nix/nix-init/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

101 lines
2.1 KiB
Nix

{ lib
, writeText
, rustPlatform
, fetchFromGitHub
, curl
, installShellFiles
, pkg-config
, bzip2
, libgit2
, openssl
, zlib
, zstd
, stdenv
, darwin
, spdx-license-list-data
, nix
, nurl
}:
let
get-nix-license = import ./get_nix_license.nix {
inherit lib writeText;
};
in
rustPlatform.buildRustPackage rec {
pname = "nix-init";
version = "0.3.2";
src = fetchFromGitHub {
owner = "nix-community";
repo = "nix-init";
rev = "v${version}";
hash = "sha256-0RLEPVtYnwYH+pMnpO0/Evbp7x9d0RMobOVAqwgMJz4=";
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes."cargo-0.82.0" = "sha256-1G14vLW3FhLxOWGxuHXcWgb+XXS1vOOyQYKVbrJWlmI=";
};
nativeBuildInputs = [
curl
installShellFiles
pkg-config
];
buildInputs = [
bzip2
curl
libgit2
openssl
zlib
zstd
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Security
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
darwin.apple_sdk.frameworks.CoreFoundation
];
buildNoDefaultFeatures = true;
checkFlags = [
# requires internet access
"--skip=lang::rust::tests"
];
postPatch = ''
mkdir -p data
ln -s ${get-nix-license} data/get_nix_license.rs
'';
preBuild = ''
cargo run -p license-store-cache \
-j $NIX_BUILD_CORES --frozen \
data/license-store-cache.zstd ${spdx-license-list-data.json}/json/details
'';
postInstall = ''
installManPage artifacts/nix-init.1
installShellCompletion artifacts/nix-init.{bash,fish} --zsh artifacts/_nix-init
'';
env = {
GEN_ARTIFACTS = "artifacts";
LIBGIT2_NO_VENDOR = 1;
NIX = lib.getExe nix;
NURL = lib.getExe nurl;
ZSTD_SYS_USE_PKG_CONFIG = true;
};
meta = with lib; {
description = "Command line tool to generate Nix packages from URLs";
mainProgram = "nix-init";
homepage = "https://github.com/nix-community/nix-init";
changelog = "https://github.com/nix-community/nix-init/blob/${src.rev}/CHANGELOG.md";
license = licenses.mpl20;
maintainers = with maintainers; [ figsoda ];
};
}