From 1a47cf6ff0cbe6cc80e3497a68343b8ecb9228c1 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 24 Nov 2020 12:08:13 -0500 Subject: Add inspekt3d to guile deps, and reorganize I reorganized in order to debug a problem with the nix overlays. I think having small, focused overlayes is more understandable than one overlay that references itself via `rec`. Also the error traces are easier to follow with smaller overlays. --- Biz/Bild/Deps.nix | 115 +++++++++++++++++++---------------------- Biz/Bild/Deps/Haskell.nix | 61 ++++++++++++++++++++++ Biz/Bild/Deps/guile-opengl.nix | 39 ++++++++++++++ Biz/Bild/Deps/inspekt3d.nix | 41 +++++++++++++++ Biz/Bild/Deps/wemux.nix | 12 +++++ Biz/Bild/Nixpkgs.nix | 43 ++++++++++----- Biz/Bild/Overlay.nix | 63 ---------------------- Biz/Bild/Rules.nix | 15 ++++-- Biz/Bild/Sources.json | 8 +++ Biz/Bild/Wemux.nix | 12 ----- 10 files changed, 256 insertions(+), 153 deletions(-) create mode 100644 Biz/Bild/Deps/Haskell.nix create mode 100644 Biz/Bild/Deps/guile-opengl.nix create mode 100644 Biz/Bild/Deps/inspekt3d.nix create mode 100644 Biz/Bild/Deps/wemux.nix delete mode 100644 Biz/Bild/Overlay.nix delete mode 100644 Biz/Bild/Wemux.nix (limited to 'Biz/Bild') diff --git a/Biz/Bild/Deps.nix b/Biz/Bild/Deps.nix index ce75805..c37b4f5 100644 --- a/Biz/Bild/Deps.nix +++ b/Biz/Bild/Deps.nix @@ -1,61 +1,54 @@ -[ - "MonadRandom" - "QuickCheck" - "acid-state" - "aeson" - "async" - "bytestring" - # "capability" # broken deps - "clay" - "cmark" - "config-ini" - "containers" - "directory" - "ekg" - "envy" - "fast-logger" - "filepath" - "ghcjs-base" - "haskeline" - "http-types" - "ixset" - "katip" - "lucid" - "miso" - "monad-logger" - "monad-metrics" - "mtl" - "network-uri" - "optparse-simple" - "parsec" - "process" - "protolude" - "quickcheck-instances" - "random" - "regex-applicative" - "req" - "safecopy" - "scotty" - "servant" - "servant-auth" - "servant-auth-server" - "servant-lucid" - "servant-server" - "split" - "stm" - "string-quote" - "tasty" - "text" - "time" - "transformers" - "unagi-chan" - "unix" - "unordered-containers" - "vector" - "wai" - "wai-app-static" - "wai-extra" - "wai-middleware-metrics" - "warp" - "x509" -] +_: pkgs: + +let + simpleCabalBuilder = self: name: + self.callCabal2nix name pkgs.sources.${name} {}; + buildCabal = self: name: subdir: + if isNull subdir then + self.callCabal2nix name pkgs.sources.${name} {} + else + self.callCabal2nix name (pkgs.sources.${name} + "/${subdir}") {}; +in rec +{ + haskell = pkgs.haskell // { + packages = pkgs.haskell.packages // { + ghc865 = pkgs.haskell.packages.ghc865.override (old: { + overrides = with pkgs.pkgs.haskell.lib; self: super: + pkgs.overridePinnedDeps (simpleCabalBuilder self) // { + acid-state = dontCheck super.acid-state; # mac: "too many open files" + ghcjs-base = null; # otherwise ghc tries to build this via overridePinnedDeps + servant-auth = buildCabal self "servant-auth" "servant-auth"; + servant-server = doJailbreak super.servant-server; + temporary = dontCheck super.temporary; + wai-middleware-metrics = dontCheck super.wai-middleware-metrics; + }; + }); + ghcjs86 = pkgs.haskell.packages.ghcjs86.override (old: { + overrides = with pkgs.haskell.lib; self: super: + pkgs.overridePinnedDeps (simpleCabalBuilder self) // { + Glob = dontCheck super.Glob; + QuickCheck = dontCheck super.QuickCheck; + aeson = dontCheck super.aeson; + base-compat-batteries = dontCheck super.base-compat-batteries; + clay = dontCheck super.clay; + comonad = dontCheck super.comonad; + ghcjs-base = dontCheck (simpleCabalBuilder self "ghcjs-base"); + jsaddle-warp = dontCheck (self.callCabal2nix "jsaddle-warp" "${pkgs.sources.jsaddle}/jsaddle-warp" {}); + http-types = dontCheck super.http-types; + network-uri= dontCheck super.network-uri; + scientific = dontCheck super.scientific; # takes forever + servant = dontCheck super.servant; + servant-auth = buildCabal self "servant-auth" "servant-auth"; + tasty-quickcheck = dontCheck super.tasty-quickcheck; + temporary = dontCheck super.temporary; + time-compat = dontCheck super.time-compat; + vector = dontCheck super.vector; + }; + }); + }; + }; + + wemux = pkgs.callPackage ./Deps/wemux.nix {}; + guile-opengl = pkgs.callPackage ./Deps/guile-opengl.nix {}; + inspekt3d = pkgs.callPackage ./Deps/inspekt3d.nix {}; +} diff --git a/Biz/Bild/Deps/Haskell.nix b/Biz/Bild/Deps/Haskell.nix new file mode 100644 index 0000000..ce75805 --- /dev/null +++ b/Biz/Bild/Deps/Haskell.nix @@ -0,0 +1,61 @@ +[ + "MonadRandom" + "QuickCheck" + "acid-state" + "aeson" + "async" + "bytestring" + # "capability" # broken deps + "clay" + "cmark" + "config-ini" + "containers" + "directory" + "ekg" + "envy" + "fast-logger" + "filepath" + "ghcjs-base" + "haskeline" + "http-types" + "ixset" + "katip" + "lucid" + "miso" + "monad-logger" + "monad-metrics" + "mtl" + "network-uri" + "optparse-simple" + "parsec" + "process" + "protolude" + "quickcheck-instances" + "random" + "regex-applicative" + "req" + "safecopy" + "scotty" + "servant" + "servant-auth" + "servant-auth-server" + "servant-lucid" + "servant-server" + "split" + "stm" + "string-quote" + "tasty" + "text" + "time" + "transformers" + "unagi-chan" + "unix" + "unordered-containers" + "vector" + "wai" + "wai-app-static" + "wai-extra" + "wai-middleware-metrics" + "warp" + "x509" +] diff --git a/Biz/Bild/Deps/guile-opengl.nix b/Biz/Bild/Deps/guile-opengl.nix new file mode 100644 index 0000000..6b5df43 --- /dev/null +++ b/Biz/Bild/Deps/guile-opengl.nix @@ -0,0 +1,39 @@ +{ stdenv +, fetchurl +, pkgconfig +, guile +, libGL +, libGLU +, freeglut +}: + +let + name = "guile-opengl-${version}"; + version = "0.1.0"; +in stdenv.mkDerivation { + inherit name; + + src = fetchurl { + url = "mirror://gnu/guile-opengl/${name}.tar.gz"; + sha256 = "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"; + }; + + patchPhase = '' + substituteInPlace glx/runtime.scm \ + --replace '(dynamic-link "libGL")' '(dynamic-link "${libGL}/lib/libGL.so")' + substituteInPlace glu/runtime.scm \ + --replace '(dynamic-link "libGLU")' '(dynamic-link "${libGLU}/lib/libGLU.so")' + substituteInPlace glut/runtime.scm \ + --replace '(dynamic-link "libglut")' '(dynamic-link "${freeglut}/lib/libglut.so")' + ''; + + nativeBuildInputs = [ pkgconfig guile libGL libGLU freeglut ]; + + meta = with stdenv.lib; { + description = "Guile bindings for the OpenGL graphics API"; + homepage = "https://www.gnu.org/software/guile-opengl/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ vyp ]; + platforms = platforms.linux; + }; +} diff --git a/Biz/Bild/Deps/inspekt3d.nix b/Biz/Bild/Deps/inspekt3d.nix new file mode 100644 index 0000000..d51b6db --- /dev/null +++ b/Biz/Bild/Deps/inspekt3d.nix @@ -0,0 +1,41 @@ +{ stdenv +, fetchFromGitHub +, autoreconfHook +, pkgconfig +, guile +, guile-opengl +, mesa +, glibcLocales +, libfive +, sources +}: + + +stdenv.mkDerivation { + name = "inspekt3d-master"; + + src = sources.inspekt3d; + version = "master"; + + nativeBuildInputs = [ pkgconfig guile autoreconfHook ]; + buildInputs = [ guile glibcLocales mesa ]; + propagatedBuildInputs = [ guile-opengl libfive ]; + + preBuild = '' + substituteInPlace inspekt3d/library.scm \ + --replace '"libfive-guile"' '"${libfive}/lib/libfive-guile.so"' \ + --replace '"libfive"' '"${libfive}/lib/libfive.so"' + cat inspekt3d/library.scm + ''; + + preConfigure = "./bootstrap"; + + meta = with stdenv.lib; { + description = "Lightweight 3D viewer for Libfive written in Guile Scheme"; + homepage = "https://gitlab.com/kavalogic-inc/inspekt3d"; + license = licenses.gpl3; + maintainers = with maintainers; [ bsima ]; + platforms = platforms.linux; + }; +} + diff --git a/Biz/Bild/Deps/wemux.nix b/Biz/Bild/Deps/wemux.nix new file mode 100644 index 0000000..365853f --- /dev/null +++ b/Biz/Bild/Deps/wemux.nix @@ -0,0 +1,12 @@ +{ sources, stdenv }: + +stdenv.mkDerivation rec { + name = "wemux-${version}"; + version = "2020.04.03"; + src = sources.wemux; + installPhase = '' + mkdir -p $out/bin + cp ${src}/wemux $out/bin + chmod +x $out/bin/wemux + ''; +} diff --git a/Biz/Bild/Nixpkgs.nix b/Biz/Bild/Nixpkgs.nix index 88cf6ca..ffafe3f 100644 --- a/Biz/Bild/Nixpkgs.nix +++ b/Biz/Bild/Nixpkgs.nix @@ -1,16 +1,33 @@ let sources = import ./Sources.nix; - nixpkgs = import sources.nixpkgs { - system = __currentSystem; - overlays = [ - (_: _: { inherit sources; }) - (import ./Overlay.nix) - (_: pkgs: pkgs.overridePinnedDeps pkgs.overrideSource) - (_: _: { niv = import sources.niv {}; }) - (_: pkgs: { wemux = pkgs.callPackage ./Wemux.nix {}; }) - ]; - config = { - allowBroken = true; - }; +in +import sources.nixpkgs { + system = __currentSystem; + overlays = [ + (_: _: { inherit sources; }) + (_: pkgs: rec { + pinnedDeps = builtins.attrNames + (builtins.removeAttrs pkgs.sources ["__functor"]); + + overridePinnedDeps = builder: pkgs.lib.genAttrs pinnedDeps builder; + + # Modifies a derivation with our source and version, keeping old build + # rules. This will fail if build steps have changed, or if no build + # rules are available upstream.. + overrideSource = depName: + if pkgs ? depName then + pkgs.${depName}.overrideAttrs (old: old // rec { + name = "${depName}-${version}"; + version = pkgs.sources.${depName}.version or pkgs.sources.${depName}.rev; + src = pkgs.sources.${depName}; + }) + else null; + }) + (_: pkgs: pkgs.overridePinnedDeps pkgs.overrideSource) + (import ./Deps.nix) + (_: pkgs: { niv = import pkgs.sources.niv {}; }) + ]; + config = { + allowBroken = true; }; -in nixpkgs +} diff --git a/Biz/Bild/Overlay.nix b/Biz/Bild/Overlay.nix deleted file mode 100644 index dc52eab..0000000 --- a/Biz/Bild/Overlay.nix +++ /dev/null @@ -1,63 +0,0 @@ -_: pkgs: - -let - simpleCabalBuilder = self: name: - self.callCabal2nix name pkgs.sources.${name} {}; - buildCabal = self: name: subdir: - if isNull subdir then - self.callCabal2nix name pkgs.sources.${name} {} - else - self.callCabal2nix name (pkgs.sources.${name} + "/${subdir}") {}; -in rec -{ - pinnedDeps = builtins.attrNames - (builtins.removeAttrs pkgs.sources ["__functor"]); - overridePinnedDeps = builder: pkgs.lib.genAttrs pinnedDeps builder; - - # Modifies a derivation with our source and version, keeping old build - # rules. This will fail if build steps have changed, or if no build - # rules are available upstream.. - overrideSource = depName: pkgs.${depName}.overrideAttrs (old: old // rec { - name = "${depName}-${version}"; - version = pkgs.sources.${depName}.version or pkgs.sources.${depName}.rev; - src = pkgs.sources.${depName}; - }); - - haskell = pkgs.haskell // { - packages = pkgs.haskell.packages // { - ghc865 = pkgs.haskell.packages.ghc865.override (old: { - overrides = with pkgs.pkgs.haskell.lib; self: super: - overridePinnedDeps (simpleCabalBuilder self) // { - acid-state = dontCheck super.acid-state; # mac: "too many open files" - ghcjs-base = null; # otherwise ghc tries to build this via overridePinnedDeps - servant-auth = buildCabal self "servant-auth" "servant-auth"; - servant-server = doJailbreak super.servant-server; - temporary = dontCheck super.temporary; - wai-middleware-metrics = dontCheck super.wai-middleware-metrics; - }; - }); - ghcjs86 = pkgs.haskell.packages.ghcjs86.override (old: { - overrides = with pkgs.haskell.lib; self: super: - overridePinnedDeps (simpleCabalBuilder self) // { - Glob = dontCheck super.Glob; - QuickCheck = dontCheck super.QuickCheck; - aeson = dontCheck super.aeson; - base-compat-batteries = dontCheck super.base-compat-batteries; - clay = dontCheck super.clay; - comonad = dontCheck super.comonad; - ghcjs-base = dontCheck (simpleCabalBuilder self "ghcjs-base"); - jsaddle-warp = dontCheck (self.callCabal2nix "jsaddle-warp" "${pkgs.sources.jsaddle}/jsaddle-warp" {}); - http-types = dontCheck super.http-types; - network-uri= dontCheck super.network-uri; - scientific = dontCheck super.scientific; # takes forever - servant = dontCheck super.servant; - servant-auth = buildCabal self "servant-auth" "servant-auth"; - tasty-quickcheck = dontCheck super.tasty-quickcheck; - temporary = dontCheck super.temporary; - time-compat = dontCheck super.time-compat; - vector = dontCheck super.vector; - }; - }); - }; - }; -} diff --git a/Biz/Bild/Rules.nix b/Biz/Bild/Rules.nix index 2141fbf..1868313 100644 --- a/Biz/Bild/Rules.nix +++ b/Biz/Bild/Rules.nix @@ -17,7 +17,7 @@ let subset = a: b: builtins.all (x: builtins.elem x b) a; - allDeps = import ./Deps.nix; + haskellDeps = import ./Deps/Haskell.nix; # gather data needed for compiling by analyzing the main module analyze = main: rec { @@ -43,11 +43,11 @@ let }; mkGhc = compiler: (deps: compiler (hp: - if (subset deps allDeps) + if (subset deps haskellDeps) then depsToPackageSet hp deps else throw '' missing from nix/haskell-deps.nix: - ${toString (lib.lists.subtractLists allDeps deps)} + ${toString (lib.lists.subtractLists haskellDeps deps)} '')); ghc_ = mkGhc pkgs.haskell.packages.ghc865.ghcWithHoogle; @@ -104,7 +104,8 @@ in { env = mkShell { name = "bizdev"; buildInputs = [ - (ghc_ allDeps) + # haskell deps + (ghc_ haskellDeps) # ghcjs doesn't need everything, and many things fail to build (ghcjs_ [ "aeson" @@ -119,6 +120,12 @@ in { "ghcjs-base" ]) + # scheme deps + nixpkgs.guile + nixpkgs.inspekt3d + nixpkgs.libfive + + # tools nixpkgs.cmark nixpkgs.figlet nixpkgs.hlint diff --git a/Biz/Bild/Sources.json b/Biz/Bild/Sources.json index 0bb1068..d6228e4 100644 --- a/Biz/Bild/Sources.json +++ b/Biz/Bild/Sources.json @@ -25,6 +25,14 @@ "url_template": "https://github.com///archive/.tar.gz", "version": "18f31dec5d9eae1ef35ff8bbf163394942efd227" }, + "inspekt3d": { + "branch": "master", + "sha256": "0lan6930g5a9z4ack9jj0zdd0mb2s6q2xzpiwcjdc3pvl9b1nbw4", + "type": "tarball", + "url": "https://gitlab.com/kavalogic-inc/inspekt3d/-/archive/703f52ccbfedad2bf5240bf8183d1b573c9d54ef/inspekt3d-703f52ccbfedad2bf5240bf8183d1b573c9d54ef.tar.gz", + "url_template": "https://gitlab.com/kavalogic-inc/inspekt3d/-/archive//inspekt3d-.tar.gz", + "version": "703f52ccbfedad2bf5240bf8183d1b573c9d54ef" + }, "jsaddle": { "branch": "master", "description": "JavaScript interface that works with GHCJS or GHC", diff --git a/Biz/Bild/Wemux.nix b/Biz/Bild/Wemux.nix deleted file mode 100644 index 365853f..0000000 --- a/Biz/Bild/Wemux.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ sources, stdenv }: - -stdenv.mkDerivation rec { - name = "wemux-${version}"; - version = "2020.04.03"; - src = sources.wemux; - installPhase = '' - mkdir -p $out/bin - cp ${src}/wemux $out/bin - chmod +x $out/bin/wemux - ''; -} -- cgit v1.2.3