nix flakes support #85
70
flake.nix
70
flake.nix
@ -13,7 +13,7 @@
|
|||||||
url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml";
|
url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml";
|
||||||
sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c=";
|
sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c=";
|
||||||
};
|
};
|
||||||
targets = [];
|
rustTargets = [];
|
||||||
rustChannelOfTargets = _channel: _date: targets:
|
rustChannelOfTargets = _channel: _date: targets:
|
||||||
(pkgs.lib.rustLib.fromManifestFile rustManifest {
|
(pkgs.lib.rustLib.fromManifestFile rustManifest {
|
||||||
inherit (pkgs) stdenv lib fetchurl patchelf;
|
inherit (pkgs) stdenv lib fetchurl patchelf;
|
||||||
@ -21,7 +21,7 @@
|
|||||||
inherit targets;
|
inherit targets;
|
||||||
extensions = ["rust-src"];
|
extensions = ["rust-src"];
|
||||||
};
|
};
|
||||||
rust = rustChannelOfTargets "nightly" null targets;
|
rust = rustChannelOfTargets "nightly" null rustTargets;
|
||||||
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
|
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
|
||||||
rustc = rust;
|
rustc = rust;
|
||||||
cargo = rust;
|
cargo = rust;
|
||||||
@ -213,15 +213,65 @@
|
|||||||
doCheck = false;
|
doCheck = false;
|
||||||
dontFixup = true;
|
dontFixup = true;
|
||||||
};
|
};
|
||||||
# ==== fsbl/
|
# ==== fsbl/default
|
||||||
|
cargoSha256Experiments = "1bvffgr4588bbkjwnhim8rvkjvbnajaiv7hc98b19sr8kb7rcj63";
|
||||||
|
|||||||
|
cargoSha256SZL = "13022ssk6s2fgxmmh5msbx01fzcmk2cj95fjpxcsmfy14k9wd77l";
|
||||||
|
|
||||||
|
build-crate = name: crate: features: cargoSha256: rustPlatform.buildRustPackage rec {
|
||||||
|
name = "${crate}";
|
||||||
|
|
||||||
|
src = builtins.filterSource (path: type:
|
||||||
|
baseNameOf path != "target"
|
||||||
|
) ./.;
|
||||||
|
inherit cargoSha256;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cargo-xbuild pkgs.llvmPackages_9.clang-unwrapped ];
|
||||||
|
buildPhase = ''
|
||||||
|
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"
|
||||||
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||||
|
pushd ${crate}
|
||||||
|
cargo xbuild --release --frozen \
|
||||||
|
--no-default-features \
|
||||||
|
--features=${features}
|
||||||
|
popd
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out $out/nix-support
|
||||||
|
cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
|
||||||
|
echo file binary-dist $out/${name}.elf >> $out/nix-support/hydra-build-products
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
dontFixup = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
fsblCrates = {
|
||||||
|
zc706-fsbl = fsbl { board = "zc706"; };
|
||||||
|
# any others?
|
||||||
|
};
|
||||||
|
|
||||||
|
targetCrates = target: {
|
||||||
|
"${target}-experiments" = build-crate "${target}-experiments" "experiments" "target_${target}" cargoSha256Experiments;
|
||||||
|
"${target}-szl" = build-crate "${target}-szl" "szl" "target_${target}" cargoSha256SZL;
|
||||||
|
};
|
||||||
|
targets = ["zc706" "coraz7" "redpitaya" "kasli_soc"];
|
||||||
|
allTargetCrates = (builtins.foldl' (results: target:
|
||||||
|
results // targetCrates target
|
||||||
|
) {} targets);
|
||||||
|
szl = pkgs.runCommand "szl" {} (builtins.foldl' (commands: target:
|
||||||
|
let
|
||||||
|
szlResult = builtins.getAttr "${target}-szl" allTargetCrates;
|
||||||
|
in
|
||||||
|
commands + "ln -s ${szlResult}/szl.elf $out/szl-${target}.elf\n"
|
||||||
|
) "mkdir $out\n" targets);
|
||||||
|
|
||||||
|
allOutputs = allTargetCrates // fsblCrates // { inherit cargo-xbuild szl; };
|
||||||
|
|
||||||
in {
|
in {
|
||||||
sb10q
commented
You can just use You can just use ``rec`` above and do ``hydraJobs = packages.x86_64-linux`` I believe.
|
|||||||
packages.x86_64-linux = {
|
packages.x86_64-linux = allOutputs;
|
||||||
|
|
||||||
};
|
hydraJobs = allOutputs;
|
||||||
|
|
||||||
hydraJobs = {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
devShell.x86_64-linux = pkgs.mkShell {
|
devShell.x86_64-linux = pkgs.mkShell {
|
||||||
name = "zynq-rs-dev-shell";
|
name = "zynq-rs-dev-shell";
|
||||||
@ -236,6 +286,6 @@
|
|||||||
llvmPackages_9.clang-unwrapped
|
llvmPackages_9.clang-unwrapped
|
||||||
mkbootimage ];
|
mkbootimage ];
|
||||||
};
|
};
|
||||||
defaultPackage.x86_64-linux = fsbl { board = "zc706"; };
|
defaultPackage.x86_64-linux = allTargetCrates.zc706-szl;
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user
Still there?