nix-init: init at 0.1.0

This commit is contained in:
figsoda 2023-01-28 15:19:25 -05:00
parent 379dfe6a9f
commit 44187e2a04
3 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,60 @@
{ lib
, rustPlatform
, fetchFromGitHub
, installShellFiles
, makeWrapper
, pkg-config
, zstd
, stdenv
, darwin
, nix
, nurl
, callPackage
, spdx-license-list-data
}:
rustPlatform.buildRustPackage rec {
pname = "nix-init";
version = "0.1.0";
src = fetchFromGitHub {
owner = "nix-community";
repo = "nix-init";
rev = "v${version}";
hash = "sha256-97aAlH03H8xTVhp45FwecNb7i/ZUtJG9OOYBx8Sf+YI=";
};
cargoHash = "sha256-uvn1cP6aIxfPKG/QLtHBd6fHjl7JNRtkZ4gIG2tpHVg=";
nativeBuildInputs = [
installShellFiles
makeWrapper
pkg-config
];
buildInputs = [
zstd
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
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
'';
GEN_ARTIFACTS = "artifacts";
NIX_LICENSES = callPackage ./license.nix { };
SPDX_LICENSE_LIST_DATA = "${spdx-license-list-data.json}/json/details";
ZSTD_SYS_USE_PKG_CONFIG = true;
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 ];
};
}

View File

@ -0,0 +1,23 @@
# vendored from src/licenses.nix
{ lib, writeText }:
let
inherit (builtins) concatLists concatStringsSep length;
inherit (lib) flip licenses mapAttrsToList optional;
inserts = concatLists
(flip mapAttrsToList licenses
(k: v: optional (v ? spdxId) '' xs.insert("${v.spdxId}", "${k}");''));
in
writeText "license.rs" ''
fn get_nix_licenses() -> rustc_hash::FxHashMap<&'static str, &'static str> {
let mut xs = std::collections::HashMap::with_capacity_and_hasher(
${toString (length inserts)},
Default::default(),
);
${concatStringsSep "\n " inserts}
xs
}
''

View File

@ -37644,6 +37644,8 @@ with pkgs;
nix-info = callPackage ../tools/nix/info { };
nix-info-tested = nix-info.override { doCheck = true; };
nix-init = callPackage ../tools/nix/nix-init { };
nix-index-unwrapped = callPackage ../tools/package-management/nix-index {
inherit (darwin.apple_sdk.frameworks) Security;
};