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.
This commit is contained in:
parent
179f1fc018
commit
804bb34181
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -19,7 +19,7 @@ jobs:
|
|||
git config --global user.email "ofborg@example.com"
|
||||
git config --global user.name "ofborg"
|
||||
- name: checkPhase
|
||||
run: nix-shell --pure --run checkPhase
|
||||
run: nix-shell --pure --run "cargo test"
|
||||
|
||||
nix-build:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"hubcaps 0.3.16 (git+https://github.com/grahamc/hubcaps.git#5e656ba35ab4ee74aa72b3b5c3a62e1bf351ff6a)": "1p7rn8y71fjwfag65437gz7a56pysz9n69smaknvblyxpjdzmh4d"
|
||||
}
|
65
default.nix
65
default.nix
|
@ -1,22 +1,44 @@
|
|||
{ pkgs ? import ./nix {
|
||||
overlays = [ (import ./nix/overlay.nix) ];
|
||||
}
|
||||
, ofborgCrates ? import ./Cargo.nix {
|
||||
inherit pkgs;
|
||||
release = pkgs.stdenv.isDarwin;
|
||||
}
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (ofborgCrates.workspaceMembers) ofborg-simple-build ofborg;
|
||||
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 ofborgCrates;
|
||||
inherit pkg;
|
||||
|
||||
ofborg.simple-build = ofborg-simple-build.build;
|
||||
|
||||
ofborg.rs = pkgs.runCommand "ofborg-rs-symlink-compat" { src = ofborg.build; } ''
|
||||
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")
|
||||
|
@ -34,31 +56,6 @@ in
|
|||
test -e $out/bin/github_comment_poster
|
||||
test -e $out/bin/log_message_collector
|
||||
test -e $out/bin/evaluation_filter
|
||||
|
||||
# Verify that the outpath contains the version number matching the
|
||||
# Cargo.toml
|
||||
if ! grep -q 'version = "${ofborg.build.crateVersion}"' ${./ofborg/Cargo.toml}; then
|
||||
cat <<EOF
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Build failed because you bumped the Cargo
|
||||
version without regenerating the Cargo.nix.
|
||||
|
||||
Run:
|
||||
|
||||
|
||||
|
||||
nix-shell --run ./nix/update-crates.sh
|
||||
|
||||
|
||||
and commit those changes.
|
||||
|
||||
|
||||
EOF
|
||||
fi
|
||||
'';
|
||||
|
||||
ofborg.php = import ./php { inherit pkgs; };
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -E "with import ./nix {}; mkShell { nativeBuildInputs = [ cacert cargo (import (builtins.fetchTarball https://github.com/kolloch/crate2nix/archive/0.9.0.tar.gz) {}) ]; }"
|
||||
#!nix-shell -i bash
|
||||
set -e
|
||||
|
||||
cargo fetch --locked
|
||||
crate2nix generate
|
||||
|
|
Loading…
Reference in a new issue