Skip to content

Commit

Permalink
chore: build aiken package directly
Browse files Browse the repository at this point in the history
When you build the application currently, it builds all crates and
exposes most of the directory inside of it, as well as not adding the
binary to the `$PATH`.

The `buildAndTestSubdir` flag for `buildRustPackage` fix this. It is not
documented anywhere, but it works...
  • Loading branch information
cfcosta committed Jul 24, 2023
1 parent 152e847 commit f3ad7cd
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,46 @@

buildInputs = with pkgs; [ openssl ] ++ osxDependencies;
nativeBuildInputs = with pkgs; [ pkg-config openssl.dev ];
cargoBuildFlags = [ "--package aiken" ];

src = pkgs.lib.cleanSourceWith { src = self; };
src = with pkgs;
lib.cleanSourceWith {
filter = orig_path: type:
let
path = (toString orig_path);
base = baseNameOf path;
parentDir = baseNameOf (dirOf path);

matchesSuffix = lib.any (suffix: lib.hasSuffix suffix base) [
".rs"
".toml"
];

# Cargo.toml already captured above
isCargoFile = base == "Cargo.lock";

# .cargo/config.toml already captured above
isCargoConfig = parentDir == ".cargo" && base == "config";
in type == "directory" || matchesSuffix || isCargoFile
|| isCargoConfig;
src = ./.;
};

# Tests might be impure and we shouldn't need to run them.
doCheck = false;

cargoLock.lockFile = ./Cargo.lock;

buildPhase = ''
cargo build --release
'';

installPhase = ''
find . -type f ! -executable -name "aiken" -delete
mkdir -p $out/bin
install -Dm755 target/release/aiken $out/bin
'';

meta = with pkgs.lib; {
description = "Cardano smart contract language and toolchain";
homepage = "https://github.com/aiken-lang/aiken";
Expand Down

0 comments on commit f3ad7cd

Please sign in to comment.