aboutsummaryrefslogtreecommitdiff
path: root/nix/candelabra.nix
blob: 926d6eb5f7d51693e83b52ca11dbd432135969e4 (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
33
34
35
36
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
    makeWrapper ${rustCrate}/bin/candelabra-cli $out/bin/candelabra-cli \
      --set CANDELABRA_SRC_DIR ${pkgs.lib.sourceByRegex ../src [
      ".*crates"
      ".*racket_specs.*"
      ".*crates/library.*"
      ".*crates/benchmarker.*"
      ".*rust-toolchain.toml.*"
      ".*Cargo.toml.*"
      ".*Cargo.lock.*"
    ]} \
        --prefix PATH : ${pkgs.callPackage ./racket-env.nix inputs}/bin \
        --prefix PATH : ${toolchain}/bin \
        --prefix PATH : ${pkgs.gcc}/bin;
  ''