Commit 96c7d09e authored by Sergei Zimmerman's avatar Sergei Zimmerman
Browse files

flawz: fix cross-compilation

Use emulation to build man pages and completions when available.
parent eee5863a
Loading
Loading
Loading
Loading
+23 −14
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
  sqlite,
  installShellFiles,
  stdenv,
  buildPackages,
}:

rustPlatform.buildRustPackage rec {
@@ -36,15 +37,21 @@ rustPlatform.buildRustPackage rec {
    "man"
  ];

  postInstall = ''
  postInstall =
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
      flawz-mangen = "${emulator} $out/bin/flawz-mangen";
      flawz-completions = "${emulator} $out/bin/flawz-completions";
    in
    lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
      export OUT_DIR=$(mktemp -d)

      # Generate the man pages
    cargo run --bin flawz-mangen
      ${flawz-mangen}
      installManPage $OUT_DIR/flawz.1

      # Generate shell completions
    cargo run --bin flawz-completions
      ${flawz-completions}
      installShellCompletion \
        --bash $OUT_DIR/flawz.bash \
        --fish $OUT_DIR/flawz.fish \
@@ -52,6 +59,8 @@ rustPlatform.buildRustPackage rec {

      # Clean up temporary directory
      rm -rf $OUT_DIR
      # No need for these binaries to end up in the output
      rm $out/bin/flawz-{completions,mangen}
    '';

  meta = {