From d176ed41599dc713ce7a73c19ea50e662acf842d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Sun, 5 Feb 2023 14:31:22 -0500 Subject: [PATCH] Simplify nixpkgs workaround (#84) - Apply that overlay only on macOS - Make use of the overlay system - Update nixpkgs and haskell-flake --- flake.lock | 12 ++++++------ flake.nix | 37 +++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 5a18e7d..2158ed8 100644 --- a/flake.lock +++ b/flake.lock @@ -35,11 +35,11 @@ }, "haskell-flake": { "locked": { - "lastModified": 1674483307, - "narHash": "sha256-NlohHWCqOsMY4q2fmKR6VAAX4y09Cr85Ezgbx4Q2hbc=", + "lastModified": 1675623979, + "narHash": "sha256-eD01oAbmfWhAVHesQrsZkGdueV7xtV1AmhGDEvJV2XA=", "owner": "srid", "repo": "haskell-flake", - "rev": "8688fb2deaa193795467eedb4d2473dbeaba19b4", + "rev": "014aa621ec2e910766f8fbe03dc9638984a359eb", "type": "github" }, "original": { @@ -102,11 +102,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1674361931, - "narHash": "sha256-lUIZItHbW+LmJAz9V9puLq2rHlewcUgg1RPehkQIkzc=", + "lastModified": 1675584158, + "narHash": "sha256-SBkchaDzCHxnPNRDdtZ5ko5caHio9iS0Mbyn/xXbXxs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ef479383e13698c8d5ccf8a608485dc8ce1d4f80", + "rev": "d840126a0890621e7b220894d749132dd4bde6a0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b01296c..8b9bf8c 100644 --- a/flake.nix +++ b/flake.nix @@ -18,31 +18,40 @@ inputs.flake-root.flakeModule inputs.mission-control.flakeModule ]; - perSystem = { self', lib, config, pkgs, ... }: { + perSystem = { self', system, lib, config, pkgs, ... }: { # The "main" project. You can have multiple projects, but this template # has only one. haskellProjects.main = { packages = { haskell-template.root = ./.; }; - buildTools = hp: + overrides = let # Workaround for https://github.com/NixOS/nixpkgs/issues/140774 - fixCyclicReference = drv: - pkgs.haskell.lib.overrideCabal drv (_: { - enableSeparateBinOutput = false; - }); + nixpkgsWorkaround = + let + disableSeparateBinOutput = + pkgs.haskell.lib.compose.overrideCabal (_: { enableSeparateBinOutput = false; }); + in + self: super: lib.optionalAttrs (system == "aarch64-darwin") { + ghcid = disableSeparateBinOutput super.ghcid; + ormolu = disableSeparateBinOutput super.ormolu; + }; + projectOverrides = self: super: { + # Add your own overrides here. + }; in - { + lib.composeManyExtensions [ + nixpkgsWorkaround + projectOverrides + ]; + devShell = { + tools = hp: { treefmt = config.treefmt.build.wrapper; - ghcid = fixCyclicReference hp.ghcid; - haskell-language-server = hp.haskell-language-server.overrideScope (lself: lsuper: { - ormolu = fixCyclicReference hp.ormolu; - }); } // config.treefmt.build.programs; - # overrides = self: super: with pkgs.haskell.lib; {}; - hlsCheck.enable = false; - hlintCheck.enable = true; + hlsCheck.enable = false; + hlintCheck.enable = true; + }; }; # Auto formatters. This also adds a flake check to ensure that the