From 6f1cdb5e079d24dc6694b76d0575ae2da6b43204 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Fri, 29 Sep 2023 11:13:14 -0400 Subject: [PATCH] Stashing more changes --- Makefile | 2 +- flake.nix | 38 ++++++++++++-------- src/nix-instantiate/local.mk | 69 ++++++++++++++++++++++++++++++++++++ src/nix/local.mk | 4 +-- 4 files changed, 96 insertions(+), 17 deletions(-) create mode 100644 src/nix-instantiate/local.mk diff --git a/Makefile b/Makefile index 5fb02e6d8a7..2ea45f01b11 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ endif include mk/lib.mk GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++2a -I src \ - -isystem /nix/store/9x6jfl84234im3f4gsrl1js3zyqz76jd-nlohmann_json-3.11.2/include \ + # -isystem /nix/store/9x6jfl84234im3f4gsrl1js3zyqz76jd-nlohmann_json-3.11.2/include \ # -isystem /nix/store/hl5lsmyf6alwj91nv8kmg2iz1lbnxym9-curl-7.86.0-dev/include \ # -isystem /nix/store/hyxa8plwvgbj16fi2rlvm2sy6idlkab1-libsodium-1.0.18-dev/include \ # -isystem /nix/store/ppqyr8qzdswkswcyb7214y9qg8cr7dnn-sqlite-3.39.4-dev/include \ diff --git a/flake.nix b/flake.nix index a85698fb676..2b261a886e0 100644 --- a/flake.nix +++ b/flake.nix @@ -515,9 +515,8 @@ "-DSQLITE_OMIT_POPEN=1" ]; outputs = [ "out" ]; - seperateDebugInfo = false; + separateDebugInfo = false; checkPhase = '' - mkdir $debug ''; }); @@ -546,10 +545,11 @@ export EM_CACHE=$(pwd)/.emscriptencache emconfigure ./Configure linux-generic64 \ shared \ + no-tests \ + no-engine no-legacy no-module no-padlockeng no-ssl-trace no-ocsp no-stdio no-sm2 no-sm3 no-sm4 no-blake2 no-chacha no-poly1305 no-aria no-dtls \ --prefix=$out \ --libdir=lib \ - --openssldir=etc/ssl \ - no-tests + --openssldir=etc/ssl sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile @@ -558,14 +558,13 @@ ''; buildPhase = '' - emmake make install_sw + emmake make build_sw ''; outputs = ["out"]; installPhase = '' - emmake make install - rm -r $out/etc/ssl/misc - rm $out/bin/c_rehash + emmake make install_sw ''; + separateDebugInfo = false; checkPhase = '' # echo "================= testing zlib using node =================" @@ -597,10 +596,10 @@ nix = stdenv.mkDerivation { name = "emscripten-nix"; - nativeBuildInputs = [ pkg-config autoconf autoreconfHook automake autoconf-archive ]; + nativeBuildInputs = [ jq emscripten pkg-config autoconf autoreconfHook automake autoconf-archive ]; buildInputs = [ boost - emscripten nodejs autoconf automake pkgconfig perlPackages.DBDSQLite perl perlPackages.WWWCurl bzip2 zlib libtool bison flex curl git file + pkgconfig bzip2 zlib libtool bison flex curl git file nlohmann_json libsodium lsof @@ -608,7 +607,7 @@ editline libarchive brotli - jq + # openssl openssl-wasm sqlite-wasm ]; @@ -626,21 +625,32 @@ name = "source"; filter = path: type: ! builtins.elem path [ (self.outPath + "/flake.nix")]; }; + # OPENSSL_CFLAGS="-I ${openssl.dev}/include"; + # OPENSSL_LIBS="-L${openssl-wasm}/lib -lcrypto"; configurePhase = '' + HOME=$TMPDIR + mkdir -p cache/sysroot/include/bits + mkdir -p cache/sysroot/include/SDL emconfigure ./configure \ - --with-boost=$PWD/src/ports/boost_headers \ + --with-boost=${boost.dev}/include \ --disable-cpuid \ --disable-seccomp-sandboxing \ --enable-gc=no \ --disable-tests \ - --prefix=$PWD/outputs/out \ + --prefix=$out \ --disable-doc-gen + export EMCC_CFLAGS="$NIX_CFLAGS_COMPILE" ''; buildPhase = '' - emmake make src/nix-instantiate/nix-instantiate.html + make src/libexpr/eval.o + make -j6 src/nix-instantiate/nix-instantiate.html + ''; + installPhase = '' mkdir $out cp src/nix-instantiate/*.{wasm,js,html} $out ''; + checkPhase = '' + ''; }; }; diff --git a/src/nix-instantiate/local.mk b/src/nix-instantiate/local.mk new file mode 100644 index 00000000000..796ad0e8394 --- /dev/null +++ b/src/nix-instantiate/local.mk @@ -0,0 +1,69 @@ +programs += nix-instantiate.html + +nix-instantiate.html_DIR := $(d) + +nix-instantiate.html_SOURCES := \ + $(wildcard src/nix-instantiate/*.cc) \ + $(wildcard $(d)/*.cc) \ + $(wildcard src/libexpr/*.cc) \ + $(wildcard src/libexpr/value/*.cc) \ + $(wildcard src/libexpr/flake/*.cc) \ + $(wildcard src/libexpr/primops/*.cc) \ + src/libexpr/lexer-tab.cc \ + src/libexpr/parser-tab.cc + + # $(wildcard $(d)/*.cc) \ + # $(wildcard src/nix-build/*.cc) \ + # $(wildcard src/nix-channel/*.cc) \ + # $(wildcard src/nix-collect-garbage/*.cc) \ + # $(wildcard src/nix-copy-closure/*.cc) \ + # $(wildcard src/nix-daemon/*.cc) \ + # $(wildcard src/nix-env/*.cc) \ + # $(wildcard src/nix-store/*.cc) \ + # $(wildcard src/build-remote/*.cc) \ + +nix-instantiate.html_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libexpr -I src/libmain -I src/libcmd + +nix-instantiate.html_LIBS = libexpr libmain libfetchers libstore libutil libcmd + +# export EM_PORTS=${PWD}/ports +# export EM_CACHE=${PWD}/cache + # -L/nix/store/0xa20qx51sr70c92sj1hlcb1ya2pxjqm-emscripten-openssl-3.0.9/lib -lcrypto + # $(shell pkg-config --libs openssl) +nix-instantiate.html_LDFLAGS = \ + $(shell echo "$(NIX_LDFLAGS)" | cut -f 5- -d' ') \ + -lcrypto \ + -sNO_EXIT_RUNTIME=1 \ + -sALLOW_MEMORY_GROWTH=1 \ + -sEXPORTED_RUNTIME_METHODS=cwrap,ccall,UTF8ToString,ptrToString,allocateUTF8,UTF32ToString \ + -sEXPORTED_FUNCTIONS=_processExpr,_main_nix_instantiate2 + # -sUSE_SQLITE3=1 \ + # -sUSE_BOOST_HEADERS=1 \ + +src/libexpr/parser-tab.cc src/libexpr/parser-tab.hh: src/libexpr/parser.y + $(trace-gen) bison -v -o src/libexpr/parser-tab.cc $< -d + +src/libexpr/lexer-tab.cc src/libexpr/lexer-tab.hh: src/libexpr/lexer.l + $(trace-gen) flex --outfile src/libexpr/lexer-tab.cc --header-file=src/libexpr/lexer-tab.hh $< + +clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh + + +$(foreach name, \ + nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \ + $(eval $(call install-symlink, nix, $(bindir)/$(name)))) +$(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote)) + +src/nix-env/user-env.cc: src/nix-env/buildenv.nix.gen.hh + +src/nix/develop.cc: src/nix/get-env.sh.gen.hh + +src/nix-channel/nix-channel.cc: src/nix-channel/unpack-channel.nix.gen.hh + +src/nix/main.cc: doc/manual/generate-manpage.nix.gen.hh doc/manual/utils.nix.gen.hh + +src/nix/doc/files/%.md: doc/manual/src/command-ref/files/%.md + @mkdir -p $$(dirname $@) + @cp $< $@ + +src/nix/profile.cc: src/nix/profile.md src/nix/doc/files/profiles.md.gen.hh diff --git a/src/nix/local.mk b/src/nix/local.mk index 60615976c6e..3128b1c39bb 100644 --- a/src/nix/local.mk +++ b/src/nix/local.mk @@ -19,8 +19,8 @@ nix.html_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/li nix.html_LIBS = libexpr libmain libfetchers libstore libutil libcmd -export EM_PORTS=${PWD}/ports -export EM_CACHE=${PWD}/cache +# export EM_PORTS=${PWD}/ports +# export EM_CACHE=${PWD}/cache nix.html_LDFLAGS = $(SODIUM_LIBS) $(EDITLINE_LIBS) $(LOWDOWN_LIBS) \ -sERROR_ON_UNDEFINED_SYMBOLS=0 \ -sUSE_SQLITE3=1 \