-
Notifications
You must be signed in to change notification settings - Fork 3
/
default.nix
69 lines (69 loc) · 2.5 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ pkgs ? import <nixpkgs> { } }:
let
pkgs_with_overlay = pkgs.appendOverlays ([
(import (builtins.fetchTarball
"https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
(self: super: {
rust-bindgen = super.rust-bindgen.overrideAttrs (_: { doCheck = false; });
rust-stable = super.rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ];
extensions = [ "rust-src" ];
};
rustPlatform = (super.makeRustPlatform {
rustc = self.rust-stable;
cargo = self.rust-stable;
stdenv = self.llvmPackages.libcxxStdenv;
}) // {
importCargoLock = pkgs.callPackage ./nix/import-cargo-lock.nix {
cargo = self.rust-stable;
};
};
# workaround for nixpkgs 23.11 for HOST_CC when invoking cargo.
rust = if super.rust ? envVars then
super.rust // { envVars = super.rust.envVars // { setEnv = ""; }; }
else
super.rust;
rust-nightly = self.rust-bin.nightly."2023-04-21".default.override {
targets = [ "wasm32-unknown-emscripten" "wasm32-wasi" ];
extensions = [ "rust-src" ];
};
v8 = self.v8_8_x;
zlib-static =
(super.pkgsStatic.zlib.override ({ splitStaticOutput = true; })).static;
lzma-static = super.pkgsStatic.lzma;
libunwind-static = super.pkgsStatic.libunwind;
openssl-static = super.pkgsStatic.openssl.override ({ static = true; });
libiconv-static = super.pkgsStatic.libiconvReal.override {
enableStatic = true;
enableShared = false;
};
})
]);
in let
pkgs = pkgs_with_overlay;
sources = import ./nix/sources.nix { inherit (pkgs) fetchgit; };
motoko = import ./motoko.nix {
inherit pkgs;
sources = { inherit (sources) motoko libtommath musl-wasi; };
};
ic = import ./ic.nix {
inherit pkgs sources;
moc = motoko.moc;
};
utils = import ./utils.nix { inherit pkgs sources; };
sdk = import ./sdk.nix {
inherit pkgs;
src = sources.sdk;
};
depsOf = drvs:
pkgs.mkShell {
name = "deps-env";
nobuildPhase = "touch $out";
buildInputs = builtins.concatMap (drv: drv.buildInputs) drvs;
nativeBuildInputs = builtins.concatMap (drv: drv.nativeBuildInputs) drvs;
};
ic-no-shell = ic // { shell = null; };
projects = { inherit motoko ic ic-no-shell sdk utils; };
in with builtins;
let derivations = pkgs.lib.lists.fold (a: b: a // b) { } (attrValues projects);
in projects // derivations // { deps = depsOf (attrValues derivations); }