naersk/default.nix

143 lines
4.2 KiB
Nix
Raw Normal View History

2019-06-22 13:18:25 +00:00
# TODO:
# cargo puts all built libs in 'target/(release|debug)/deps'. The format is
# something like 'libfoo-<some hash>.(rlib|rmeta)'. Would be straightforward to
# just copy these instead of rebuilding everything from scratch.
#
#
2019-06-18 14:55:38 +00:00
with rec
{ sources = import ./nix/sources.nix;
_pkgs = import sources.nixpkgs {};
};
2019-06-13 11:26:19 +00:00
2019-06-18 14:55:38 +00:00
{ lib ? _pkgs.lib
, runCommand ? _pkgs.runCommand
, symlinkJoin ? _pkgs.symlinkJoin
, stdenv ? _pkgs.stdenv
, writeText ? _pkgs.writeText
, llvmPackages ? _pkgs.llvmPackages
2019-06-25 15:36:22 +00:00
, jq ? _pkgs.jq
2019-06-18 14:55:38 +00:00
, darwin ? _pkgs.darwin
2019-06-13 11:26:19 +00:00
, rustPackages ?
with sources;
2019-06-18 14:55:38 +00:00
(_pkgs.callPackage rust-nightly {}).rust {inherit (rust-nightly) date; }
2019-06-13 11:26:19 +00:00
}:
2019-06-25 15:36:22 +00:00
with
{ libb = import ./lib.nix { inherit lib; }; };
2019-06-13 11:26:19 +00:00
# Crate building
with rec
2019-06-25 15:36:22 +00:00
{
buildPackage = src: attrs:
with
{ defaultAttrs =
{ inherit
llvmPackages
jq
runCommand
rustPackages
lib
darwin
writeText
stdenv
symlinkJoin ;
} ;
2019-06-13 11:26:19 +00:00
};
2019-06-25 15:36:22 +00:00
import ./build.nix src (defaultAttrs // attrs);
2019-06-18 10:58:08 +00:00
};
2019-06-20 09:04:08 +00:00
with
{ crates =
{ lorri = buildPackage sources.lorri
{ override = _oldAttrs:
{ BUILD_REV_COUNT = 1;
RUN_TIME_CLOSURE = "${sources.lorri}/nix/runtime.nix";
};
2019-06-21 09:06:28 +00:00
doCheck = false;
2019-06-20 09:04:08 +00:00
};
2019-06-18 14:55:38 +00:00
2019-06-20 09:04:08 +00:00
ripgrep-all = buildPackage sources.ripgrep-all {};
rustfmt = buildPackage sources.rustfmt {};
};
};
2019-06-26 08:32:46 +00:00
{ inherit buildPackage crates;
2019-06-20 09:04:08 +00:00
test_lorri = runCommand "lorri" { buildInputs = [ crates.lorri ]; }
"lorri --help && touch $out";
2019-06-18 12:42:26 +00:00
test_talent-plan-1 = buildPackage "${sources.talent-plan}/rust/projects/project-1" {};
test_talent-plan-2 = buildPackage "${sources.talent-plan}/rust/projects/project-2" {};
2019-06-21 15:32:52 +00:00
test_talent-plan-3 = buildPackage
"${sources.talent-plan}/rust/projects/project-3"
2019-06-26 08:59:29 +00:00
{ doCheck = false; };
2019-06-18 12:42:26 +00:00
# TODO: support for git deps
#test_talent-plan-4 = buildPackage "${sources.talent-plan}/rust/projects/project-4" {};
#test_talent-plan-5 = buildPackage "${sources.talent-plan}/rust/projects/project-5" {};
2019-06-18 13:40:44 +00:00
# TODO: figure out executables from src/bin/*.rs
2019-06-20 09:04:08 +00:00
test_ripgrep-all = runCommand "ripgrep-all"
{ buildInputs = [ crates.ripgrep-all ]; }
"touch $out";
2019-06-18 12:42:26 +00:00
# TODO: Nix error:
# error: while parsing a TOML string at default.nix:80:25:
# Bare key 'cfg(all(target_env = "musl", target_pointer_width = "64"))'
# cannot contain whitespace at line 64
# and this is the culprit:
# https://github.com/BurntSushi/ripgrep/blob/d1389db2e39802d5e04dc7b902fd2b1f9f615b01/Cargo.toml#L64
2019-06-22 12:43:30 +00:00
# TODO: update Nix: https://github.com/NixOS/nix/pull/2902
2019-06-18 12:42:26 +00:00
#test_ripgrep = buildPackage sources.ripgrep {};
# TODO: (workspace)
2019-06-18 13:40:44 +00:00
# error: while parsing a TOML string at ...:115:25:
# Bare key 'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'
# cannot contain whitespace at line 53
2019-06-18 12:42:26 +00:00
#test_rust = buildPackage sources.rust {};
2019-06-18 13:40:44 +00:00
# Unable to update https://github.com/...
2019-06-18 12:42:26 +00:00
#test_noria = buildPackage sources.noria {};
2019-06-18 13:40:44 +00:00
2019-06-21 15:32:52 +00:00
# TODO: fix submodules
test_lucet =
with rec
{ lucetSpec =
{ inherit (sources.lucet) owner repo rev;
fetchSubmodules = true;
sha256 = "1vwz7gijq4pcs2dvaazmzcdyb8d64y5qss6s4j2wwigsgqmpfdvs";
} ;
lucetGit = _pkgs.fetchFromGitHub lucetSpec;
};
buildPackage lucetGit
{ nativeBuildInputs = [ _pkgs.cmake _pkgs.python3 ] ;
2019-06-26 08:59:29 +00:00
doCheck = false;
cargoBuild =
lib.concatStringsSep " "
2019-06-21 15:32:52 +00:00
[ "cargo build"
"-p lucetc"
"-p lucet-runtime"
"-p lucet-runtime-internals"
"-p lucet-module-data"
2019-06-26 08:59:29 +00:00
];
2019-06-21 15:32:52 +00:00
};
2019-06-18 13:40:44 +00:00
test_rustlings = buildPackage sources.rustlings {};
2019-06-18 14:47:13 +00:00
# TODO: walk through bins
2019-06-18 14:55:38 +00:00
test_rustfmt = runCommand "rust-fmt"
2019-06-20 09:04:08 +00:00
{ buildInputs = [ crates.rustfmt ]; }
2019-06-18 14:47:13 +00:00
''
rustfmt --help
cargo-fmt --help
touch $out
'';
2019-06-24 16:04:34 +00:00
#test_git-dep = buildPackage (lib.cleanSource ./test/git-dep)
#{ override = oldAttrs:
#{};
#};
2019-06-18 12:42:26 +00:00
}