Add otherOverlays option (#277)

This commit is contained in:
Sridhar Ratnakumar 2024-03-27 15:39:41 -04:00 committed by GitHub
parent 786aca6c82
commit 5dcb739e9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 81 additions and 4 deletions

View File

@ -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.

View File

@ -64,6 +64,13 @@
inherit nixpkgs flake-parts haskell-flake;
};
};
test-otherOverlays = {
dir = "test/otherOverlays";
overrideInputs = {
inherit nixpkgs flake-parts haskell-flake;
};
};
};
};
}

View File

@ -68,6 +68,17 @@ 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.
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 = [ ];
};
autoWire =
let
outputTypes = [ "packages" "checks" "apps" "devShells" ];

View File

@ -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;

View File

@ -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;
};
};
}

View File

@ -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

View File

@ -0,0 +1,7 @@
module Main where
import Foo
main :: IO ()
main = do
fooFunc