From f034ad709ba0de5a2e5ec6be47523f595e381d7a Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 18 Jul 2022 14:49:42 -0400 Subject: Move let bindings to 'private' This way I can still inspect and use them from the nix repl by just doing `:l Biz/Bild.nix`, but its also clear that they aren't part of the normal build rules. --- Biz/Bild.nix | 65 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'Biz') diff --git a/Biz/Bild.nix b/Biz/Bild.nix index a56ba4d..c007661 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -2,50 +2,51 @@ with import ./Bild/Constants.nix; -let - # provided by .envrc - root = builtins.getEnv "BIZ_ROOT"; +rec { + private = { + inherit nixpkgs; - selectAttrs = deps: packageSet: - nixpkgs.lib.attrsets.attrVals deps packageSet; + # provided by .envrc + root = builtins.getEnv "BIZ_ROOT"; - # returns true if a is a subset of b, where a and b are attrsets - subset = a: b: builtins.all - (x: builtins.elem x b) a; + selectAttrs = deps: packageSet: + nixpkgs.lib.attrsets.attrVals deps packageSet; - # 44 = lib.strings.stringLength "/nix/store/gia2r9mxhc900y1m97dlmr1g3rm3ich3-" - dropNixStore = s: nixpkgs.lib.strings.substring 44 (nixpkgs.lib.strings.stringLength s) s; + # returns true if a is a subset of b, where a and b are attrsets + subset = a: b: builtins.all + (x: builtins.elem x b) a; - haskellDeps = import ./Bild/Deps/Haskell.nix; + # 44 = lib.strings.stringLength "/nix/store/gia2r9mxhc900y1m97dlmr1g3rm3ich3-" + dropNixStore = s: nixpkgs.lib.strings.substring 44 (nixpkgs.lib.strings.stringLength s) s; - ghcWith = nixpkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; - #mkGhcjsPackageSet = nixpkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; + haskellDeps = import ./Bild/Deps/Haskell.nix; - ghcPackageSetFull = ghcWith haskellDeps; - ghcPackageSetBild = ghcWith (hpkgs: with hpkgs; [ - aeson async base bytestring conduit conduit-extra containers directory - docopt filepath process protolude rainbow regex-applicative split tasty - tasty-hunit tasty-quickcheck text - wai # can remove when removed from Biz.Log - ]); -in rec { - inherit (nixpkgs) lib stdenv sources; + ghcWith = nixpkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; + #mkGhcjsPackageSet = nixpkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; - inherit ghcWith; + ghcPackageSetFull = private.ghcWith private.haskellDeps; + ghcPackageSetBild = private.ghcWith (hpkgs: with hpkgs; [ + aeson async base bytestring conduit conduit-extra containers directory + docopt filepath process protolude rainbow regex-applicative split tasty + tasty-hunit tasty-quickcheck text + wai # can remove when removed from Biz.Log + ]); + }; + inherit (nixpkgs) lib stdenv sources; # a standard nix build for `bild` - this should be the only hand-written # builder we need bild = stdenv.mkDerivation { name = "bild"; src = ../.; - nativeBuildInputs = [ ghcPackageSetBild ]; + nativeBuildInputs = [ private.ghcPackageSetBild ]; buildInputs = [ nixpkgs.makeWrapper ]; strictDeps = true; buildPhase = '' - mkdir -p $out/bin $out/lib/ghc-${ghcPackageSetFull.version} + mkdir -p $out/bin $out/lib/ghc-${private.ghcPackageSetFull.version} cp -r \ - ${ghcPackageSetFull}/lib/ghc-${ghcPackageSetFull.version}/package.conf.d \ - $out/lib/ghc-${ghcPackageSetFull.version} + ${private.ghcPackageSetFull}/lib/ghc-${private.ghcPackageSetFull.version}/package.conf.d \ + $out/lib/ghc-${private.ghcPackageSetFull.version} ghc \ -Werror \ -i. \ @@ -55,9 +56,9 @@ in rec { ''; installPhase = '' wrapProgram $out/bin/bild \ - --prefix PATH : ${lib.makeBinPath [ ghcPackageSetBild ]} \ + --prefix PATH : ${lib.makeBinPath [ private.ghcPackageSetBild ]} \ --set GHC_PACKAGE_PATH \ - $out/lib/ghc-${ghcPackageSetFull.version}/package.conf.d + $out/lib/ghc-${private.ghcPackageSetFull.version}/package.conf.d ''; }; @@ -90,12 +91,12 @@ in rec { ghc = main: let data = analyze main; - ghc = ghcWith (hp: selectAttrs data.langdeps hp); + ghc = private.ghcWith (hp: private.selectAttrs data.langdeps hp); module = lib.strings.concatStringsSep "." data.namespace.path; in stdenv.mkDerivation { name = module; src = ../.; - nativeBuildInputs = [ ghc ] ++ selectAttrs data.sysdeps nixpkgs.pkgs; + nativeBuildInputs = [ ghc ] ++ private.selectAttrs data.sysdeps nixpkgs.pkgs; strictDeps = true; buildPhase = '' set -eux @@ -115,7 +116,7 @@ in rec { #ghcjs = main: # let # data = analyze main; - # ghcjs = mkGhcjsPackageSet (hp: selectAttrs data.deps hp); + # ghcjs = mkGhcjsPackageSet (hp: private.selectAttrs data.deps hp); # in stdenv.mkDerivation { # name = data.module; # src = ../.; -- cgit v1.2.3