Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nixpkgs 21.05 #2532

Merged
merged 38 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b6861b6
Use nixpkgs master
nomeata May 17, 2021
80559dd
Use buildDunePackage
nomeata May 17, 2021
b2560bd
Less stdenv.lib
nomeata May 17, 2021
1bfe444
Update generated nix files
nomeata May 17, 2021
13457c0
Bump to get fixes
nomeata May 18, 2021
73efb93
Merge branch 'master' of github.com:dfinity/motoko into joachim/nixpk…
nomeata May 18, 2021
2573e36
Bump nixpkgs
nomeata May 18, 2021
2ff2cdb
Bump ocamlformat
nomeata May 19, 2021
e045c54
Add nixpkgs patch
nomeata May 19, 2021
8e95c1c
More patches
nomeata May 19, 2021
4e543d9
Try building vlq differently
nomeata May 19, 2021
486d2b3
Fix vlq
nomeata May 19, 2021
d5e3399
Build vlq with buildDunePackage and dune2
nomeata May 19, 2021
4e0a8fb
Revert "Build vlq with buildDunePackage and dune2"
nomeata May 19, 2021
1f925c6
Disable static ocaml build
nomeata May 19, 2021
51bdd63
Allow requisites for now
nomeata May 19, 2021
7bc6153
Quench warning
nomeata May 19, 2021
2d89954
More warnings
nomeata May 19, 2021
9be2c85
Better error message
nomeata May 19, 2021
22da1d4
Try GHC-8.8.4
nomeata May 19, 2021
cd8993c
Actually bump to GHC-8.10.4
nomeata May 19, 2021
6ce8e61
Bump niv
nomeata May 19, 2021
4dd5f07
Fix parsing global names
nomeata May 19, 2021
37da281
Call bindgen directly
nomeata May 19, 2021
ce475be
Bump nixpkgs, patches have been applied
nomeata May 25, 2021
6bdc55f
Run formatter
nomeata May 26, 2021
13c25e3
Does this work?
nomeata May 26, 2021
c55f708
More comments
nomeata May 26, 2021
ab44bbf
Try static biuld again
nomeata May 26, 2021
12ceb29
Revert "Try static biuld again"
nomeata May 26, 2021
ba7e625
Actually follow the release branch
nomeata May 26, 2021
15770d8
Include patch from https://github.com/NixOS/nixpkgs/pull/124498
nomeata May 26, 2021
b58324e
More patches
nomeata May 26, 2021
d5af730
Set allowedRequisites again
nomeata May 26, 2021
22f10d4
Remove references to menhir
nomeata May 26, 2021
862ff72
Refresh patch
nomeata May 27, 2021
8a1d12d
Merge branch 'master' into joachim/nixpkgs-master
nomeata May 27, 2021
423062a
Apply suggestions from code review
nomeata May 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ let haskellPackages = nixpkgs.haskellPackages.override {
}; in
let
rtsBuildInputs = with nixpkgs; [
clang_10 # for native/wasm building
lld_10 # for wasm building
# pulls in clang (wrapped) and clang-10 (unwrapped)
llvmPackages_10.clang
# pulls in wasm-ld
llvmPackages_10.lld
llvmPackages_10.bintools
rustc-nightly
cargo-nightly
Expand All @@ -32,13 +34,19 @@ let
];

llvmEnv = ''
# When compiling to wasm, we want to have more control over the flags,
# so we do not use the nix-provided wrapper in clang
export WASM_CLANG="clang-10"
export WASM_LD=wasm-ld
# because we use the unwrapped clang, we have to pass in some flags/paths
# that otherwise the wrapped clang would take care for us
export WASM_CLANG_LIB="${nixpkgs.llvmPackages_10.clang-unwrapped.lib}"

# When compiling natively, we want to use `clang` (which is a nixpkgs
# provided wrapper that sets various include paths etc).
# But for some reason it does not handle building for Wasm well, so
# there we use plain clang-10. There is no stdlib there anyways.
export CLANG="${nixpkgs.clang_10}/bin/clang"
export WASM_CLANG="clang-10"
export WASM_LD=wasm-ld
'';
in

