aboutsummaryrefslogtreecommitdiff
path: root/nix/candelabra.nix
blob: 192bf1fb1fba781dc585a7106ef23f1e1615d8d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
inputs @ {
  pkgs,
  crane,
  ...
}: let
  inherit (pkgs) system;
  toolchain = pkgs.rust-bin.fromRustupToolchain ((builtins.fromTOML (builtins.readFile ../src/rust-toolchain.toml)).toolchain // {profile = "minimal";});
  craneLib = crane.lib.${system}.overrideToolchain toolchain;

  rustCrate = craneLib.buildPackage {
    pname = "candelabra-unwrapped";
    version = "1.0.0";

    src = craneLib.cleanCargoSource (craneLib.path ../src);
    doCheck = false;
    propagatedBuildInputs = [];

    cargoExtraArgs = "-p candelabra-cli";
  };
in
  pkgs.runCommand "candelabra" {} ''
    . ${pkgs.makeWrapper}/nix-support/setup-hook
    mkdir -p $out/{bin,nix-support}
    makeWrapper ${rustCrate}/bin/candelabra $out/bin/candelabra \
      --set CANDELABRA_SRC_DIR ${pkgs.lib.sourceByRegex ../src [
      ".*crates"
      ".*racket_specs.*"
      ".*crates/library.*"
      ".*crates/benchmarker.*"
    ]}
    echo "${pkgs.callPackage ./racket-env.nix inputs} ${toolchain}" > $out/nix-support/propagated-build-inputs
  ''