ofborg/default.nix
Andreas Rammhold 804bb34181 Move from crate2nix to buildRustPackage based on the Cargo.lock
Nixpkgs recently gained the ability to fetch cargo dependencies based on
the Cargo.lock file which means we can get rid of all the generated Nix
expressions. The only downside to that is that we are now building
everything in one go and do not have the semi-incremental builds as we
had before.
2021-07-07 12:19:54 -07:00

63 lines
1.4 KiB
Nix

{ pkgs ? import ./nix {
overlays = [ (import ./nix/overlay.nix) ];
}
}:
let
pkg = pkgs.rustPlatform.buildRustPackage {
name = "ofborg";
src = pkgs.nix-gitignore.gitignoreSource [] ./.;
nativeBuildInputs = with pkgs; [
pkgconfig
pkgs.rustPackages.clippy
];
buildInputs = with pkgs; [
openssl
];
preBuild = ''
cargo clippy
'';
doCheck = false; # Tests require access to a /nix/ and a nix daemon
checkInputs = with pkgs; [
nix
];
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hubcaps-0.3.16" = "1p7rn8y71fjwfag65437gz7a56pysz9n69smaknvblyxpjdzmh4d";
};
};
};
in
{
inherit pkg;
ofborg.rs = pkgs.runCommand "ofborg-rs-symlink-compat" { src = pkg; } ''
mkdir -p $out/bin
for f in $(find $src -type f); do
bn=$(basename "$f")
ln -s "$f" "$out/bin/$bn"
# Rust 1.n? or Cargo starting outputting bins with dashes
# instead of underscores ... breaking all the callers.
if echo "$bn" | grep -q "-"; then
ln -s "$f" "$out/bin/$(echo "$bn" | tr '-' '_')"
fi
done
test -e $out/bin/builder
test -e $out/bin/github_comment_filter
test -e $out/bin/github_comment_poster
test -e $out/bin/log_message_collector
test -e $out/bin/evaluation_filter
'';
ofborg.php = import ./php { inherit pkgs; };
}