Expand Down Expand Up @@ -114,6 +122,12 @@ let ocaml_exe = name: bin: rts:
-t ${nixpkgs.darwin.CF} \
-t ${nixpkgs.libiconv} \
$out/bin/*
'' + ''
# also, there is a refernece to /nix/store/…/share/menhir/standard.mly.
# Let's remove that, too
remove-references-to \
-t ${staticpkgs.ocamlPackages.menhir} \
$out/bin/*
# sanity check
$out/bin/* --help >/dev/null
'';
Expand Down Expand Up @@ -284,7 +298,7 @@ rec {
});

qc = testDerivation {
buildInputs = [ moc /* nixpkgs.wasm */ wasmtime drun haskellPackages.qc-motoko ];
buildInputs = [ moc wasmtime drun haskellPackages.qc-motoko ];
checkPhase = ''
export LANG=C.utf8 # for haskell
qc-motoko${nixpkgs.lib.optionalString (replay != 0)
Expand Down Expand Up @@ -631,7 +645,7 @@ rec {
TOMMATHSRC = nixpkgs.sources.libtommath;
MUSLSRC = "${nixpkgs.sources.musl-wasi}/libc-top-half/musl";
MUSL_WASI_SYSROOT = musl-wasi-sysroot;
LOCALE_ARCHIVE = stdenv.lib.optionalString stdenv.isLinux "${nixpkgs.glibcLocales}/lib/locale/locale-archive";
LOCALE_ARCHIVE = nixpkgs.lib.optionalString stdenv.isLinux "${nixpkgs.glibcLocales}/lib/locale/locale-archive";
MOTOKO_BASE = base-src;
CANDID_TESTS = "${nixpkgs.sources.candid}/test";

Expand Down
35 changes: 24 additions & 11 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,45 @@ let
};
nixpkgs_src = (import sourcesnix { sourcesFile = ./sources.json; inherit pkgs; }).nixpkgs;

bootstrap-pkgs = import nixpkgs_src {
system = builtins.currentSystem;
};

nixpkgs-patched = bootstrap-pkgs.applyPatches {
name = "nixpkgs-patched";
src = nixpkgs_src;
patches = [
./patches/124498.patch
];
};

pkgs =
import nixpkgs_src {
import nixpkgs-patched {
inherit system;
overlays = [
# add nix/sources.json
(self: super: {
sources = import sourcesnix { sourcesFile = ./sources.json; pkgs = super; };
})

# add a newer version of niv
# add a newer version of niv
(self: super: {
niv = (import self.sources.niv { pkgs = super; }).niv;
})

# Selecting the ocaml version
# (self: super: { ocamlPackages = super.ocamlPackages; })

(
self: super: {
# Additional ocaml package
ocamlPackages = super.ocamlPackages // {
vlq = import ./ocaml-vlq.nix {
inherit (self) stdenv fetchFromGitHub ocaml dune;
inherit (self) stdenv fetchFromGitHub ocaml dune_1;
inherit (self.ocamlPackages) findlib;
};
obelisk = import ./ocaml-obelisk.nix {
inherit (self) stdenv fetchFromGitHub ocaml dune_2;
inherit (self) stdenv lib fetchFromGitHub ocaml dune_2;
inherit (self) ocamlPackages;
};
};
Expand All @@ -45,11 +58,11 @@ let
in rec {
rustc-nightly = rust-channel.rust.override {
targets = [
"wasm32-unknown-unknown"
"wasm32-unknown-emscripten"
"wasm32-wasi"
"i686-unknown-linux-gnu"
];
"wasm32-unknown-unknown"
"wasm32-unknown-emscripten"
"wasm32-wasi"
"i686-unknown-linux-gnu"
];
extensions = ["rust-src"];
};
cargo-nightly = rustc-nightly;
Expand All @@ -60,8 +73,8 @@ let
xargo = self.callPackage ./xargo.nix {};
})

# wasm-profiler
(self: super: import ./wasm-profiler.nix self)
# wasm-profiler
(self: super: import ./wasm-profiler.nix self)

# to allow picking up more recent Haskell packages from Hackage
(self: super: {
Expand Down
4 changes: 2 additions & 2 deletions nix/generated/haskell-lsp-types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
, filepath
, hashable
, lens
, lib
, network-uri
, scientific
, stdenv
, text
, unordered-containers
}:
Expand All @@ -35,5 +35,5 @@ mkDerivation {
];
homepage = "https://github.com/alanz/haskell-lsp";
description = "Haskell library for the Microsoft Language Server Protocol, data types";
license = stdenv.lib.licenses.mit;
license = lib.licenses.mit;
}
4 changes: 2 additions & 2 deletions nix/generated/haskell-lsp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
, hspec
, hspec-discover
, lens
, lib
, mtl
, network-uri
, QuickCheck
, quickcheck-instances
, rope-utf16-splay
, sorted-list
, stdenv
, stm
, temporary
, text
Expand Down Expand Up @@ -80,5 +80,5 @@ mkDerivation {
testToolDepends = [ hspec-discover ];
homepage = "https://github.com/alanz/haskell-lsp";
description = "Haskell library for the Microsoft Language Server Protocol";
license = stdenv.lib.licenses.mit;
license = lib.licenses.mit;
}
4 changes: 2 additions & 2 deletions nix/generated/lsp-int.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
, hspec
, HUnit
, lens
, lib
, lsp-test
, stdenv
, text
}:
mkDerivation {
Expand All @@ -35,5 +35,5 @@ mkDerivation {
];
description = "Integration tests for the language server";
license = "unknown";
hydraPlatforms = stdenv.lib.platforms.none;
hydraPlatforms = lib.platforms.none;
}
4 changes: 2 additions & 2 deletions nix/generated/lsp-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
, haskell-lsp
, hspec
, lens
, lib
, mtl
, parser-combinators
, process
, stdenv
, text
, transformers
, unix
Expand Down Expand Up @@ -72,5 +72,5 @@ mkDerivation {
];
homepage = "https://github.com/bubba/lsp-test#readme";
description = "Functional test framework for LSP servers";
license = stdenv.lib.licenses.bsd3;
license = lib.licenses.bsd3;
}
4 changes: 2 additions & 2 deletions nix/generated/random.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
, pkgs
, base
, exceptions
, lib
, managed
, process
, QuickCheck
, quickcheck-text
, quickcheck-unicode
, stdenv
, tasty
, tasty-quickcheck
, text
Expand All @@ -37,5 +37,5 @@ mkDerivation {
];
description = "generate randomised tests for Motoko";
license = "unknown";
hydraPlatforms = stdenv.lib.platforms.none;
hydraPlatforms = lib.platforms.none;
}
6 changes: 3 additions & 3 deletions nix/ocaml-obelisk.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, ocaml, dune_2, ocamlPackages }:
{ stdenv, lib, fetchFromGitHub, ocaml, dune_2, ocamlPackages }:
stdenv.mkDerivation rec {
pname = "obelisk";
version = "0.5.2";
Expand All @@ -22,8 +22,8 @@ stdenv.mkDerivation rec {

meta = {
description = "A simple tool which produces pretty-printed output from a Menhir parser file (.mly)";
license = stdenv.lib.licenses.mit;
maintainers = [ stdenv.lib.maintainers.vbgl ];
license = lib.licenses.mit;
maintainers = [];
inherit (src.meta) homepage;
inherit (ocamlPackages.ocaml.meta) platforms;
};
Expand Down
8 changes: 3 additions & 5 deletions nix/ocaml-vlq.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, ocaml, findlib, dune }:
{ stdenv, fetchFromGitHub, ocaml, findlib, dune_1 }:

let version = "v0.2.0"; in
stdenv.mkDerivation {
Expand All @@ -11,17 +11,15 @@ stdenv.mkDerivation {
sha256 = "09jdgih2n2qwpxnlbcca4xa193rwbd1nw7prxaqlg134l4mbya83";
};

buildInputs = [ ocaml findlib dune ];
buildInputs = [ ocaml findlib dune_1 ];

buildPhase = "dune build";

inherit (dune) installPhase;
installPhase = "dune install --prefix $out --libdir $OCAMLFIND_DESTDIR vlq";

meta = {
homepage = https://github.com/flowtype/ocaml-vlq;
platforms = ocaml.meta.platforms or [];
description = "A simple library for encoding variable-length quantities";
license = stdenv.lib.licenses.mit;
maintainers = with stdenv.lib.maintainers; [ vbgl ];
};
}
52 changes: 52 additions & 0 deletions nix/patches/124498.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/pkgs/development/compilers/ocaml/generic.nix b/pkgs/development/compilers/ocaml/generic.nix
index d9853dd642a..4ff1b0ead72 100644
--- a/pkgs/development/compilers/ocaml/generic.nix
+++ b/pkgs/development/compilers/ocaml/generic.nix
@@ -58,6 +58,8 @@ stdenv.mkDerivation (args // {
++ optional spaceTimeSupport (flags "--enable-spacetime" "-spacetime")
;

+ hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
+
buildFlags = [ "world" ] ++ optionals useNativeCompilers [ "bootstrap" "world.opt" ];
buildInputs = optional (!lib.versionAtLeast version "4.07") ncurses
++ optionals useX11 [ libX11 xorgproto ];
diff --git a/pkgs/development/ocaml-modules/menhir/generic.nix b/pkgs/development/ocaml-modules/menhir/generic.nix
index a917d634a19..a15452ec490 100644
--- a/pkgs/development/ocaml-modules/menhir/generic.nix
+++ b/pkgs/development/ocaml-modules/menhir/generic.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation {

createFindlibDestdir = true;

+ hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
+
preBuild = ''
# fix makefiles.
RM=$(type -p rm)
diff --git a/pkgs/development/ocaml-modules/wasm/default.nix b/pkgs/development/ocaml-modules/wasm/default.nix
index c8944926488..27e6bbe73fa 100644
--- a/pkgs/development/ocaml-modules/wasm/default.nix
+++ b/pkgs/development/ocaml-modules/wasm/default.nix
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {

buildInputs = [ ocaml findlib ocamlbuild ];

+ hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
+
makeFlags = [ "-C" "interpreter" ];

createFindlibDestdir = true;
diff --git a/pkgs/development/tools/ocaml/ocamlbuild/default.nix b/pkgs/development/tools/ocaml/ocamlbuild/default.nix
index c74794b35c9..b7d0a08c010 100644
--- a/pkgs/development/tools/ocaml/ocamlbuild/default.nix
+++ b/pkgs/development/tools/ocaml/ocamlbuild/default.nix
@@ -17,6 +17,8 @@ stdenv.mkDerivation {

buildInputs = [ ocaml findlib ];

+ hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
+
configurePhase = ''
make -f configure.make Makefile.config \
"OCAMLBUILD_PREFIX=$out" \
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,23 @@
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e",
"sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n",
"rev": "94080ae8286024820c570a2a24ed7c36d7ad04a9",
"sha256": "0wlk52zwlrq727x3z1vg9d9qq4zw62ab5jzg4068iqb6hyb0cr0w",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz",
"url": "https://github.com/nmattia/niv/archive/94080ae8286024820c570a2a24ed7c36d7ad04a9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-20.09",
"branch": "release-21.05",
"builtin": true,
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",
"homepage": null,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "66cd39409e8ae1e2981edfb33bb06c164893d70d",
"sha256": "1c44akgqbqsm2b6k5b850lb0q7wq5l5p4hm6bqbaif1h05sc2bkx",
"rev": "97fc742ae64563093fd26c642db6748e24b01bd9",
"sha256": "0731aadb8kvs3b9dv21jr4ybzahma8rsc8pjvpj70fqkgpa2qsgn",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/66cd39409e8ae1e2981edfb33bb06c164893d70d.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/97fc742ae64563093fd26c642db6748e24b01bd9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-mozilla": {
Expand Down
6 changes: 3 additions & 3 deletions rts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ CLANG_FLAGS = \
--target=wasm32-emscripten \
-fno-builtin -ffreestanding \
--optimize=s \
-resource-dir=$(WASM_CLANG_LIB)/lib/clang/10.0.1

#
# Build targets
Expand Down Expand Up @@ -161,8 +162,7 @@ TOMMATH_BINDINGS_RS=_build/tommath_bindings.rs


$(TOMMATH_BINDINGS_RS): | _build
# use bash explicitly (work around nixpkgs bug https://github.com/NixOS/nixpkgs/issues/110126)
bash $$(command -v bindgen) $(TOMMATHSRC)/tommath.h \
bindgen $(TOMMATHSRC)/tommath.h \
-o $@ \
--use-core --ctypes-prefix=libc --no-layout-tests \
--whitelist-function mp_init \
Expand Down Expand Up @@ -238,7 +238,7 @@ EXPORTED_SYMBOLS=\
fmod \
log \

mo-rts.wasm: $(RTS_RUST_WASM_A) $(TOMMATH_WASM_A) $(MUSL_WASM_A)
mo-rts.wasm: $(TOMMATH_WASM_A) $(MUSL_WASM_A) $(RTS_RUST_WASM_A)
$(WASM_LD) -o $@ \
--import-memory --shared --no-entry --gc-sections \
$(EXPORTED_SYMBOLS:%=--export=%) \
Expand Down
2 changes: 1 addition & 1 deletion src/docs/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=0.15.0
version=0.18.0
break-infix=fit-or-vertical
doc-comments=before
Loading