From 622a6ce82adf0e991945298d2c77a5201ff06a3f Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 14 Mar 2024 14:37:49 -0400 Subject: [PATCH 1/5] Add otherOverlays option --- nix/modules/project/default.nix | 6 ++++++ nix/modules/project/outputs.nix | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nix/modules/project/default.nix b/nix/modules/project/default.nix index 2f6d42b5..bc161dab 100644 --- a/nix/modules/project/default.nix +++ b/nix/modules/project/default.nix @@ -68,6 +68,12 @@ in default = pkgs.haskellPackages; defaultText = lib.literalExpression "pkgs.haskellPackages"; }; + otherOverlays = lib.mkOption { + type = types.listOf (import ../../types/haskell-overlay-type.nix { inherit lib; }); + description = '' + Extra overlays to apply. + ''; + }; autoWire = let outputTypes = [ "packages" "checks" "apps" "devShells" ]; diff --git a/nix/modules/project/outputs.nix b/nix/modules/project/outputs.nix index ca330234..4b1e5f21 100644 --- a/nix/modules/project/outputs.nix +++ b/nix/modules/project/outputs.nix @@ -83,10 +83,10 @@ in localPackages = lib.filterAttrs (_: cfg: cfg.local.toCurrentProject) config.packages; - finalOverlay = lib.composeManyExtensions [ + finalOverlay = lib.composeManyExtensions ([ config.packagesOverlay config.settingsOverlay - ]; + ] ++ config.otherOverlays); finalPackages = config.basePackages.extend finalOverlay; From b77714fdcfe521402464ec3900df238c2b77a86d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 14 Mar 2024 14:40:45 -0400 Subject: [PATCH 2/5] add default --- nix/modules/project/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/modules/project/default.nix b/nix/modules/project/default.nix index bc161dab..431310fa 100644 --- a/nix/modules/project/default.nix +++ b/nix/modules/project/default.nix @@ -73,6 +73,7 @@ in description = '' Extra overlays to apply. ''; + default = [ ]; }; autoWire = let From 485782bf3ad156cfb9d148bd68def9b904740f85 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 14 Mar 2024 14:43:28 -0400 Subject: [PATCH 3/5] expand docs --- nix/modules/project/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/modules/project/default.nix b/nix/modules/project/default.nix index 431310fa..028882d6 100644 --- a/nix/modules/project/default.nix +++ b/nix/modules/project/default.nix @@ -72,6 +72,10 @@ in type = types.listOf (import ../../types/haskell-overlay-type.nix { inherit lib; }); description = '' Extra overlays to apply. + + Normally, you would only use `packages.*` and `settings.*` (which + translate to overlays), but you can use this option if you want control + over the final overlay. ''; default = [ ]; }; From d88ced38e4e7ae9097cf1431ef8c989c3e559199 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 27 Mar 2024 15:36:03 -0400 Subject: [PATCH 4/5] Add test --- flake.nix | 7 +++++ test/otherOverlays/flake.nix | 32 +++++++++++++++++++++ test/otherOverlays/haskell-flake-test.cabal | 19 ++++++++++++ test/otherOverlays/src/Main.hs | 7 +++++ 4 files changed, 65 insertions(+) create mode 100644 test/otherOverlays/flake.nix create mode 100644 test/otherOverlays/haskell-flake-test.cabal create mode 100644 test/otherOverlays/src/Main.hs diff --git a/flake.nix b/flake.nix index 3f35dc5c..5fbef8a1 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,13 @@ inherit nixpkgs flake-parts haskell-flake; }; }; + + test-otherOverlays = { + dir = "test/otherOverlays"; + overrideInputs = { + inherit nixpkgs flake-parts haskell-flake; + }; + }; }; }; } diff --git a/test/otherOverlays/flake.nix b/test/otherOverlays/flake.nix new file mode 100644 index 00000000..5b8e1940 --- /dev/null +++ b/test/otherOverlays/flake.nix @@ -0,0 +1,32 @@ +{ + # Since there is no flake.lock file (to avoid incongruent haskell-flake + # pinning), we must specify revisions for *all* inputs to ensure + # reproducibility. + inputs = { + nixpkgs = { }; + flake-parts = { }; + haskell-flake = { }; + + haskell-multi-nix.url = "github:srid/haskell-multi-nix/d6ac6ccab559f886d1fc7da8cab44b99cb0c2c3d"; + haskell-multi-nix.inputs.haskell-flake.follows = "haskell-flake"; + haskell-multi-nix.inputs.nixpkgs.follows = "nixpkgs"; + haskell-multi-nix.inputs.flake-parts.follows = "flake-parts"; + }; + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + ]; + perSystem = { self', pkgs, ... }: { + haskellProjects.default = { + otherOverlays = [ + (self: super: { + foo = super.callCabal2nix "foo" "${inputs.haskell-multi-nix}/foo" { }; + }) + ]; + }; + packages.default = self'.packages.haskell-flake-test; + }; + }; +} diff --git a/test/otherOverlays/haskell-flake-test.cabal b/test/otherOverlays/haskell-flake-test.cabal new file mode 100644 index 00000000..14d5ef65 --- /dev/null +++ b/test/otherOverlays/haskell-flake-test.cabal @@ -0,0 +1,19 @@ +cabal-version: 3.0 +name: haskell-flake-test +version: 0.1.0.0 +license: NONE +author: Joe +maintainer: joe@example.com +build-type: Simple + +common warnings + ghc-options: -Wall + +executable haskell-flake-test + import: warnings + main-is: Main.hs + build-depends: + base, + foo + hs-source-dirs: src + default-language: Haskell2010 diff --git a/test/otherOverlays/src/Main.hs b/test/otherOverlays/src/Main.hs new file mode 100644 index 00000000..f9b44a6d --- /dev/null +++ b/test/otherOverlays/src/Main.hs @@ -0,0 +1,7 @@ +module Main where + +import Foo + +main :: IO () +main = do + fooFunc From 32bad3d6ebde007d565c6e240be107fc742180f0 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 27 Mar 2024 15:37:12 -0400 Subject: [PATCH 5/5] changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad469ead..358f3423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - #210: Add `extraLibraries` to `settings` module. +- #277: Add `otherOverlays` option to add custom Haskell package overlays. - #225: settings: add `removeReferencesTo` - #215: Improved debug logging. - #216: Remove `debug` option (pass `--trace-verbose` to nix instead) @@ -30,8 +31,8 @@ ## 0.3.0 (May 22, 2023) - #134: Add `autoWire` option to control generation of flake outputs - - #138: Add `checks` to `outputs` submodule - - #143: Changed `autoWire` to be an enum type, for granular controlling of which outputs to autowire. + - #138: Add `checks` to `outputs` submodule + - #143: Changed `autoWire` to be an enum type, for granular controlling of which outputs to autowire. - #137: Expose cabal executables as flake apps. Add a corresponding `outputs.apps` option, while the `outputs.localPackages` option is renamed to `outputs.packages` (it now contains package metadata, including packages and its executables). - #151: Use `lib.getBin` to get the bin output - #148: Remove automatic hpack->cabal generation. Use `pre-commit-hooks.nix` instead.