Unverified Commit 016a7ad7 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

nh: some refactoring (#400493)

parents 7d82762e 0dbffe62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ The pre-existing `services.ankisyncd` has been marked deprecated and will be dro

- [Netbird](https://netbird.io), an open-source VPN management platform, now has a self-hosted management server. Available as [services.netbird.server](#opt-services.netbird.server.enable).

- [nh](https://github.com/viperML/nh), yet another Nix CLI helper. Available as [programs.nh](#opt-programs.nh.enable).
- [nh](https://github.com/nix-community/nh), yet another Nix CLI helper. Available as [programs.nh](#opt-programs.nh.enable).

- [oink](https://github.com/rlado/oink), a dynamic DNS client for Porkbun. Available as [services.oink](#opt-services.oink.enable).

+19 −14
Original line number Diff line number Diff line
@@ -9,22 +9,22 @@
  nix-update-script,
  nvd,
  nix-output-monitor,
  buildPackages,
}:
let
  version = "3.6.0";
  runtimeDeps = [
    nvd
    nix-output-monitor
  ];
in
rustPlatform.buildRustPackage {
  inherit version;
rustPlatform.buildRustPackage (finalAttrs: {
  pname = "nh";
  version = "3.6.0";

  src = fetchFromGitHub {
    owner = "viperML";
    owner = "nix-community";
    repo = "nh";
    tag = "v${version}";
    tag = "v${finalAttrs.version}";
    hash = "sha256-k8rz5RF1qi7RXzQYWGbw5pJRNRFIdX85SIYN+IHiVL4=";
  };

@@ -39,14 +39,19 @@ rustPlatform.buildRustPackage {
    darwin.apple_sdk.frameworks.SystemConfiguration
  ];

  preFixup = ''
  preFixup = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
    in
    ''
      mkdir completions
    $out/bin/nh completions --shell bash > completions/nh.bash
    $out/bin/nh completions --shell zsh > completions/nh.zsh
    $out/bin/nh completions --shell fish > completions/nh.fish
      ${emulator} $out/bin/nh completions --shell bash > completions/nh.bash
      ${emulator} $out/bin/nh completions --shell zsh > completions/nh.zsh
      ${emulator} $out/bin/nh completions --shell fish > completions/nh.fish

      installShellCompletion completions/*
  '';
    ''
  );

  postFixup = ''
    wrapProgram $out/bin/nh \
@@ -60,7 +65,7 @@ rustPlatform.buildRustPackage {

  meta = {
    description = "Yet another nix cli helper";
    homepage = "https://github.com/viperML/nh";
    homepage = "https://github.com/nix-community/nh";
    license = lib.licenses.eupl12;
    mainProgram = "nh";
    maintainers = with lib.maintainers; [
@@ -68,4 +73,4 @@ rustPlatform.buildRustPackage {
      viperML
    ];
  };
}
})