From 72840edbd760553361720c13ff8820658ac11045 Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Wed, 19 Jul 2023 19:10:47 -0400 Subject: [PATCH 01/12] add revery --- ocaml/default.nix | 2 + ocaml/revery/default.nix | 323 ++++++++++++++++++ .../patches/0001-lru-initial-size.patch | 49 +++ .../patches/0002-esy-skia-use-libtool.patch | 52 +++ 4 files changed, 426 insertions(+) create mode 100644 ocaml/revery/default.nix create mode 100644 ocaml/revery/patches/0001-lru-initial-size.patch create mode 100644 ocaml/revery/patches/0002-esy-skia-use-libtool.patch diff --git a/ocaml/default.nix b/ocaml/default.nix index d58be445b..fc19cfbe5 100644 --- a/ocaml/default.nix +++ b/ocaml/default.nix @@ -1584,6 +1584,8 @@ with oself; }; }); + revery = callPackage ./revery { }; + swhid_core = buildDunePackage { pname = "swhid_core"; version = "0.1"; diff --git a/ocaml/revery/default.nix b/ocaml/revery/default.nix new file mode 100644 index 000000000..6fbfbf97a --- /dev/null +++ b/ocaml/revery/default.nix @@ -0,0 +1,323 @@ +{ lib +, buildDunePackage +, fetchFromGitHub +, fetchgit +, ocaml +, stdenv +, gn +, ninja +, libjpeg +, libpng +, zlib +, python3 +, expat +, darwin +, dune-configurator +, SDL2 +, libcxx + # TODO: try to remove? +, findlib + # TODO: try to remove? +, pkg-config +, libiconv +, reason +, ctypes +, lru +, uchar +, harfbuzz +, freetype +, flex +, fpath +, fmt +, logs +, re +, ppx_deriving +, brisk-reconciler +, lwt_ppx +, ppx_optcomp +, uutf +, uucp +, rebez +, bos +, charInfo_width +}: + +let + reverySrc = fetchFromGitHub { + owner = "revery-ui"; + repo = "revery"; + # master branch as of Aug 27, 2021 + rev = "141f70f69d6abd69674b46d805a783411b38cd79"; + sha256 = "sha256-3AGdf0vcFoxcmGUHCUcmjb+VCpp2WDYmkv9Tp7VJqsw="; + }; + angle2 = fetchgit { + url = "https://chromium.googlesource.com/angle/angle.git"; + rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; + sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; + }; + piex = fetchgit { + url = "https://android.googlesource.com/platform/external/piex.git"; + rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; + sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; + }; + esy-skia = stdenv.mkDerivation rec { + name = "skia"; + patches = [ + ./patches/0002-esy-skia-use-libtool.patch + ]; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "esy-skia"; + rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; + sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; + }; + nativeBuildInputs = [ + gn + ninja + libjpeg + libpng + zlib + python3 + expat + # TODO: add optional webp support + #libwebp + darwin.apple_sdk.frameworks.ApplicationServices + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.OpenGL + # TODO handle ios, android + #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation + stdenv.cc + # needed to get libtool - TODO: double check this, add darwin flag, test on linux if ar is needed + darwin.cctools + ]; + + preConfigure = '' + mkdir -p third_party/externals + ln -s ${angle2} third_party/externals/angle2 + ln -s ${piex} third_party/externals/piex + ''; + #TODO: remove cc= ccx= + #TODO: optional xcode_sysroot + #TODO: built this based on feature flags, with sane defaults per os + #TODO: enable more features + configurePhase = '' + runHook preConfigure + gn gen out/Release --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_use_wuffs=false skia_enable_tools=false extra_asmflags=[] xcode_sysroot="${darwin.apple_sdk_11_0.MacOSX-SDK}" host_os="mac" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_use_no_jpeg_encode=true skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true' + runHook postConfigure + ''; + buildPhase = '' + runHook preBuild + ninja -C out/Release skia + runHook postBuild + ''; + + # TODO: these includes were taken from alperite and can probably be simplified to include everything + installPhase = '' + mkdir -p $out + + # Glob will match all subdirs. + shopt -s globstar + + cp -r --parents -t $out/ \ + include/codec \ + include/config \ + include/core \ + include/effects \ + include/gpu \ + include/private \ + include/utils \ + include/c \ + out/Release/*.a \ + src/gpu/**/*.h \ + third_party/externals/angle2/include \ + third_party/skcms/**/*.h + ''; + }; + reason-sdl2 = buildDunePackage rec { + pname = "reason-sdl2"; + version = "0.0.0"; + src = reverySrc; + postPatch = '' + substituteInPlace packages/reason-sdl2/src/sdl2_wrapper.cpp \ + --replace "case SDL_PANEVENT:" "/* case SDL_PANEVENT:" \ + --replace "case SDL_DROPTEXT:" "*/ case SDL_DROPTEXT:" \ + --replace "case SDL_WINDOWEVENT_FULLSCREEN:" "/* case SDL_WINDOWEVENT_FULLSCREEN:" \ + --replace "case SDL_WINDOWEVENT_RESTORED:" "*/ case SDL_WINDOWEVENT_RESTORED:" \ + --replace "hash_variant" "caml_hash_variant" + ''; + buildInputs = [ + dune-configurator + SDL2 + SDL2.dev + findlib + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.ForceFeedback + libiconv + ]; + nativeBuildInputs = [ + reason + SDL2 + SDL2.dev + findlib + ]; + propagatedBuildInputs = [ + SDL2 + SDL2.dev + ctypes + findlib + ]; + SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; + SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; + cur__root = "${src}"; + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; + }; + # This change is allows configuring initial capacity of the cache + # https://github.com/pqwy/lru/pull/8/commits/f646450cc5a165bbb39121d5a456dd3f5ad4dba5 + lruOverride = lru.overrideAttrs (_: super: { + patches = [ ./patches/0001-lru-initial-size.patch ]; + }); + omd = buildDunePackage { + pname = "omd"; + version = "0.0.0"; + src = fetchFromGitHub { + owner = "ocaml"; + repo = "omd"; + rev = "1535e3c684323f370f3f80bce2564863140de6ba"; + sha256 = "sha256-Tu60WdHvVq24m6QMJTe3B55gfNjtoxomW/Q3MT6//n4="; + }; + propagatedBuildInputs = [ + uchar + ]; + }; + reason-harfbuzz = buildDunePackage { + pname = "reason-harfbuzz"; + version = "0.0.0"; + src = reverySrc; + buildInputs = [ + pkg-config + dune-configurator + stdenv + findlib + ]; + nativeBuildInputs = [ + reason + pkg-config + findlib + ]; + HARFBUZZ_INCLUDE_PATH = "${harfbuzz.dev}/include/harfbuzz"; + HARFBUZZ_LIB_PATH = ''${harfbuzz}/lib''; + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; + }; + reason-skia = buildDunePackage { + pname = "reason-skia"; + version = "0.0.0"; + src = reverySrc; + postPatch = '' + # the cptr function was removed from ctypes, so the value now needs to be + # destructured to get to the pointer + substituteInPlace packages/reason-skia/src/Skia.re \ + --replace "module CI = Cstubs_internals;" \ + "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" + #substituteInPlace packages/reason-skia/src/wrapped/bindings/SkiaWrappedBindings.re \ + #packages/reason-skia/src/Skia.re \ + # --replace "module CI = Cstubs_internals;" \ + # "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" + ''; + buildInputs = [ + dune-configurator + ]; + nativeBuildInputs = [ + reason + pkg-config + ]; + propagatedBuildInputs = [ + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.ForceFeedback + libiconv + findlib + reason-sdl2 + ctypes + ]; + SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; + SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; + SKIA_INCLUDE_PATH = "${esy-skia}/include/c"; + SKIA_LIB_PATH = "${esy-skia}/out/Release"; + JPEG_LIB_PATH = "${(libjpeg.override{enableStatic = true;}).out}/lib"; + FREETYPE2_LIB_PATH = "${freetype}/lib"; + }; + rench = buildDunePackage { + pname = "Rench"; + version = "0.0.0"; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "rench"; + rev = "df44c5277ed1d3ccfa959f2623705baefd26ad99"; + sha256 = "sha256-cGBYBIxVIuhbvkGxM1lAN0j5m5Fiqlc3O1xyt9OFP4U="; + }; + nativeBuildInputs = [ + reason + ]; + propagatedBuildInputs = [ + flex + fpath + ]; + }; + timber = buildDunePackage { + pname = "timber"; + version = "0.0.0"; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "timber"; + rev = "f4c40ee5d7cb93801160340ac4ac9c974ce01b66"; + sha256 = "sha256-tk/2Of0R4WzjM7Fiv0mXVSbmiRHXMtppLgBcgvX4p9s="; + }; + nativeBuildInputs = [ + reason + ]; + propagatedBuildInputs = [ + fmt + logs + re + ]; + }; +in +buildDunePackage { + pname = "Revery"; + version = "0.0.0"; + # TODO: check if a patch can avoid disabling this + # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-overflow + hardeningDisable = [ "strictoverflow" ]; + src = reverySrc; + preBuild = '' + substituteInPlace packages/zed/src/dune --replace "bytes" "" + # This supresses a warning from the use of CAMLparam2, where caml__frame is unused: + # dialog.c:32:5: error: unused variable 'caml__frame' [-Werror,-Wunused-variable] + # TODO: try to suppress this for the single file + substituteInPlace src/Native/dune --replace "-Werror" "-Werror\n -Wno-unused-variable" + ''; + buildInputs = [ + dune-configurator + ]; + nativeBuildInputs = [ + reason + pkg-config + ]; + propagatedBuildInputs = [ + ppx_deriving + brisk-reconciler + lwt_ppx + ppx_optcomp + uutf + uucp + reason-skia + omd + rebez + bos + reason-harfbuzz + charInfo_width + lruOverride + rench + timber + ]; +} diff --git a/ocaml/revery/patches/0001-lru-initial-size.patch b/ocaml/revery/patches/0001-lru-initial-size.patch new file mode 100644 index 000000000..f417cd91b --- /dev/null +++ b/ocaml/revery/patches/0001-lru-initial-size.patch @@ -0,0 +1,49 @@ +diff --git a/src/lru.ml b/src/lru.ml +index f3e1301..fffcec2 100644 +--- a/src/lru.ml ++++ b/src/lru.ml +@@ -209,7 +209,7 @@ module M = struct + type t + type k + type v +- val create : ?random:bool -> int -> t ++ val create : ?random:bool -> ?initialSize: int -> int -> t + val is_empty : t -> bool + val size : t -> int + val weight : t -> int +@@ -250,9 +250,11 @@ module M = struct + + let cap_makes_sense = cap_makes_sense ~m:"M" + +- let create ?random cap = ++ let create ?random ?initialSize cap = ++ let hashSize = ++ match initialSize with | None -> cap | (Some v) -> v in + cap_makes_sense ~f:"create" cap; +- { cap; w = 0; ht = HT.create ?random cap; q = Q.create () } ++ { cap; w = 0; ht = HT.create ?random hashSize; q = Q.create () } + + let lru t = match t.q.Q.first with Some n -> Some n.Q.value | _ -> None + +diff --git a/src/lru.mli b/src/lru.mli +index 5271846..ea81bf0 100644 +--- a/src/lru.mli ++++ b/src/lru.mli +@@ -219,12 +219,15 @@ module M : sig + type v + (** Values in {{!t}[t]}. *) + +- val create : ?random:bool -> int -> t +- (** [create ?random cap] is a new map with capacity [cap]. ++ val create : ?random:bool -> ?initialSize:int -> int -> t ++ (** [create ?random ?initialSize cap] is a new map with capacity [cap]. + + [~random] randomizes the underlying hash table. It defaults to [false]. + See {!Hashtbl.create}. + ++ [~initialSize] sets the initial size of the underlying hash table. If not set, ++ [initialSize] is set to [cap]. ++ + {b Note.} The internal hash table is created with size [cap]. + + @raise Invalid_argument when [cap < 0]. *) diff --git a/ocaml/revery/patches/0002-esy-skia-use-libtool.patch b/ocaml/revery/patches/0002-esy-skia-use-libtool.patch new file mode 100644 index 000000000..c4eda580f --- /dev/null +++ b/ocaml/revery/patches/0002-esy-skia-use-libtool.patch @@ -0,0 +1,52 @@ +From 445b2e0cb969f9de458b8464bd3b18caade11fc4 Mon Sep 17 00:00:00 2001 +From: Joseph Price +Date: Wed, 19 Jul 2023 07:37:32 -0400 +Subject: [PATCH] use libtool + +--- + gn/toolchain/BUILD.gn | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn +index cd1def114d..8a914a99c3 100644 +--- a/gn/toolchain/BUILD.gn ++++ b/gn/toolchain/BUILD.gn +@@ -260,11 +260,22 @@ template("gcc_like_toolchain") { + description = "assemble {{source}}" + } + ++ if (is_mac || is_ios) { ++ not_needed([ "ar" ]) # We use libtool instead. ++ } + tool("alink") { +- rspfile = "{{output}}.rsp" +- rspfile_content = "{{inputs}}" +- ar_py = rebase_path("../ar.py") +- command = "python $ar_py $ar {{output}} $rspfile" ++ if (is_mac || is_ios) { ++ command = "libtool -static -o {{output}} -no_warning_for_no_symbols {{inputs}}" ++ } else { ++ rspfile = "{{output}}.rsp" ++ rspfile_content = "{{inputs}}" ++ # TODO: add rm.py ++ #rm_py = rebase_path("../rm.py") ++ #command = "$shell python3 \"$rm_py\" \"{{output}}\" && $ar rcs {{output}} @$rspfile" ++ ar_py = rebase_path("../ar.py") ++ command = "python $ar_py $ar {{output}} $rspfile" ++ } ++ + outputs = [ + "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", + ] +@@ -280,7 +291,7 @@ template("gcc_like_toolchain") { + } + + rpath = "-Wl,-soname,$soname" +- if (is_mac) { ++ if (is_mac || is_ios) { + rpath = "-Wl,-install_name,@rpath/$soname" + } + +-- +2.40.1 + From 03eb4f98ba0db115890527fce4e6b7474817f29c Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 19 Jul 2023 19:22:23 -0700 Subject: [PATCH 02/12] multiple files + prune unnecessary stuff --- ocaml/default.nix | 29 ++++ ocaml/revery/default.nix | 256 ++----------------------------- ocaml/revery/reason-harfbuzz.nix | 25 +++ ocaml/revery/reason-sdl2.nix | 58 +++++++ ocaml/revery/reason-skia.nix | 51 ++++++ overlay/default.nix | 90 +++++++++++ 6 files changed, 262 insertions(+), 247 deletions(-) create mode 100644 ocaml/revery/reason-harfbuzz.nix create mode 100644 ocaml/revery/reason-sdl2.nix create mode 100644 ocaml/revery/reason-skia.nix diff --git a/ocaml/default.nix b/ocaml/default.nix index fc19cfbe5..6b0e99c04 100644 --- a/ocaml/default.nix +++ b/ocaml/default.nix @@ -1584,8 +1584,37 @@ with oself; }; }); + reason-harfbuzz = callPackage ./revery/reason-harfbuzz.nix { }; + reason-sdl2 = callPackage ./revery/reason-sdl2.nix { }; + reason-skia = callPackage ./revery/reason-skia.nix { }; revery = callPackage ./revery { }; + rench = buildDunePackage { + pname = "Rench"; + version = "0.0.0"; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "rench"; + rev = "df44c5277ed1d3ccfa959f2623705baefd26ad99"; + sha256 = "sha256-cGBYBIxVIuhbvkGxM1lAN0j5m5Fiqlc3O1xyt9OFP4U="; + }; + nativeBuildInputs = [ reason ]; + propagatedBuildInputs = [ flex fpath ]; + }; + + timber = buildDunePackage { + pname = "timber"; + version = "0.0.0"; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "timber"; + rev = "f4c40ee5d7cb93801160340ac4ac9c974ce01b66"; + sha256 = "sha256-tk/2Of0R4WzjM7Fiv0mXVSbmiRHXMtppLgBcgvX4p9s="; + }; + nativeBuildInputs = [ reason ]; + propagatedBuildInputs = [ fmt logs re ]; + }; + swhid_core = buildDunePackage { pname = "swhid_core"; version = "0.1"; diff --git a/ocaml/revery/default.nix b/ocaml/revery/default.nix index 6fbfbf97a..3776a1be1 100644 --- a/ocaml/revery/default.nix +++ b/ocaml/revery/default.nix @@ -1,36 +1,11 @@ { lib , buildDunePackage , fetchFromGitHub -, fetchgit -, ocaml -, stdenv -, gn -, ninja -, libjpeg -, libpng -, zlib -, python3 -, expat -, darwin , dune-configurator -, SDL2 -, libcxx - # TODO: try to remove? -, findlib - # TODO: try to remove? , pkg-config -, libiconv , reason -, ctypes , lru , uchar -, harfbuzz -, freetype -, flex -, fpath -, fmt -, logs -, re , ppx_deriving , brisk-reconciler , lwt_ppx @@ -40,137 +15,14 @@ , rebez , bos , charInfo_width +, reason-sdl2 +, reason-skia +, reason-harfbuzz +, rench +, timber }: let - reverySrc = fetchFromGitHub { - owner = "revery-ui"; - repo = "revery"; - # master branch as of Aug 27, 2021 - rev = "141f70f69d6abd69674b46d805a783411b38cd79"; - sha256 = "sha256-3AGdf0vcFoxcmGUHCUcmjb+VCpp2WDYmkv9Tp7VJqsw="; - }; - angle2 = fetchgit { - url = "https://chromium.googlesource.com/angle/angle.git"; - rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; - sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; - }; - piex = fetchgit { - url = "https://android.googlesource.com/platform/external/piex.git"; - rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; - sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; - }; - esy-skia = stdenv.mkDerivation rec { - name = "skia"; - patches = [ - ./patches/0002-esy-skia-use-libtool.patch - ]; - src = fetchFromGitHub { - owner = "revery-ui"; - repo = "esy-skia"; - rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; - sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; - }; - nativeBuildInputs = [ - gn - ninja - libjpeg - libpng - zlib - python3 - expat - # TODO: add optional webp support - #libwebp - darwin.apple_sdk.frameworks.ApplicationServices - darwin.apple_sdk.frameworks.AppKit - darwin.apple_sdk.frameworks.OpenGL - # TODO handle ios, android - #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation - stdenv.cc - # needed to get libtool - TODO: double check this, add darwin flag, test on linux if ar is needed - darwin.cctools - ]; - - preConfigure = '' - mkdir -p third_party/externals - ln -s ${angle2} third_party/externals/angle2 - ln -s ${piex} third_party/externals/piex - ''; - #TODO: remove cc= ccx= - #TODO: optional xcode_sysroot - #TODO: built this based on feature flags, with sane defaults per os - #TODO: enable more features - configurePhase = '' - runHook preConfigure - gn gen out/Release --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_use_wuffs=false skia_enable_tools=false extra_asmflags=[] xcode_sysroot="${darwin.apple_sdk_11_0.MacOSX-SDK}" host_os="mac" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_use_no_jpeg_encode=true skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true' - runHook postConfigure - ''; - buildPhase = '' - runHook preBuild - ninja -C out/Release skia - runHook postBuild - ''; - - # TODO: these includes were taken from alperite and can probably be simplified to include everything - installPhase = '' - mkdir -p $out - - # Glob will match all subdirs. - shopt -s globstar - - cp -r --parents -t $out/ \ - include/codec \ - include/config \ - include/core \ - include/effects \ - include/gpu \ - include/private \ - include/utils \ - include/c \ - out/Release/*.a \ - src/gpu/**/*.h \ - third_party/externals/angle2/include \ - third_party/skcms/**/*.h - ''; - }; - reason-sdl2 = buildDunePackage rec { - pname = "reason-sdl2"; - version = "0.0.0"; - src = reverySrc; - postPatch = '' - substituteInPlace packages/reason-sdl2/src/sdl2_wrapper.cpp \ - --replace "case SDL_PANEVENT:" "/* case SDL_PANEVENT:" \ - --replace "case SDL_DROPTEXT:" "*/ case SDL_DROPTEXT:" \ - --replace "case SDL_WINDOWEVENT_FULLSCREEN:" "/* case SDL_WINDOWEVENT_FULLSCREEN:" \ - --replace "case SDL_WINDOWEVENT_RESTORED:" "*/ case SDL_WINDOWEVENT_RESTORED:" \ - --replace "hash_variant" "caml_hash_variant" - ''; - buildInputs = [ - dune-configurator - SDL2 - SDL2.dev - findlib - darwin.apple_sdk.frameworks.Cocoa - darwin.apple_sdk.frameworks.ForceFeedback - libiconv - ]; - nativeBuildInputs = [ - reason - SDL2 - SDL2.dev - findlib - ]; - propagatedBuildInputs = [ - SDL2 - SDL2.dev - ctypes - findlib - ]; - SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; - SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; - cur__root = "${src}"; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; - }; # This change is allows configuring initial capacity of the cache # https://github.com/pqwy/lru/pull/8/commits/f646450cc5a165bbb39121d5a456dd3f5ad4dba5 lruOverride = lru.overrideAttrs (_: super: { @@ -189,106 +41,16 @@ let uchar ]; }; - reason-harfbuzz = buildDunePackage { - pname = "reason-harfbuzz"; - version = "0.0.0"; - src = reverySrc; - buildInputs = [ - pkg-config - dune-configurator - stdenv - findlib - ]; - nativeBuildInputs = [ - reason - pkg-config - findlib - ]; - HARFBUZZ_INCLUDE_PATH = "${harfbuzz.dev}/include/harfbuzz"; - HARFBUZZ_LIB_PATH = ''${harfbuzz}/lib''; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; - }; - reason-skia = buildDunePackage { - pname = "reason-skia"; - version = "0.0.0"; - src = reverySrc; - postPatch = '' - # the cptr function was removed from ctypes, so the value now needs to be - # destructured to get to the pointer - substituteInPlace packages/reason-skia/src/Skia.re \ - --replace "module CI = Cstubs_internals;" \ - "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" - #substituteInPlace packages/reason-skia/src/wrapped/bindings/SkiaWrappedBindings.re \ - #packages/reason-skia/src/Skia.re \ - # --replace "module CI = Cstubs_internals;" \ - # "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" - ''; - buildInputs = [ - dune-configurator - ]; - nativeBuildInputs = [ - reason - pkg-config - ]; - propagatedBuildInputs = [ - darwin.apple_sdk.frameworks.AppKit - darwin.apple_sdk.frameworks.Cocoa - darwin.apple_sdk.frameworks.ForceFeedback - libiconv - findlib - reason-sdl2 - ctypes - ]; - SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; - SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; - SKIA_INCLUDE_PATH = "${esy-skia}/include/c"; - SKIA_LIB_PATH = "${esy-skia}/out/Release"; - JPEG_LIB_PATH = "${(libjpeg.override{enableStatic = true;}).out}/lib"; - FREETYPE2_LIB_PATH = "${freetype}/lib"; - }; - rench = buildDunePackage { - pname = "Rench"; - version = "0.0.0"; - src = fetchFromGitHub { - owner = "revery-ui"; - repo = "rench"; - rev = "df44c5277ed1d3ccfa959f2623705baefd26ad99"; - sha256 = "sha256-cGBYBIxVIuhbvkGxM1lAN0j5m5Fiqlc3O1xyt9OFP4U="; - }; - nativeBuildInputs = [ - reason - ]; - propagatedBuildInputs = [ - flex - fpath - ]; - }; - timber = buildDunePackage { - pname = "timber"; - version = "0.0.0"; - src = fetchFromGitHub { - owner = "revery-ui"; - repo = "timber"; - rev = "f4c40ee5d7cb93801160340ac4ac9c974ce01b66"; - sha256 = "sha256-tk/2Of0R4WzjM7Fiv0mXVSbmiRHXMtppLgBcgvX4p9s="; - }; - nativeBuildInputs = [ - reason - ]; - propagatedBuildInputs = [ - fmt - logs - re - ]; - }; + in + buildDunePackage { pname = "Revery"; version = "0.0.0"; - # TODO: check if a patch can avoid disabling this + # TODO: check if a patch can avoid disabling this # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-overflow hardeningDisable = [ "strictoverflow" ]; - src = reverySrc; + inherit (reason-sdl2) src; preBuild = '' substituteInPlace packages/zed/src/dune --replace "bytes" "" # This supresses a warning from the use of CAMLparam2, where caml__frame is unused: diff --git a/ocaml/revery/reason-harfbuzz.nix b/ocaml/revery/reason-harfbuzz.nix new file mode 100644 index 000000000..3cd0a187b --- /dev/null +++ b/ocaml/revery/reason-harfbuzz.nix @@ -0,0 +1,25 @@ +{ buildDunePackage +, pkg-config +, reason-sdl2 +, reason +, dune-configurator +, harfbuzz +, lib +, libcxx +, stdenv +}: + +buildDunePackage { + pname = "reason-harfbuzz"; + version = "0.0.0"; + inherit (reason-sdl2) src; + + buildInputs = [ dune-configurator ]; + nativeBuildInputs = [ + reason + pkg-config + ]; + HARFBUZZ_INCLUDE_PATH = "${harfbuzz.dev}/include/harfbuzz"; + HARFBUZZ_LIB_PATH = ''${harfbuzz}/lib''; + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; +} diff --git a/ocaml/revery/reason-sdl2.nix b/ocaml/revery/reason-sdl2.nix new file mode 100644 index 000000000..1d41ed0ae --- /dev/null +++ b/ocaml/revery/reason-sdl2.nix @@ -0,0 +1,58 @@ +{ buildDunePackage +, fetchFromGitHub +, SDL2 +, ctypes +, findlib +, reason +, dune-configurator +, darwin +, libiconv +, lib +, stdenv +, libcxx + +}: + +buildDunePackage rec { + pname = "reason-sdl2"; + version = "0.0.0"; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "revery"; + # master branch as of Aug 27, 2021 + rev = "141f70f69d6abd69674b46d805a783411b38cd79"; + sha256 = "sha256-3AGdf0vcFoxcmGUHCUcmjb+VCpp2WDYmkv9Tp7VJqsw="; + }; + postPatch = '' + substituteInPlace packages/reason-sdl2/src/sdl2_wrapper.cpp \ + --replace "case SDL_PANEVENT:" "/* case SDL_PANEVENT:" \ + --replace "case SDL_DROPTEXT:" "*/ case SDL_DROPTEXT:" \ + --replace "case SDL_WINDOWEVENT_FULLSCREEN:" "/* case SDL_WINDOWEVENT_FULLSCREEN:" \ + --replace "case SDL_WINDOWEVENT_RESTORED:" "*/ case SDL_WINDOWEVENT_RESTORED:" \ + --replace "hash_variant" "caml_hash_variant" + ''; + buildInputs = [ + dune-configurator + # SDL2 + # SDL2.dev + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.ForceFeedback + libiconv + ]; + nativeBuildInputs = [ + reason + # SDL2 + # SDL2.dev + findlib + ]; + propagatedBuildInputs = [ + SDL2 + SDL2.dev + ctypes + # findlib + ]; + SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; + SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; + cur__root = "${src}"; + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1"; +} diff --git a/ocaml/revery/reason-skia.nix b/ocaml/revery/reason-skia.nix new file mode 100644 index 000000000..ef045f282 --- /dev/null +++ b/ocaml/revery/reason-skia.nix @@ -0,0 +1,51 @@ +{ buildDunePackage +, ctypes +, darwin +, dune-configurator +, esy-skia +, freetype +, libiconv +, libjpeg +, pkg-config +, reason +, reason-sdl2 +, SDL2 +}: + +buildDunePackage { + pname = "reason-skia"; + version = "0.0.0"; + inherit (reason-sdl2) src; + postPatch = '' + # the cptr function was removed from ctypes, so the value now needs to be + # destructured to get to the pointer + substituteInPlace packages/reason-skia/src/Skia.re \ + --replace "module CI = Cstubs_internals;" \ + "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" + #substituteInPlace packages/reason-skia/src/wrapped/bindings/SkiaWrappedBindings.re \ + #packages/reason-skia/src/Skia.re \ + # --replace "module CI = Cstubs_internals;" \ + # "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" + ''; + buildInputs = [ + dune-configurator + ]; + nativeBuildInputs = [ + reason + pkg-config + ]; + propagatedBuildInputs = [ + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.ForceFeedback + libiconv + reason-sdl2 + ctypes + ]; + SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; + SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; + SKIA_INCLUDE_PATH = "${esy-skia}/include/c"; + SKIA_LIB_PATH = "${esy-skia}/out/Release"; + JPEG_LIB_PATH = "${(libjpeg.override { enableStatic = true; }).out}/lib"; + FREETYPE2_LIB_PATH = "${freetype}/lib"; +} diff --git a/overlay/default.nix b/overlay/default.nix index 0bc29089b..922dcc6ed 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -11,7 +11,9 @@ let stdenv fetchFromGitHub callPackage + darwin fetchpatch + fetchgit buildGoModule haskell haskellPackages; @@ -143,6 +145,94 @@ in opaline = null; ott = super.ott.override { opaline = self.ocamlPackages.opaline; }; esy = callPackage ../ocaml/esy { }; + esy-skia = + let + angle2 = fetchgit { + url = "https://chromium.googlesource.com/angle/angle.git"; + rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; + sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; + }; + piex = fetchgit { + url = "https://android.googlesource.com/platform/external/piex.git"; + rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; + sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; + }; + in + + stdenv.mkDerivation rec { + name = "skia"; + patches = [ + ../ocaml/revery/patches/0002-esy-skia-use-libtool.patch + ]; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "esy-skia"; + rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; + sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; + }; + nativeBuildInputs = with self; [ + gn + ninja + libjpeg + libpng + zlib + python3 + expat + # TODO: add optional webp support + #libwebp + darwin.apple_sdk.frameworks.ApplicationServices + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.OpenGL + # TODO handle ios, android + #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation + stdenv.cc + # needed to get libtool - TODO: double check this, add darwin flag, test on linux if ar is needed + darwin.cctools + ]; + + preConfigure = '' + mkdir -p third_party/externals + ln -s ${angle2} third_party/externals/angle2 + ln -s ${piex} third_party/externals/piex + ''; + #TODO: remove cc= ccx= + #TODO: optional xcode_sysroot + #TODO: built this based on feature flags, with sane defaults per os + #TODO: enable more features + configurePhase = '' + runHook preConfigure + gn gen out/Release \ + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] target_cpu="arm64" host_os="mac" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true' + runHook postConfigure + ''; + buildPhase = '' + runHook preBuild + ninja -C out/Release skia + runHook postBuild + ''; + + # TODO: these includes were taken from alperite and can probably be simplified to include everything + installPhase = '' + mkdir -p $out + + # Glob will match all subdirs. + shopt -s globstar + + cp -r --parents -t $out/ \ + include/codec \ + include/config \ + include/core \ + include/effects \ + include/gpu \ + include/private \ + include/utils \ + include/c \ + out/Release/*.a \ + src/gpu/**/*.h \ + third_party/externals/angle2/include \ + third_party/skcms/**/*.h + ''; + }; h2spec = self.buildGoModule { pname = "h2spec"; From 38b29374436eb983a0a2bddccbf3de264c933ec9 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 19 Jul 2023 19:39:35 -0700 Subject: [PATCH 03/12] more fixes --- ocaml/revery/reason-harfbuzz.nix | 5 ++++- ocaml/revery/reason-skia.nix | 28 ++++++++++------------------ overlay/default.nix | 10 ++-------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/ocaml/revery/reason-harfbuzz.nix b/ocaml/revery/reason-harfbuzz.nix index 3cd0a187b..75c1fe158 100644 --- a/ocaml/revery/reason-harfbuzz.nix +++ b/ocaml/revery/reason-harfbuzz.nix @@ -7,6 +7,7 @@ , lib , libcxx , stdenv +, darwin }: buildDunePackage { @@ -14,7 +15,9 @@ buildDunePackage { version = "0.0.0"; inherit (reason-sdl2) src; - buildInputs = [ dune-configurator ]; + buildInputs = [ dune-configurator ] ++ + lib.optionals stdenv.isDarwin + (with darwin.apple_sdk.frameworks; [ Foundation AppKit ]); nativeBuildInputs = [ reason pkg-config diff --git a/ocaml/revery/reason-skia.nix b/ocaml/revery/reason-skia.nix index ef045f282..377d3c163 100644 --- a/ocaml/revery/reason-skia.nix +++ b/ocaml/revery/reason-skia.nix @@ -16,34 +16,26 @@ buildDunePackage { pname = "reason-skia"; version = "0.0.0"; inherit (reason-sdl2) src; + # the cptr function was removed from ctypes, so the value now needs to be + # destructured to get to the pointer postPatch = '' - # the cptr function was removed from ctypes, so the value now needs to be - # destructured to get to the pointer substituteInPlace packages/reason-skia/src/Skia.re \ --replace "module CI = Cstubs_internals;" \ "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" - #substituteInPlace packages/reason-skia/src/wrapped/bindings/SkiaWrappedBindings.re \ - #packages/reason-skia/src/Skia.re \ - # --replace "module CI = Cstubs_internals;" \ - # "module CI = { include Cstubs_internals; let cptr = (CPointer(a)) => a; };" ''; - buildInputs = [ - dune-configurator - ]; - nativeBuildInputs = [ - reason - pkg-config - ]; - propagatedBuildInputs = [ - darwin.apple_sdk.frameworks.AppKit - darwin.apple_sdk.frameworks.Cocoa - darwin.apple_sdk.frameworks.ForceFeedback + + nativeBuildInputs = [ reason pkg-config ]; + buildInputs = [ dune-configurator ]; + propagatedBuildInputs = with darwin.apple_sdk.frameworks; [ + AppKit + Cocoa + ForceFeedback libiconv reason-sdl2 ctypes ]; SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; - SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; + SDL2_LIB_PATH = "${SDL2.override { withStatic = true; }}/lib"; SKIA_INCLUDE_PATH = "${esy-skia}/include/c"; SKIA_LIB_PATH = "${esy-skia}/out/Release"; JPEG_LIB_PATH = "${(libjpeg.override { enableStatic = true; }).out}/lib"; diff --git a/overlay/default.nix b/overlay/default.nix index 922dcc6ed..8eb6cbd90 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -161,15 +161,13 @@ in stdenv.mkDerivation rec { name = "skia"; - patches = [ - ../ocaml/revery/patches/0002-esy-skia-use-libtool.patch - ]; src = fetchFromGitHub { owner = "revery-ui"; repo = "esy-skia"; rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; }; + nativeBuildInputs = with self; [ gn ninja @@ -185,9 +183,6 @@ in darwin.apple_sdk.frameworks.OpenGL # TODO handle ios, android #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation - stdenv.cc - # needed to get libtool - TODO: double check this, add darwin flag, test on linux if ar is needed - darwin.cctools ]; preConfigure = '' @@ -195,8 +190,7 @@ in ln -s ${angle2} third_party/externals/angle2 ln -s ${piex} third_party/externals/piex ''; - #TODO: remove cc= ccx= - #TODO: optional xcode_sysroot + #TODO: built this based on feature flags, with sane defaults per os #TODO: enable more features configurePhase = '' From b1757d6883df1f043902f33e6a3b535defa85bfa Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 19 Jul 2023 19:40:03 -0700 Subject: [PATCH 04/12] wip --- overlay/default.nix | 147 ++++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 74 deletions(-) diff --git a/overlay/default.nix b/overlay/default.nix index 8eb6cbd90..0941c92ff 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -145,88 +145,87 @@ in opaline = null; ott = super.ott.override { opaline = self.ocamlPackages.opaline; }; esy = callPackage ../ocaml/esy { }; - esy-skia = - let - angle2 = fetchgit { - url = "https://chromium.googlesource.com/angle/angle.git"; - rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; - sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; - }; - piex = fetchgit { - url = "https://android.googlesource.com/platform/external/piex.git"; - rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; - sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; - }; - in - - stdenv.mkDerivation rec { - name = "skia"; - src = fetchFromGitHub { - owner = "revery-ui"; - repo = "esy-skia"; - rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; - sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; - }; + esy-skia = stdenv.mkDerivation rec { + name = "skia"; + src = fetchFromGitHub { + owner = "revery-ui"; + repo = "esy-skia"; + rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; + sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; + }; - nativeBuildInputs = with self; [ - gn - ninja - libjpeg - libpng - zlib - python3 - expat - # TODO: add optional webp support - #libwebp - darwin.apple_sdk.frameworks.ApplicationServices - darwin.apple_sdk.frameworks.AppKit - darwin.apple_sdk.frameworks.OpenGL - # TODO handle ios, android - #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation - ]; + nativeBuildInputs = with self; [ + gn + ninja + libjpeg + libpng + zlib + python3 + expat + # TODO: add optional webp support + #libwebp + darwin.apple_sdk.frameworks.ApplicationServices + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.OpenGL + # TODO handle ios, android + #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation + ]; - preConfigure = '' + preConfigure = + let + angle2 = fetchgit { + url = "https://chromium.googlesource.com/angle/angle.git"; + rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; + sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; + }; + piex = fetchgit { + url = "https://android.googlesource.com/platform/external/piex.git"; + rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; + sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; + }; + in + '' mkdir -p third_party/externals ln -s ${angle2} third_party/externals/angle2 ln -s ${piex} third_party/externals/piex ''; - #TODO: built this based on feature flags, with sane defaults per os - #TODO: enable more features - configurePhase = '' - runHook preConfigure - gn gen out/Release \ - --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] target_cpu="arm64" host_os="mac" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true' - runHook postConfigure - ''; - buildPhase = '' - runHook preBuild - ninja -C out/Release skia - runHook postBuild - ''; + #TODO: built this based on feature flags, with sane defaults per os + #TODO: enable more features + configurePhase = '' + runHook preConfigure + gn gen out/Release \ + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] target_cpu="arm64" host_os="mac" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true' + runHook postConfigure + ''; + buildPhase = '' + runHook preBuild + ninja -C out/Release skia + runHook postBuild + ''; - # TODO: these includes were taken from alperite and can probably be simplified to include everything - installPhase = '' - mkdir -p $out - - # Glob will match all subdirs. - shopt -s globstar - - cp -r --parents -t $out/ \ - include/codec \ - include/config \ - include/core \ - include/effects \ - include/gpu \ - include/private \ - include/utils \ - include/c \ - out/Release/*.a \ - src/gpu/**/*.h \ - third_party/externals/angle2/include \ - third_party/skcms/**/*.h - ''; - }; + # TODO: these includes were taken from alperite and can probably be simplified to include everything + installPhase = '' + mkdir -p $out + + # Glob will match all subdirs. + shopt -s globstar + + cp -r --parents -t $out/ \ + include/codec \ + include/config \ + include/core \ + include/effects \ + include/gpu \ + include/private \ + include/utils \ + include/c \ + out/Release/*.a \ + src/gpu/**/*.h \ + third_party/externals/angle2/include \ + third_party/skcms/**/*.h + ''; + }; h2spec = self.buildGoModule { pname = "h2spec"; From ae361c0feaf8f16530461c4d20f2d12806459c11 Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Fri, 21 Jul 2023 19:37:26 -0400 Subject: [PATCH 05/12] make cpu and host os dynamic --- overlay/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/overlay/default.nix b/overlay/default.nix index 0941c92ff..8af0a3314 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -153,7 +153,6 @@ in rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; }; - nativeBuildInputs = with self; [ gn ninja @@ -169,6 +168,10 @@ in darwin.apple_sdk.frameworks.OpenGL # TODO handle ios, android #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation + ] ++ + lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ darwin.cctools ]; + patches = lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ + ../ocaml/revery/patches/0002-esy-skia-use-libtool.patch ]; preConfigure = @@ -195,7 +198,7 @@ in configurePhase = '' runHook preConfigure gn gen out/Release \ - --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] target_cpu="arm64" host_os="mac" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true' + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' runHook postConfigure ''; buildPhase = '' From 17064e52edfa7fea07867f4ce115ed9b670b84f0 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Fri, 21 Jul 2023 17:36:33 -0700 Subject: [PATCH 06/12] try to run tests --- .github/workflows/pipeline.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 59d07e7ba..4cf1cee7f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -47,7 +47,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@fork + - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} @@ -77,7 +77,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@fork + - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} @@ -107,7 +107,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@fork + - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} @@ -142,7 +142,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@fork + - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} From f7fcd7c8281cff2cf96d5fbb0180dec31dfa21e8 Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Thu, 20 Jul 2023 00:49:39 -0400 Subject: [PATCH 07/12] add linux support --- ocaml/revery/reason-harfbuzz.nix | 3 +- ocaml/revery/reason-sdl2.nix | 19 ++- ocaml/revery/reason-skia.nix | 10 +- overlay/default.nix | 196 +++++++++++++++++-------------- 4 files changed, 136 insertions(+), 92 deletions(-) diff --git a/ocaml/revery/reason-harfbuzz.nix b/ocaml/revery/reason-harfbuzz.nix index 75c1fe158..2e2d9e44b 100644 --- a/ocaml/revery/reason-harfbuzz.nix +++ b/ocaml/revery/reason-harfbuzz.nix @@ -17,7 +17,8 @@ buildDunePackage { buildInputs = [ dune-configurator ] ++ lib.optionals stdenv.isDarwin - (with darwin.apple_sdk.frameworks; [ Foundation AppKit ]); + (with darwin.apple_sdk.frameworks; + lib.optionals stdenv.isDarwin [ Foundation AppKit ]); nativeBuildInputs = [ reason pkg-config diff --git a/ocaml/revery/reason-sdl2.nix b/ocaml/revery/reason-sdl2.nix index 1d41ed0ae..dcb8b0668 100644 --- a/ocaml/revery/reason-sdl2.nix +++ b/ocaml/revery/reason-sdl2.nix @@ -10,7 +10,12 @@ , lib , stdenv , libcxx - +, libGLU +, libXxf86vm +, libXcursor +, libXrandr +, libXinerama +, libXi }: buildDunePackage rec { @@ -35,9 +40,19 @@ buildDunePackage rec { dune-configurator # SDL2 # SDL2.dev + libiconv + ] ++ + lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa darwin.apple_sdk.frameworks.ForceFeedback - libiconv + ] ++ + lib.optionals stdenv.isLinux [ + libGLU + libXxf86vm + libXcursor + libXrandr + libXinerama + libXi ]; nativeBuildInputs = [ reason diff --git a/ocaml/revery/reason-skia.nix b/ocaml/revery/reason-skia.nix index 377d3c163..19ece1834 100644 --- a/ocaml/revery/reason-skia.nix +++ b/ocaml/revery/reason-skia.nix @@ -10,6 +10,8 @@ , reason , reason-sdl2 , SDL2 +, lib +, stdenv }: buildDunePackage { @@ -27,12 +29,14 @@ buildDunePackage { nativeBuildInputs = [ reason pkg-config ]; buildInputs = [ dune-configurator ]; propagatedBuildInputs = with darwin.apple_sdk.frameworks; [ - AppKit - Cocoa - ForceFeedback libiconv reason-sdl2 ctypes + ] ++ + lib.optionals stdenv.isDarwin [ + AppKit + Cocoa + ForceFeedback ]; SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; SDL2_LIB_PATH = "${SDL2.override { withStatic = true; }}/lib"; diff --git a/overlay/default.nix b/overlay/default.nix index 8af0a3314..63cd1b126 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -153,7 +153,7 @@ in rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; }; - nativeBuildInputs = with self; [ + nativeBuildInputs = with self; ([ gn ninja libjpeg @@ -163,42 +163,53 @@ in expat # TODO: add optional webp support #libwebp + # TODO handle ios, android + #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation + ] ++ + lib.optionals stdenv.isDarwin [ + darwin.cctools darwin.apple_sdk.frameworks.ApplicationServices darwin.apple_sdk.frameworks.AppKit darwin.apple_sdk.frameworks.OpenGL # TODO handle ios, android #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation ] ++ - lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ darwin.cctools ]; + lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ darwin.cctools ] + ); patches = lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ ../ocaml/revery/patches/0002-esy-skia-use-libtool.patch ]; - preConfigure = let - angle2 = fetchgit { - url = "https://chromium.googlesource.com/angle/angle.git"; - rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; - sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; - }; - piex = fetchgit { - url = "https://android.googlesource.com/platform/external/piex.git"; - rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; - sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; - }; + angle2 = fetchgit + { + url = "https://chromium.googlesource.com/angle/angle.git"; + rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; + sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; + }; + piex = fetchgit + { + url = "https://android.googlesource.com/platform/external/piex.git"; + rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; + sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; + }; in '' - mkdir -p third_party/externals - ln -s ${angle2} third_party/externals/angle2 - ln -s ${piex} third_party/externals/piex + mkdir -p third_party/externals + ln -s ${angle2} third_party/externals/angle2 + ln -s ${piex} third_party/externals/piex + + substituteInPlace gn/BUILDCONFIG.gn --replace "gn/is_clang.py" "is_clang.py" + substituteInPlace gn/is_clang.py --replace "print 'true'" "print('true')" + substituteInPlace gn/is_clang.py --replace "print 'false'" "print('false')" + substituteInPlace gn/is_clang.py --replace "shell=True)" "shell=True).decode(sys.stdout.eding)" ''; - #TODO: built this based on feature flags, with sane defaults per os #TODO: enable more features configurePhase = '' runHook preConfigure gn gen out/Release \ - --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' runHook postConfigure ''; buildPhase = '' @@ -230,18 +241,19 @@ in ''; }; - h2spec = self.buildGoModule { - pname = "h2spec"; - version = "dev"; - - src = fetchFromGitHub { - owner = "summerwind"; - repo = "h2spec"; - rev = "af83a65f0b"; - sha256 = "sha256-z06uQiImMD4nPLp4Qxka9JT9NTmY0AurnHQKhB/kM40="; + h2spec = self.buildGoModule + { + pname = "h2spec"; + version = "dev"; + + src = fetchFromGitHub { + owner = "summerwind"; + repo = "h2spec"; + rev = "af83a65f0b"; + sha256 = "sha256-z06uQiImMD4nPLp4Qxka9JT9NTmY0AurnHQKhB/kM40="; + }; + vendorSha256 = "sha256-YSaLOYIHgMCK2hXSDL+aoBEfOX7j6rnJ4DMWg0jhzWY="; }; - vendorSha256 = "sha256-YSaLOYIHgMCK2hXSDL+aoBEfOX7j6rnJ4DMWg0jhzWY="; - }; h3spec = haskell.lib.compose.justStaticExecutables (haskellPackages.callPackage @@ -298,71 +310,83 @@ in pnpm = let inherit (self) - writeScriptBin runtimeShell nodejs_latest nodePackages_latest; + writeScriptBin + runtimeShell + nodejs_latest + nodePackages_latest; in - writeScriptBin "pnpm" '' - #!${runtimeShell} - ${nodejs_latest}/bin/node \ - ${nodePackages_latest.pnpm}/lib/node_modules/pnpm/bin/pnpm.cjs \ - "$@" - ''; + writeScriptBin + "pnpm" + '' + #!${runtimeShell} + ${nodejs_latest}/bin/node \ + ${nodePackages_latest.pnpm}/lib/node_modules/pnpm/bin/pnpm.cjs \ + "$@" + ''; - rdkafka = super.rdkafka.overrideAttrs (_: { - src = super.fetchFromGitHub { - owner = "confluentinc"; - repo = "librdkafka"; - rev = "v2.2.0"; - hash = "sha256-v/FjnDg22ZNQHmrUsPvjaCs4UQ/RPAxQdg9i8k6ba/4="; - }; - }); + rdkafka = super.rdkafka.overrideAttrs + (_: { + src = super.fetchFromGitHub { + owner = "confluentinc"; + repo = "librdkafka"; + rev = "v2.2.0"; + hash = "sha256-v/FjnDg22ZNQHmrUsPvjaCs4UQ/RPAxQdg9i8k6ba/4="; + }; + }); melange-relay-compiler = let - inherit (super) rustPlatform darwin pkg-config openssl; - melange-relay-compiler-src = stdenv.mkDerivation { - name = "melange-relay-compiler-src"; - src = fetchFromGitHub { - owner = "anmonteiro"; - repo = "relay"; - rev = "59b2edc6a9332ec83b79166bd6b1c9535d4bf6ab"; - hash = "sha256-3uN/oPMJd5bTCrINzGpkApb5fRTKj6TwPE6NCcXf95g="; - sparseCheckout = [ "compiler" ]; + inherit (super) + rustPlatform + darwin + pkg-config + openssl; + melange-relay-compiler-src = stdenv.mkDerivation + { + name = "melange-relay-compiler-src"; + src = fetchFromGitHub { + owner = "anmonteiro"; + repo = "relay"; + rev = "59b2edc6a9332ec83b79166bd6b1c9535d4bf6ab"; + hash = "sha256-3uN/oPMJd5bTCrINzGpkApb5fRTKj6TwPE6NCcXf95g="; + sparseCheckout = [ "compiler" ]; + }; + # patches = [ ./reason-relay-cargo.patch ]; + dontBuild = true; + installPhase = '' + mkdir $out + cp -r ./* $out + ''; }; - # patches = [ ./reason-relay-cargo.patch ]; - dontBuild = true; - installPhase = '' - mkdir $out - cp -r ./* $out - ''; - }; in - rustPlatform.buildRustPackage { - pname = "relay"; - version = "n/a"; - src = "${melange-relay-compiler-src}/compiler"; - cargoHash = "sha256-iyFSsvw3+YCiJz43XVE2IhvooimWdNvuLsBKPtC5EWk="; - - nativeBuildInputs = lib.optionals stdenv.isLinux [ pkg-config ]; - # Needed to get openssl-sys to use pkg-config. - # Doesn't seem to like OpenSSL 3 - OPENSSL_NO_VENDOR = 1; - - buildInputs = lib.optionals stdenv.isLinux [ openssl ]; - propagatedBuildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; - - postInstall = '' - mv $out/bin/relay $out/bin/melange-relay-compiler - ln -sf $out/bin/melange-relay-compiler $out/bin/melrelay - ''; - doCheck = false; - meta = with lib; { - description = "Melange Relay compiler"; - homepage = "https://github.com/anmonteiro/relay"; - maintainers = [ maintainers.anmonteiro ]; + rustPlatform.buildRustPackage + { + pname = "relay"; + version = "n/a"; + src = "${melange-relay-compiler-src}/compiler"; + cargoHash = "sha256-iyFSsvw3+YCiJz43XVE2IhvooimWdNvuLsBKPtC5EWk="; + + nativeBuildInputs = lib.optionals stdenv.isLinux [ pkg-config ]; + # Needed to get openssl-sys to use pkg-config. + # Doesn't seem to like OpenSSL 3 + OPENSSL_NO_VENDOR = 1; + + buildInputs = lib.optionals stdenv.isLinux [ openssl ]; + propagatedBuildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; + + postInstall = '' + mv $out/bin/relay $out/bin/melange-relay-compiler + ln -sf $out/bin/melange-relay-compiler $out/bin/melrelay + ''; + doCheck = false; + meta = with lib; { + description = "Melange Relay compiler"; + homepage = "https://github.com/anmonteiro/relay"; + maintainers = [ maintainers.anmonteiro ]; + }; }; - }; } // ( lib.mapAttrs' (n: p: lib.nameValuePair "${n}-oc" p) From 3d020e6fb8961751b4f616b0df315e94270bd17d Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Thu, 20 Jul 2023 01:36:00 -0400 Subject: [PATCH 08/12] more linux fixes --- ocaml/default.nix | 13 ++++++++++++- ocaml/revery/default.nix | 2 +- ocaml/revery/reason-skia.nix | 29 ++++++++++++++++++++++++++++- overlay/default.nix | 12 ++++++++---- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ocaml/default.nix b/ocaml/default.nix index 6b0e99c04..c53070ada 100644 --- a/ocaml/default.nix +++ b/ocaml/default.nix @@ -46,6 +46,7 @@ , libxcb , xorg , zstd-oc +, libfontconfig }: oself: osuper: @@ -309,6 +310,14 @@ with oself; }; }; + fontconfig = osuper.fontconfig.overrideAttrs (o: { + postPatch = + if lib.versionAtLeast ocaml.version "5.0" then '' + substituteInPlace extract_consts.ml --replace "String.lowercase" "String.lowercase_ascii" + substituteInPlace extract_consts.ml --replace "String.capitalize" "String.capitalize_ascii" + '' else ""; + }); + camlimages = osuper.camlimages.overrideAttrs (o: { buildInputs = o.buildInputs ++ [ findlib ]; postPatch = @@ -1586,7 +1595,9 @@ with oself; reason-harfbuzz = callPackage ./revery/reason-harfbuzz.nix { }; reason-sdl2 = callPackage ./revery/reason-sdl2.nix { }; - reason-skia = callPackage ./revery/reason-skia.nix { }; + reason-skia = callPackage ./revery/reason-skia.nix { + inherit libfontconfig; + }; revery = callPackage ./revery { }; rench = buildDunePackage { diff --git a/ocaml/revery/default.nix b/ocaml/revery/default.nix index 3776a1be1..6178677a1 100644 --- a/ocaml/revery/default.nix +++ b/ocaml/revery/default.nix @@ -56,7 +56,7 @@ buildDunePackage { # This supresses a warning from the use of CAMLparam2, where caml__frame is unused: # dialog.c:32:5: error: unused variable 'caml__frame' [-Werror,-Wunused-variable] # TODO: try to suppress this for the single file - substituteInPlace src/Native/dune --replace "-Werror" "-Werror\n -Wno-unused-variable" + substituteInPlace src/Native/dune --replace "-Werror" "-Werror -Wno-unused-variable" ''; buildInputs = [ dune-configurator diff --git a/ocaml/revery/reason-skia.nix b/ocaml/revery/reason-skia.nix index 19ece1834..e49d339e0 100644 --- a/ocaml/revery/reason-skia.nix +++ b/ocaml/revery/reason-skia.nix @@ -12,6 +12,17 @@ , SDL2 , lib , stdenv +, libGLU +, libXxf86vm +, libXcursor +, libXrandr +, libXinerama +, libXi +, zlib +, bzip2 +, fontconfig +, findlib +, libfontconfig }: buildDunePackage { @@ -27,7 +38,9 @@ buildDunePackage { ''; nativeBuildInputs = [ reason pkg-config ]; - buildInputs = [ dune-configurator ]; + buildInputs = [ + dune-configurator + ]; propagatedBuildInputs = with darwin.apple_sdk.frameworks; [ libiconv reason-sdl2 @@ -37,6 +50,19 @@ buildDunePackage { AppKit Cocoa ForceFeedback + ] ++ + lib.optionals stdenv.isLinux [ + libfontconfig + #findlib + #builtins.trace "fontconfig" fontconfig + libGLU + libXxf86vm + libXcursor + libXrandr + libXinerama + libXi + zlib + bzip2 ]; SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; SDL2_LIB_PATH = "${SDL2.override { withStatic = true; }}/lib"; @@ -44,4 +70,5 @@ buildDunePackage { SKIA_LIB_PATH = "${esy-skia}/out/Release"; JPEG_LIB_PATH = "${(libjpeg.override { enableStatic = true; }).out}/lib"; FREETYPE2_LIB_PATH = "${freetype}/lib"; + FREETYPE2_INCLUDE_PATH = "${freetype}/include"; } diff --git a/overlay/default.nix b/overlay/default.nix index 63cd1b126..c5b4bcaf6 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -16,7 +16,8 @@ let fetchgit buildGoModule haskell - haskellPackages; + haskellPackages + fontconfig; overlayOCamlPackages = attrs: import ../ocaml/overlay-ocaml-packages.nix (attrs // { inherit nixpkgs; @@ -24,7 +25,9 @@ let staticLightExtend = pkgSet: pkgSet.extend (self: super: super.lib.overlayOCamlPackages { inherit super; - overlays = [ (super.callPackage ../static/ocaml.nix { }) ]; + overlays = [ + (super.callPackage ../static/ocaml.nix { }) + ]; updateOCamlPackages = true; }); @@ -36,6 +39,7 @@ in (callPackage ../ocaml { inherit nixpkgs; super-opaline = super.opaline; + libfontconfig = fontconfig; }) ]; }) // { @@ -202,14 +206,14 @@ in substituteInPlace gn/BUILDCONFIG.gn --replace "gn/is_clang.py" "is_clang.py" substituteInPlace gn/is_clang.py --replace "print 'true'" "print('true')" substituteInPlace gn/is_clang.py --replace "print 'false'" "print('false')" - substituteInPlace gn/is_clang.py --replace "shell=True)" "shell=True).decode(sys.stdout.eding)" + substituteInPlace gn/is_clang.py --replace "shell=True)" "shell=True).decode(sys.stdout.encoding)" ''; #TODO: built this based on feature flags, with sane defaults per os #TODO: enable more features configurePhase = '' runHook preConfigure gn gen out/Release \ - --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=true skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=${lib.trivial.boolToString stdenv.isDarwin} skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' runHook postConfigure ''; buildPhase = '' From 4e275cf461939aca5dd72d8bd75e7503b7ef4e43 Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Thu, 20 Jul 2023 02:08:17 -0400 Subject: [PATCH 09/12] working on linux --- overlay/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/overlay/default.nix b/overlay/default.nix index c5b4bcaf6..8480e78c1 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -170,6 +170,10 @@ in # TODO handle ios, android #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation ] ++ + lib.optionals stdenv.isLinux [ + fontconfig + freetype + ] ++ lib.optionals stdenv.isDarwin [ darwin.cctools darwin.apple_sdk.frameworks.ApplicationServices From 8107f52b27a79fae7d4f552c63434a10edac3df4 Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Fri, 21 Jul 2023 23:50:01 -0400 Subject: [PATCH 10/12] cleanup --- ocaml/default.nix | 8 -- ocaml/revery/reason-sdl2.nix | 3 - ocaml/revery/reason-skia.nix | 2 - overlay/default.nix | 190 ++++++++++++++++------------------- 4 files changed, 88 insertions(+), 115 deletions(-) diff --git a/ocaml/default.nix b/ocaml/default.nix index c53070ada..5174a927c 100644 --- a/ocaml/default.nix +++ b/ocaml/default.nix @@ -310,14 +310,6 @@ with oself; }; }; - fontconfig = osuper.fontconfig.overrideAttrs (o: { - postPatch = - if lib.versionAtLeast ocaml.version "5.0" then '' - substituteInPlace extract_consts.ml --replace "String.lowercase" "String.lowercase_ascii" - substituteInPlace extract_consts.ml --replace "String.capitalize" "String.capitalize_ascii" - '' else ""; - }); - camlimages = osuper.camlimages.overrideAttrs (o: { buildInputs = o.buildInputs ++ [ findlib ]; postPatch = diff --git a/ocaml/revery/reason-sdl2.nix b/ocaml/revery/reason-sdl2.nix index dcb8b0668..0ed71b95b 100644 --- a/ocaml/revery/reason-sdl2.nix +++ b/ocaml/revery/reason-sdl2.nix @@ -56,15 +56,12 @@ buildDunePackage rec { ]; nativeBuildInputs = [ reason - # SDL2 - # SDL2.dev findlib ]; propagatedBuildInputs = [ SDL2 SDL2.dev ctypes - # findlib ]; SDL2_LIB_PATH = ''${(SDL2.override { withStatic = true; }).out}/lib''; SDL2_INCLUDE_PATH = "${SDL2.dev}/include"; diff --git a/ocaml/revery/reason-skia.nix b/ocaml/revery/reason-skia.nix index e49d339e0..7e98f41a2 100644 --- a/ocaml/revery/reason-skia.nix +++ b/ocaml/revery/reason-skia.nix @@ -53,8 +53,6 @@ buildDunePackage { ] ++ lib.optionals stdenv.isLinux [ libfontconfig - #findlib - #builtins.trace "fontconfig" fontconfig libGLU libXxf86vm libXcursor diff --git a/overlay/default.nix b/overlay/default.nix index 8480e78c1..fc704aaca 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -25,9 +25,7 @@ let staticLightExtend = pkgSet: pkgSet.extend (self: super: super.lib.overlayOCamlPackages { inherit super; - overlays = [ - (super.callPackage ../static/ocaml.nix { }) - ]; + overlays = [ (super.callPackage ../static/ocaml.nix { }) ]; updateOCamlPackages = true; }); @@ -157,7 +155,7 @@ in rev = "29349b9279ed24a73ec41acd7082caea9bd8c04e"; sha256 = "sha256-VyY1clAdTEZu0cFy/+Bw19OQ4lb55s4gIV/7TsFKdnk="; }; - nativeBuildInputs = with self; ([ + nativeBuildInputs = with self; [ gn ninja libjpeg @@ -182,34 +180,35 @@ in # TODO handle ios, android #-framework CoreServices -framework CoreGraphics -framework CoreText -framework CoreFoundation ] ++ - lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ darwin.cctools ] - ); + lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ darwin.cctools ]; + patches = lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ ../ocaml/revery/patches/0002-esy-skia-use-libtool.patch ]; preConfigure = let - angle2 = fetchgit - { - url = "https://chromium.googlesource.com/angle/angle.git"; - rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; - sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; - }; - piex = fetchgit - { - url = "https://android.googlesource.com/platform/external/piex.git"; - rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; - sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; - }; + angle2 = fetchgit { + url = "https://chromium.googlesource.com/angle/angle.git"; + rev = "47b3db22be33213eea4ad58f2453ee1088324ceb"; + sha256 = "sha256-ZF5wDOqh3cRfQGwOMay//4aWh9dBWk/cLmUsx+Ab2vw="; + }; + piex = fetchgit { + url = "https://android.googlesource.com/platform/external/piex.git"; + rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406"; + sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412"; + }; in '' - mkdir -p third_party/externals - ln -s ${angle2} third_party/externals/angle2 - ln -s ${piex} third_party/externals/piex + mkdir -p third_party/externals + ln -s ${angle2} third_party/externals/angle2 + ln -s ${piex} third_party/externals/piex + # this file is incorrectly referenced as paths are relative when gn runs in the folder substituteInPlace gn/BUILDCONFIG.gn --replace "gn/is_clang.py" "is_clang.py" + # python 3 compat substituteInPlace gn/is_clang.py --replace "print 'true'" "print('true')" substituteInPlace gn/is_clang.py --replace "print 'false'" "print('false')" + # python 3 returns raw binary instead of an ecoded string substituteInPlace gn/is_clang.py --replace "shell=True)" "shell=True).decode(sys.stdout.encoding)" ''; #TODO: built this based on feature flags, with sane defaults per os @@ -217,7 +216,7 @@ in configurePhase = '' runHook preConfigure gn gen out/Release \ - --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=${lib.trivial.boolToString stdenv.isDarwin} skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=${lib.trivial.boolToString stdenv.isDarwin} skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' runHook postConfigure ''; buildPhase = '' @@ -249,19 +248,18 @@ in ''; }; - h2spec = self.buildGoModule - { - pname = "h2spec"; - version = "dev"; - - src = fetchFromGitHub { - owner = "summerwind"; - repo = "h2spec"; - rev = "af83a65f0b"; - sha256 = "sha256-z06uQiImMD4nPLp4Qxka9JT9NTmY0AurnHQKhB/kM40="; - }; - vendorSha256 = "sha256-YSaLOYIHgMCK2hXSDL+aoBEfOX7j6rnJ4DMWg0jhzWY="; + h2spec = self.buildGoModule { + pname = "h2spec"; + version = "dev"; + + src = fetchFromGitHub { + owner = "summerwind"; + repo = "h2spec"; + rev = "af83a65f0b"; + sha256 = "sha256-z06uQiImMD4nPLp4Qxka9JT9NTmY0AurnHQKhB/kM40="; }; + vendorSha256 = "sha256-YSaLOYIHgMCK2hXSDL+aoBEfOX7j6rnJ4DMWg0jhzWY="; + }; h3spec = haskell.lib.compose.justStaticExecutables (haskellPackages.callPackage @@ -318,83 +316,71 @@ in pnpm = let inherit (self) - writeScriptBin - runtimeShell - nodejs_latest - nodePackages_latest; + writeScriptBin runtimeShell nodejs_latest nodePackages_latest; in - writeScriptBin - "pnpm" - '' - #!${runtimeShell} - ${nodejs_latest}/bin/node \ - ${nodePackages_latest.pnpm}/lib/node_modules/pnpm/bin/pnpm.cjs \ - "$@" - ''; + writeScriptBin "pnpm" '' + #!${runtimeShell} + ${nodejs_latest}/bin/node \ + ${nodePackages_latest.pnpm}/lib/node_modules/pnpm/bin/pnpm.cjs \ + "$@" + ''; - rdkafka = super.rdkafka.overrideAttrs - (_: { - src = super.fetchFromGitHub { - owner = "confluentinc"; - repo = "librdkafka"; - rev = "v2.2.0"; - hash = "sha256-v/FjnDg22ZNQHmrUsPvjaCs4UQ/RPAxQdg9i8k6ba/4="; - }; - }); + rdkafka = super.rdkafka.overrideAttrs (_: { + src = super.fetchFromGitHub { + owner = "confluentinc"; + repo = "librdkafka"; + rev = "v2.2.0"; + hash = "sha256-v/FjnDg22ZNQHmrUsPvjaCs4UQ/RPAxQdg9i8k6ba/4="; + }; + }); melange-relay-compiler = let - inherit (super) - rustPlatform - darwin - pkg-config - openssl; - melange-relay-compiler-src = stdenv.mkDerivation - { - name = "melange-relay-compiler-src"; - src = fetchFromGitHub { - owner = "anmonteiro"; - repo = "relay"; - rev = "59b2edc6a9332ec83b79166bd6b1c9535d4bf6ab"; - hash = "sha256-3uN/oPMJd5bTCrINzGpkApb5fRTKj6TwPE6NCcXf95g="; - sparseCheckout = [ "compiler" ]; - }; - # patches = [ ./reason-relay-cargo.patch ]; - dontBuild = true; - installPhase = '' - mkdir $out - cp -r ./* $out - ''; + inherit (super) rustPlatform darwin pkg-config openssl; + melange-relay-compiler-src = stdenv.mkDerivation { + name = "melange-relay-compiler-src"; + src = fetchFromGitHub { + owner = "anmonteiro"; + repo = "relay"; + rev = "59b2edc6a9332ec83b79166bd6b1c9535d4bf6ab"; + hash = "sha256-3uN/oPMJd5bTCrINzGpkApb5fRTKj6TwPE6NCcXf95g="; + sparseCheckout = [ "compiler" ]; }; + # patches = [ ./reason-relay-cargo.patch ]; + dontBuild = true; + installPhase = '' + mkdir $out + cp -r ./* $out + ''; + }; in - rustPlatform.buildRustPackage - { - pname = "relay"; - version = "n/a"; - src = "${melange-relay-compiler-src}/compiler"; - cargoHash = "sha256-iyFSsvw3+YCiJz43XVE2IhvooimWdNvuLsBKPtC5EWk="; - - nativeBuildInputs = lib.optionals stdenv.isLinux [ pkg-config ]; - # Needed to get openssl-sys to use pkg-config. - # Doesn't seem to like OpenSSL 3 - OPENSSL_NO_VENDOR = 1; - - buildInputs = lib.optionals stdenv.isLinux [ openssl ]; - propagatedBuildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; + rustPlatform.buildRustPackage { + pname = "relay"; + version = "n/a"; + src = "${melange-relay-compiler-src}/compiler"; + cargoHash = "sha256-iyFSsvw3+YCiJz43XVE2IhvooimWdNvuLsBKPtC5EWk="; + + nativeBuildInputs = lib.optionals stdenv.isLinux [ pkg-config ]; + # Needed to get openssl-sys to use pkg-config. + # Doesn't seem to like OpenSSL 3 + OPENSSL_NO_VENDOR = 1; + + buildInputs = lib.optionals stdenv.isLinux [ openssl ]; + propagatedBuildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; - postInstall = '' - mv $out/bin/relay $out/bin/melange-relay-compiler - ln -sf $out/bin/melange-relay-compiler $out/bin/melrelay - ''; - doCheck = false; - meta = with lib; { - description = "Melange Relay compiler"; - homepage = "https://github.com/anmonteiro/relay"; - maintainers = [ maintainers.anmonteiro ]; - }; + postInstall = '' + mv $out/bin/relay $out/bin/melange-relay-compiler + ln -sf $out/bin/melange-relay-compiler $out/bin/melrelay + ''; + doCheck = false; + meta = with lib; { + description = "Melange Relay compiler"; + homepage = "https://github.com/anmonteiro/relay"; + maintainers = [ maintainers.anmonteiro ]; }; + }; } // ( lib.mapAttrs' (n: p: lib.nameValuePair "${n}-oc" p) From 94b2148c021641d5aab1cc9123d689990359512a Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Sat, 22 Jul 2023 00:12:38 -0400 Subject: [PATCH 11/12] fix some flags --- overlay/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlay/default.nix b/overlay/default.nix index fc704aaca..05045f8d6 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -216,7 +216,7 @@ in configurePhase = '' runHook preConfigure gn gen out/Release \ - --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=${lib.trivial.boolToString stdenv.isDarwin} skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=false skia_use_freetype=false skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' + --args='is_debug=false is_official_build=true skia_use_egl=false skia_use_dng_sdk=false skia_enable_tools=false extra_asmflags=[] host_os="${if stdenv.isDarwin then "mac" else "linux"}" skia_enable_gpu=true skia_use_metal=${lib.trivial.boolToString stdenv.isDarwin} skia_use_vulkan=false skia_use_angle=false skia_use_fontconfig=${lib.trivial.boolToString stdenv.isLinux} skia_use_freetype=${lib.trivial.boolToString stdenv.isLinux} skia_enable_pdf=false skia_use_sfntly=false skia_use_icu=false skia_use_libwebp=false skia_use_libpng=true esy_skia_enable_svg=true target_cpu="${if stdenv.isAarch64 then "arm64" else "x86_64"}"' runHook postConfigure ''; buildPhase = '' From 4fbb6c5dab1fcbbc07df787c900d4999d66ac2bc Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 22 Jul 2023 14:42:28 -0700 Subject: [PATCH 12/12] s3-action --- .github/workflows/pipeline.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4cf1cee7f..59d07e7ba 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -47,7 +47,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb + - uses: nix-ocaml/nix-s3-action@fork with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} @@ -77,7 +77,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb + - uses: nix-ocaml/nix-s3-action@fork with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} @@ -107,7 +107,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb + - uses: nix-ocaml/nix-s3-action@fork with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }} @@ -142,7 +142,7 @@ jobs: system-features = nixos-test benchmark big-parallel kvm extra-substituters = https://anmonteiro.nix-cache.workers.dev extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= - - uses: nix-ocaml/nix-s3-action@e49ac4ebd0a75e58f9033aece4239733af1ee7cb + - uses: nix-ocaml/nix-s3-action@fork with: endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com" signingKey: ${{ secrets.R2_SIGNING_KEY }}