Created
March 29, 2019 13:56
-
-
Save andir/c637c78450e6ae7815d98e7fa08d45dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ attrPaths ? [ | |
"cargo-download" | |
# "cargo-vendor" | |
"carnix" | |
] }: | |
let | |
pkgs = import ../../../default.nix { }; | |
getSource = pkg: pkg.overrideAttrs (_: { | |
dependencies = []; | |
phases = [ "unpackPhase" "installPhase" ]; | |
installPhase = '' | |
ls -la | |
cp -rv $(pwd) $out | |
''; | |
}); | |
# FIXME: use proper paths e.g. ["rust" "cargo-uodate"] for rust.cargo-update | |
cargoPackages = map (n: pkgs."${n}") attrPaths; | |
generateCarnix = pkg: pkgs.writeScript "carnix-${pkg.name}" '' | |
set -ex | |
PATH="${pkgs.carnix}/bin:$PATH" | |
out=$1 | |
WRKDIR=$(mktemp -d) | |
cp -rv ${getSource pkg}/* $WRKDIR | |
cd $WRKDIR | |
test ! -e Cargo.lock && cargo update | |
carnix generate-nix --src . | |
cp crates-io.nix $out | |
''; | |
in with pkgs.lib; pkgs.runCommand "update-crates-io" { | |
nativeBuildInputs = [ pkgs.carnix ]; | |
shellHook = '' | |
set -ex | |
TMP=$(mktemp -d) | |
OUTDIR=$(pwd) | |
cd $TMP | |
${concatMapStringsSep "\n" (p: '' | |
${generateCarnix p} $TMP/${p.name}.nix | |
'') cargoPackages} | |
carnix merge $TMP/*.nix > $OUTDIR/crates-io.nix | |
exit 0 | |
''; | |
} "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment