Unverified Commit 0dbffe62 authored by Acid Bong's avatar Acid Bong
Browse files

nh: allow generating completions while cross-compiling

parent 1910d945
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
  nix-update-script,
  nvd,
  nix-output-monitor,
  buildPackages,
}:
let
  runtimeDeps = [
@@ -38,14 +39,19 @@ rustPlatform.buildRustPackage (finalAttrs: {
    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 \