From c09ae680ba732eed20cd3e106d955fcc19f412c3 Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Wed, 1 Mar 2023 03:41:39 +0100 Subject: [PATCH] Add unicode-data and unicode-data-names to Nix --- nix/haskell-deps.nix | 4 +++- nix/pkgs.nix | 18 +++++++++++++++++- nix/settings.nix | 5 +++++ package.yaml | 1 + shell.nix | 4 ++++ stack-shell.nix | 3 ++- utoy.cabal | 3 +++ 7 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 nix/settings.nix diff --git a/nix/haskell-deps.nix b/nix/haskell-deps.nix index b25d0dc..7edd5e4 100644 --- a/nix/haskell-deps.nix +++ b/nix/haskell-deps.nix @@ -1,2 +1,4 @@ haskellPackages: with haskellPackages; [ -] \ No newline at end of file + unicode-data + unicode-data-names +] diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 3c50090..eeef947 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -1,5 +1,21 @@ { overlays ? [] }: let sources = import ./sources.nix; + settings = import ./settings.nix; + + overlay = final: prev: { + haskell = prev.haskell // { + packages = prev.haskell.packages // { + "${settings.ghc}" = prev.haskell.packages."${settings.ghc}".override { + overrides = haskellOverlay prev; + }; + }; + }; + }; + + haskellOverlay = pkgs: final: prev: { + unicode-data = prev.unicode-data_0_4_0_1; + unicode-data-names = pkgs.haskell.lib.markUnbroken prev.unicode-data-names; + }; in - import sources.nixpkgs { inherit overlays; } + import sources.nixpkgs { overlays = overlays ++ [overlay]; } diff --git a/nix/settings.nix b/nix/settings.nix new file mode 100644 index 0000000..1b3b3b6 --- /dev/null +++ b/nix/settings.nix @@ -0,0 +1,5 @@ +{ + # GHC version to use with Nix. + # Should match the one in stack.yaml. + ghc = "ghc943"; +} diff --git a/package.yaml b/package.yaml index a798d03..d3e3abe 100644 --- a/package.yaml +++ b/package.yaml @@ -13,6 +13,7 @@ extra-source-files: dependencies: - base >= 4.7 && < 5 +- unicode-data-names ghc-options: - -Wall diff --git a/shell.nix b/shell.nix index 137fdd0..525a729 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,8 @@ { pkgs ? import ./nix/pkgs.nix {} }: let + haskellDeps = import ./nix/haskell-deps.nix; + settings = import ./nix/settings.nix; + tools = with pkgs; [ # nix tools niv @@ -8,6 +11,7 @@ let # haskell tools stack haskell-language-server + (pkgs.haskell.packages."${settings.ghc}".ghcWithPackages haskellDeps) ]; in pkgs.mkShellNoCC { diff --git a/stack-shell.nix b/stack-shell.nix index 440acae..c96744d 100644 --- a/stack-shell.nix +++ b/stack-shell.nix @@ -1,9 +1,10 @@ {}: let pkgs = import ./nix/pkgs.nix {}; + settings = import ./nix/settings.nix; haskellDeps = import ./nix/haskell-deps.nix; in pkgs.haskell.lib.buildStackProject { name = "utoy"; - ghc = pkgs.haskell.packages.ghc943.ghcWithPackages haskellDeps; + ghc = pkgs.haskell.packages."${settings.ghc}".ghcWithPackages haskellDeps; } diff --git a/utoy.cabal b/utoy.cabal index c224e8d..5ca2818 100644 --- a/utoy.cabal +++ b/utoy.cabal @@ -27,6 +27,7 @@ library ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints build-depends: base >=4.7 && <5 + , unicode-data-names default-language: Haskell2010 executable utoy-exe @@ -36,6 +37,7 @@ executable utoy-exe ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5 + , unicode-data-names , utoy default-language: Haskell2010 @@ -49,5 +51,6 @@ test-suite utoy-test ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5 + , unicode-data-names , utoy default-language: Haskell2010