add Nix build files
This commit is contained in:
parent
1995defa9d
commit
ba2256d0d5
32
default.nix
Normal file
32
default.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{ # Use master branch of the overlay by default
|
||||
mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
|
||||
rustManifest ? builtins.fetchurl "https://static.rust-lang.org/dist/channel-rust-nightly.toml"
|
||||
}:
|
||||
|
||||
let
|
||||
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
||||
in
|
||||
with pkgs;
|
||||
let
|
||||
rustPlatform = recurseIntoAttrs (callPackage ./nix/rustPlatform.nix {
|
||||
inherit rustManifest;
|
||||
});
|
||||
stabilizer = callPackage ./nix/stabilizer.nix { inherit rustPlatform; };
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "stabilizer-dist";
|
||||
buildInputs = [ stabilizer ];
|
||||
src = ./.;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase =
|
||||
let
|
||||
firmwareBinary = "$out/lib/stabilizer.elf";
|
||||
in ''
|
||||
mkdir -p $out/bin $out/lib $out/nix-support
|
||||
|
||||
ln -s ${stabilizer}/lib/stabilizer ${firmwareBinary}
|
||||
|
||||
echo file binary-dist ${firmwareBinary} >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
}
|
11552
nix/channel-rust-nightly.toml
Normal file
11552
nix/channel-rust-nightly.toml
Normal file
File diff suppressed because it is too large
Load Diff
49
nix/fetchcargo.nix
Normal file
49
nix/fetchcargo.nix
Normal file
@ -0,0 +1,49 @@
|
||||
{ stdenv, cacert, git, cargo, cargo-vendor }:
|
||||
{ name, src, sha256 }:
|
||||
let
|
||||
# `src` restricted to the two files that define dependencies
|
||||
cargoOnlySrc = stdenv.mkDerivation {
|
||||
name = "${name}-cargo";
|
||||
inherit src;
|
||||
phases = "installPhase";
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp ${src}/Cargo.{toml,lock} $out/
|
||||
mkdir $out/src
|
||||
touch $out/src/main.rs
|
||||
'';
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "${name}-vendor";
|
||||
nativeBuildInputs = [ cacert git cargo cargo-vendor ];
|
||||
src = cargoOnlySrc;
|
||||
|
||||
phases = "unpackPhase patchPhase installPhase";
|
||||
|
||||
installPhase = ''
|
||||
if [[ ! -f Cargo.lock ]]; then
|
||||
echo
|
||||
echo "ERROR: The Cargo.lock file doesn't exist"
|
||||
echo
|
||||
echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change"
|
||||
echo "when the registry is updated."
|
||||
echo
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||
|
||||
cargo vendor
|
||||
|
||||
cp -ar vendor $out
|
||||
'';
|
||||
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
outputHash = sha256;
|
||||
|
||||
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
|
||||
preferLocalBuild = true;
|
||||
}
|
23
nix/rustPlatform.nix
Normal file
23
nix/rustPlatform.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{ recurseIntoAttrs, stdenv, lib,
|
||||
makeRustPlatform,
|
||||
fetchurl, patchelf,
|
||||
rustManifest ? ./channel-rust-nightly.toml
|
||||
}:
|
||||
|
||||
let
|
||||
targets = [
|
||||
"thumbv7em-none-eabihf"
|
||||
];
|
||||
rustChannel =
|
||||
lib.rustLib.fromManifestFile rustManifest {
|
||||
inherit stdenv fetchurl patchelf;
|
||||
};
|
||||
rust =
|
||||
rustChannel.rust.override {
|
||||
inherit targets;
|
||||
};
|
||||
in
|
||||
makeRustPlatform {
|
||||
rustc = rust;
|
||||
cargo = rust;
|
||||
}
|
45
nix/stabilizer.nix
Normal file
45
nix/stabilizer.nix
Normal file
@ -0,0 +1,45 @@
|
||||
{ stdenv, rustPlatform, cacert, git, cargo-vendor }:
|
||||
|
||||
with rustPlatform;
|
||||
let
|
||||
sha256 = "1m4cxf6c4lh28xv4iagp20ni97cya1f12yg58q0m733qahk8gncb";
|
||||
fetchcargo = import ./fetchcargo.nix {
|
||||
inherit stdenv cacert git cargo-vendor;
|
||||
inherit (rust) cargo;
|
||||
};
|
||||
stabilizerDeps = fetchcargo {
|
||||
name = "stabilizer";
|
||||
src = ../.;
|
||||
inherit sha256;
|
||||
};
|
||||
in
|
||||
|
||||
buildRustPackage rec {
|
||||
name = "stabilizer";
|
||||
version = "0.0.0";
|
||||
|
||||
src = ../.;
|
||||
cargoSha256 = sha256;
|
||||
|
||||
buildInputs = [ stabilizerDeps ];
|
||||
patchPhase = ''
|
||||
cat >> .cargo/config <<EOF
|
||||
[source.crates-io]
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source.vendored-sources]
|
||||
directory = "${stabilizerDeps}"
|
||||
EOF
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||
cargo build --release
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib
|
||||
cp target/thumbv7em-none-eabihf/release/stabilizer $out/lib/
|
||||
'';
|
||||
}
|
15
release.nix
Normal file
15
release.nix
Normal file
@ -0,0 +1,15 @@
|
||||
# For running on Hydra
|
||||
{ pkgs ? import <nixpkgs> {},
|
||||
rustManifest ? ./nix/channel-rust-nightly.toml
|
||||
}:
|
||||
|
||||
with pkgs;
|
||||
let
|
||||
stabilizer = callPackage ./default.nix {
|
||||
inherit rustManifest;
|
||||
mozillaOverlay = import <mozillaOverlay>;
|
||||
};
|
||||
in
|
||||
{
|
||||
build = lib.hydraJob stabilizer;
|
||||
}
|
Loading…
Reference in New Issue
Block a user