summaryrefslogtreecommitdiff
path: root/Biz/Bild
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-10 20:31:27 -0400
committerBen Sima <ben@bsima.me>2024-04-10 20:31:27 -0400
commit94e7ec4f6280a80e2e929db9aa3c00fe8e066684 (patch)
tree8a3d7ad4997e165ea0f7ff4f4923f78408ee28a0 /Biz/Bild
parenta6856775ad86d8f33d5d724a3843fb16e5a3551d (diff)
Explicitly pass Bild.nix to nix builds & expose references to stable
This change was motivated by my testing of tabbyAPI. I kept doing like `nix-build -A pkgs.tabbyAPI` and I thought, can't bild just do this? So I wrote a file called TabbyAPI.nix with the following contents:: { bild }: bild.pkgs.tabbyAPI and it worked, I just needed this change to Bild.hs to supply the `bild` argument. The benefit of using bild here is that I can get the logging, concurrency settings, and linking to _/nix etc all by default. Plus, using a standalone nix file like TabbyAPI.nix might be a good way to pin some package in the build system and make sure it continues to build, test, and so on. Also, thie means I don't sprinkle relative paths to the Bild.nix library throughout the repo, which is bad practice anyway. Re: explicitly exposing refernces to stable: This keeps things a bit more tidy and less confusing when working on the nix library.
Diffstat (limited to 'Biz/Bild')
-rw-r--r--Biz/Bild/Builder.nix25
1 files changed, 12 insertions, 13 deletions
diff --git a/Biz/Bild/Builder.nix b/Biz/Bild/Builder.nix
index d1fc48b..1a2460a 100644
--- a/Biz/Bild/Builder.nix
+++ b/Biz/Bild/Builder.nix
@@ -3,9 +3,9 @@
wouldn't you?
- Try to reuse as much upstream Nix as possible.
*/
-{ analysisJSON, bild ? import ../Bild.nix { } }:
+{ analysisJSON, bild }:
+with bild;
let
- lib = bild.lib;
analysis = builtins.fromJSON analysisJSON;
build = _: target:
let
@@ -53,29 +53,28 @@ let
sysdeps_ = if isEmpty target.sysdeps then
[ ]
else
- lib.attrsets.attrVals target.sysdeps bild.pkgs;
+ lib.attrsets.attrVals target.sysdeps pkgs;
rundeps_ = if isEmpty target.rundeps then
[ ]
else
- lib.attrsets.attrVals target.rundeps bild.pkgs;
+ lib.attrsets.attrVals target.rundeps pkgs;
CODEROOT = ".";
builders = {
- base = bild.stdenv.mkDerivation rec {
+ base = stdenv.mkDerivation rec {
inherit name src CODEROOT preBuild;
buildInputs = langdeps_ ++ sysdeps_;
installPhase = "install -D ${name} $out/bin/${name}";
buildPhase = compileLine;
};
- haskell = bild.stdenv.mkDerivation rec {
+ haskell = stdenv.mkDerivation rec {
inherit name src CODEROOT preBuild;
- nativeBuildInputs = [ bild.makeWrapper ];
+ nativeBuildInputs = [ makeWrapper ];
buildInputs = sysdeps_ ++ [
- (bild.haskell.ghcWith
- (p: (lib.attrsets.attrVals target.langdeps p)))
+ (haskell.ghcWith (p: (lib.attrsets.attrVals target.langdeps p)))
];
buildPhase = compileLine;
installPhase = ''
@@ -85,7 +84,7 @@ let
'';
};
- c = bild.stdenv.mkDerivation rec {
+ c = stdenv.mkDerivation rec {
inherit name src CODEROOT preBuild;
buildInputs = langdeps_ ++ sysdeps_;
installPhase = "install -D ${name} $out/bin/${name}";
@@ -106,11 +105,11 @@ let
];
};
- python = bild.python.buildPythonApplication rec {
+ python = python.buildPythonApplication rec {
inherit name src CODEROOT;
propagatedBuildInputs = langdeps_ ++ sysdeps_;
buildInputs = sysdeps_;
- nativeCheckInputs = lib.attrsets.attrVals [ "mypy" "ruff" ] bild.pkgs;
+ nativeCheckInputs = lib.attrsets.attrVals [ "mypy" "ruff" ] pkgs;
checkPhase = ''
check() {
$@ || { echo "fail: $name: $3"; exit 1; }
@@ -155,4 +154,4 @@ let
# return a single drv, so just take the first one for now. ideally i would only
# pass Target, one at a time, (perhaps parallelized in haskell land) and then i
# wouldn't need all of this let nesting
-in builtins.head (bild.lib.attrsets.mapAttrsToList build analysis)
+in builtins.head (lib.attrsets.mapAttrsToList build analysis)