Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add otherOverlays option #277

Merged
merged 10 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
inherit nixpkgs flake-parts haskell-flake;
};
};

test-otherOverlays = {
dir = "test/otherOverlays";
overrideInputs = {
inherit nixpkgs flake-parts haskell-flake;
};
};
};
};
}
11 changes: 11 additions & 0 deletions nix/modules/project/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand Down
4 changes: 2 additions & 2 deletions nix/modules/project/outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
32 changes: 32 additions & 0 deletions test/otherOverlays/flake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}
19 changes: 19 additions & 0 deletions test/otherOverlays/haskell-flake-test.cabal
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/otherOverlays/src/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Main where

import Foo

main :: IO ()
main = do
fooFunc