Unverified Commit 7989d92a authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

nh,nh-unwrapped: split into two packages (#463477)

parents d7491eef d3cc6458
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
{
  stdenv,
  lib,
  rustPlatform,
  installShellFiles,
  fetchFromGitHub,
  nix-update-script,
  buildPackages,
}:
rustPlatform.buildRustPackage (finalAttrs: {
  pname = "nh-unwrapped";
  version = "4.2.0";

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = "nh";
    tag = "v${finalAttrs.version}";
    hash = "sha256-6n5SVO8zsdVTD691lri7ZcO4zpqYFU8GIvjI6dbxkA8=";
  };

  strictDeps = true;

  nativeBuildInputs = [
    installShellFiles
  ];

  postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
    in
    ''
      mkdir completions

      for shell in bash zsh fish; do
        NH_NO_CHECKS=1 ${emulator} $out/bin/nh completions $shell > completions/nh.$shell
      done

      installShellCompletion completions/*

      cargo xtask man --out-dir gen
      installManPage gen/nh.1
    ''
  );

  cargoHash = "sha256-cxZsePgraYevuYQSi3hTU2EsiDyn1epSIcvGi183fIU=";

  passthru.updateScript = nix-update-script { };

  env.NH_REV = finalAttrs.src.tag;

  meta = {
    changelog = "https://github.com/nix-community/nh/blob/${finalAttrs.version}/CHANGELOG.md";
    description = "Yet another nix cli helper";
    homepage = "https://github.com/nix-community/nh";
    license = lib.licenses.eupl12;
    mainProgram = "nh";
    maintainers = with lib.maintainers; [
      NotAShelf
      viperML
    ];
  };
})
+10 −55
Original line number Diff line number Diff line
{
  stdenv,
  lib,
  rustPlatform,
  installShellFiles,
  symlinkJoin,
  makeBinaryWrapper,
  fetchFromGitHub,
  nix-update-script,
  nh-unwrapped,
  nix-output-monitor,
  buildPackages,
}:
let
  unwrapped = nh-unwrapped;
  runtimeDeps = [
    nix-output-monitor
  ];
in
rustPlatform.buildRustPackage (finalAttrs: {
symlinkJoin {
  pname = "nh";
  version = "4.2.0";
  inherit (unwrapped) version meta;

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = "nh";
    tag = "v${finalAttrs.version}";
    hash = "sha256-6n5SVO8zsdVTD691lri7ZcO4zpqYFU8GIvjI6dbxkA8=";
  };

  strictDeps = true;
  paths = [
    unwrapped
  ];

  nativeBuildInputs = [
    installShellFiles
    makeBinaryWrapper
  ];

  postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
    in
    ''
      mkdir completions

      for shell in bash zsh fish; do
        NH_NO_CHECKS=1 ${emulator} $out/bin/nh completions $shell > completions/nh.$shell
      done

      installShellCompletion completions/*

      cargo xtask man --out-dir gen
      installManPage gen/nh.1
    ''
  );

  postFixup = ''
  postBuild = ''
    wrapProgram $out/bin/nh \
      --prefix PATH : ${lib.makeBinPath runtimeDeps}
  '';

  cargoHash = "sha256-cxZsePgraYevuYQSi3hTU2EsiDyn1epSIcvGi183fIU=";

  passthru.updateScript = nix-update-script { };

  env.NH_REV = finalAttrs.src.tag;

  meta = {
    changelog = "https://github.com/nix-community/nh/blob/${finalAttrs.version}/CHANGELOG.md";
    description = "Yet another nix cli helper";
    homepage = "https://github.com/nix-community/nh";
    license = lib.licenses.eupl12;
    mainProgram = "nh";
    maintainers = with lib.maintainers; [
      NotAShelf
      viperML
    ];
  };
})
}