From d1f3c854b8d4b02ea4cfbaf553cd22d615a5ad6c Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Tue, 8 Oct 2024 17:29:22 +1300 Subject: [PATCH 1/6] Fix components in `build-type: Custom` packages These components may depend on the `library` component of the package however `plan.json` does not include that dependency (since cabal will build all the components at once). This fix adds the library component as a dependency of the other components. --- flake.nix | 2 +- lib/load-cabal-plan.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 15ee49425d..333cbfd5b9 100644 --- a/flake.nix +++ b/flake.nix @@ -90,7 +90,7 @@ let callFlake = import flake-compat; - ifdLevel = 3; + ifdLevel = 0; runningHydraEvalTest = false; compiler = "ghc928"; config = import ./config.nix; diff --git a/lib/load-cabal-plan.nix b/lib/load-cabal-plan.nix index 14ba6db55a..6970722823 100644 --- a/lib/load-cabal-plan.nix +++ b/lib/load-cabal-plan.nix @@ -47,7 +47,7 @@ let name = pkgs.lib.removePrefix "${prefix}:" n; value = (if cabal2nixComponents == null then {} else cabal2nixComponents.${collectionName}.${name}) // { buildable = true; - } // lookupDependencies hsPkgs c.depends c.exe-depends; + } // lookupDependencies hsPkgs (c.depends ++ pkgs.lib.optional (p ? components) p.id) c.exe-depends; in { inherit name value; } )) components)); in From 72dcba62936b4e5c4b8a4e870f188c1c2385beaa Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Tue, 8 Oct 2024 17:40:16 +1300 Subject: [PATCH 2/6] ifdLevel 1 --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 333cbfd5b9..ced3c36cab 100644 --- a/flake.nix +++ b/flake.nix @@ -90,7 +90,7 @@ let callFlake = import flake-compat; - ifdLevel = 0; + ifdLevel = 1; runningHydraEvalTest = false; compiler = "ghc928"; config = import ./config.nix; From 0ec25e0a00234cded1f28d2d680c76d83202c10a Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Tue, 8 Oct 2024 17:55:24 +1300 Subject: [PATCH 3/6] Add comment and only include library if there is one. --- lib/load-cabal-plan.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/load-cabal-plan.nix b/lib/load-cabal-plan.nix index 6970722823..adf3a6898d 100644 --- a/lib/load-cabal-plan.nix +++ b/lib/load-cabal-plan.nix @@ -47,7 +47,15 @@ let name = pkgs.lib.removePrefix "${prefix}:" n; value = (if cabal2nixComponents == null then {} else cabal2nixComponents.${collectionName}.${name}) // { buildable = true; - } // lookupDependencies hsPkgs (c.depends ++ pkgs.lib.optional (p ? components) p.id) c.exe-depends; + } // lookupDependencies hsPkgs ( + c.depends + # If plan.json uses a single unit for this package (build-type: Custom), + # then it will leave the package itself out of `c.depends` for the + # components of the package. + # Haskell.nix builds the components separately so we need + # to add the `library` component as a dependency. + ++ pkgs.lib.optional (p ? components && p.components ? lib) p.id + ) c.exe-depends; in { inherit name value; } )) components)); in From 06882f832504b69b10223345ad6c0957f5f0746d Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Tue, 8 Oct 2024 18:51:19 +1300 Subject: [PATCH 4/6] ifdLevel 2 --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ced3c36cab..62ae19c1e0 100644 --- a/flake.nix +++ b/flake.nix @@ -90,7 +90,7 @@ let callFlake = import flake-compat; - ifdLevel = 1; + ifdLevel = 2; runningHydraEvalTest = false; compiler = "ghc928"; config = import ./config.nix; From 3b28ee89bf413fe7231541e2c6e59c354a830d57 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 9 Oct 2024 01:39:06 +1300 Subject: [PATCH 5/6] ifdLevel 3 --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 62ae19c1e0..15ee49425d 100644 --- a/flake.nix +++ b/flake.nix @@ -90,7 +90,7 @@ let callFlake = import flake-compat; - ifdLevel = 2; + ifdLevel = 3; runningHydraEvalTest = false; compiler = "ghc928"; config = import ./config.nix; From 5eca2352cf06aebfc74e601404e4f6f0a9e9fe41 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 9 Oct 2024 12:52:37 +1300 Subject: [PATCH 6/6] Fix broken test --- test/setup-deps/pkg/src/Pkg.hs | 4 ++++ test/setup-deps/pkg/src/conduit-test.hs | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 test/setup-deps/pkg/src/Pkg.hs delete mode 100644 test/setup-deps/pkg/src/conduit-test.hs diff --git a/test/setup-deps/pkg/src/Pkg.hs b/test/setup-deps/pkg/src/Pkg.hs new file mode 100644 index 0000000000..fc1111aa2e --- /dev/null +++ b/test/setup-deps/pkg/src/Pkg.hs @@ -0,0 +1,4 @@ +module Pkg where + +foo :: Int +foo = 1 diff --git a/test/setup-deps/pkg/src/conduit-test.hs b/test/setup-deps/pkg/src/conduit-test.hs deleted file mode 100644 index 696025f9fc..0000000000 --- a/test/setup-deps/pkg/src/conduit-test.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Main where - -import Conduit - -main = return ()