nixpkgs/pkgs/tools/nix/nix-init/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
2.0 KiB
Nix
Raw Normal View History

2023-01-28 20:19:25 +00:00
{ lib
, writeText
2023-01-28 20:19:25 +00:00
, rustPlatform
, fetchFromGitHub
, curl
2023-01-28 20:19:25 +00:00
, installShellFiles
, makeBinaryWrapper
2023-01-28 20:19:25 +00:00
, pkg-config
, bzip2
, libgit2_1_5
, openssl
, zlib
2023-01-28 20:19:25 +00:00
, zstd
, stdenv
, darwin
, spdx-license-list-data
2023-01-28 20:19:25 +00:00
, nix
, nurl
}:
let
get-nix-license = import ./get-nix-license.nix {
inherit lib writeText;
};
in
2023-01-28 20:19:25 +00:00
rustPlatform.buildRustPackage rec {
pname = "nix-init";
version = "0.2.3";
2023-01-28 20:19:25 +00:00
src = fetchFromGitHub {
owner = "nix-community";
repo = "nix-init";
rev = "v${version}";
hash = "sha256-QxGPBGCCjbQ1QbJNoW0dwQS/srwQ0hBR424zmcqdjI8=";
2023-01-28 20:19:25 +00:00
};
cargoHash = "sha256-+Vj3TqNxMgaUmhzCgSEGl58Jh1PLsC6q/DfDbfg2mmo=";
2023-01-28 20:19:25 +00:00
nativeBuildInputs = [
curl
2023-01-28 20:19:25 +00:00
installShellFiles
makeBinaryWrapper
2023-01-28 20:19:25 +00:00
pkg-config
];
buildInputs = [
bzip2
curl
libgit2_1_5
openssl
zlib
2023-01-28 20:19:25 +00:00
zstd
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
] ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
darwin.apple_sdk.frameworks.CoreFoundation
2023-01-28 20:19:25 +00:00
];
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
'';
2023-01-28 20:19:25 +00:00
postInstall = ''
wrapProgram $out/bin/nix-init \
--prefix PATH : ${lib.makeBinPath [ nix nurl ]}
installManPage artifacts/nix-init.1
installShellCompletion artifacts/nix-init.{bash,fish} --zsh artifacts/_nix-init
'';
env = {
GEN_ARTIFACTS = "artifacts";
ZSTD_SYS_USE_PKG_CONFIG = true;
};
2023-01-28 20:19:25 +00:00
meta = with lib; {
description = "Command line tool to generate Nix packages from URLs";
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 ];
};
}