From 94e7ec4f6280a80e2e929db9aa3c00fe8e066684 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 10 Apr 2024 20:31:27 -0400 Subject: 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. --- Biz/Bild.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Biz/Bild.hs') diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 2ec0c7f..f8385c8 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -680,7 +680,10 @@ analyze hmap ns = case Map.lookup ns hmap of "--out-link", root nixdir Namespace.toPath namespace, "--builders", - toNixFlag builder + toNixFlag builder, + "--arg", + "bild", + str <| "import " <> root "Biz/Bild.nix {}" ] |> map Text.pack, out = Meta.None, @@ -1059,8 +1062,6 @@ nixBuild loud maxJobs cores target@(Target {..}) = >> run symlink x -> pure x where - argstr :: Text -> Text -> [Text] - argstr n v = ["--argstr", n, v] instantiate root = Proc { loud = loud, @@ -1070,7 +1071,8 @@ nixBuild loud maxJobs cores target@(Target {..}) = -- is tightly coupled with the code in the nix builder and there's no -- way around that, methinks. args = - [ argstr "analysisJSON" <| str <| Aeson.encode <| (Map.singleton namespace target :: Analysis), + [ ["--argstr", "analysisJSON", str <| Aeson.encode <| (Map.singleton namespace target :: Analysis)], + ["--arg", "bild", str <| "import " <> root "Biz/Bild.nix {}"], [str <| root "Biz/Bild/Builder.nix"] ] |> mconcat -- cgit v1.2.3