summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-07-18 14:49:42 -0400
committerBen Sima <ben@bsima.me>2022-07-18 22:23:12 -0400
commitf034ad709ba0de5a2e5ec6be47523f595e381d7a (patch)
tree5950fa8a0cc35ad8c34930b7c7e4f8015641afe1 /Biz
parent2da57835006168e27b7f9b3226706c342df90f3a (diff)
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.
Diffstat (limited to 'Biz')
-rw-r--r--Biz/Bild.nix65
1 files changed, 33 insertions, 32 deletions
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 = ../.;