refactor a bit of nix so that we can use wingman on ghc 9.0

This commit is contained in:
Marco Perone 2023-01-11 12:07:57 +01:00
parent 441cb5149e
commit 5e82980d2e
5 changed files with 109 additions and 25 deletions

View File

@ -27,7 +27,7 @@ nix-shell
### GHC version
The project has a default GHC version that is specified in the flake.
The project has a default GHC version that is specified in the flake. At the moment that version is 9.0, because the HLS plugin Wingman [currently only builds up to this version](https://github.com/haskell/haskell-language-server/issues/2971).
It is also possible to use other GHC versions to build the project and enter development shells. This allows us to easily test multiple versions.

27
flake.lock generated
View File

@ -48,16 +48,32 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1672756850,
"narHash": "sha256-Smbq3+fitwA13qsTMeaaurv09/KVbZfW7m7lINwzDGA=",
"lastModified": 1673226411,
"narHash": "sha256-b6cGb5Ln7Zy80YO66+cbTyGdjZKtkoqB/iIIhDX9gRA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "298add347c2bbce14020fcb54051f517c391196b",
"rev": "aa1d74709f5dac623adb4d48fdfb27cc2c92a4d4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1673345971,
"narHash": "sha256-4DfFcKLRfVUTyuGrGNNmw37IeIZSoku9tgTVmu/iD98=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "54644f409ab471e87014bb305eac8c50190bcf48",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
@ -67,7 +83,8 @@
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable"
}
}
},

View File

@ -2,7 +2,8 @@
description = "marcosh/crm: compositional reproducible machines";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
flake-compat = {
@ -32,16 +33,16 @@
# see here for specifics: https://nixos.wiki/wiki/Overlays
haskellPackagesFor =
{ ghcVersion
, overrides ? (_: _: { })
, haskellPackages ? pkgs.haskell.packages."ghc${ghcVersion}"
}:
pkgs.haskell.packages."ghc${ghcVersion}".override {
overrides = self: super: (overrides self super) // {
haskellPackages.override {
overrides = self: super: {
crm = self.callCabal2nix "crm" src { };
};
};
# A list of GHC versions and corresponding package overrides to use with `haskellPackagesFor`.
configurations = import ./nix/haskell-configurations.nix { inherit inputs; };
configurations = import ./nix/haskell-configurations.nix { inherit inputs system; };
# A utility function that creates a set containing key-value pairs constructed for each
# element in `configurations`.
@ -54,7 +55,21 @@
configurations;
# The version of GHC used for default package and development shell.
defaultGhcVersion = "ghc92";
defaultGhcVersion = "ghc90";
# This is a shell utility that watches Haskell source files for changes, and triggers a
# Cabal rebuild when they change. This will NOT trigger when a NEW file is added.
watch = pkgs.writeShellApplication {
name = "watch";
text = "fd --extension=hs --extension=yaml | entr -c ${pkgs.writeShellApplication {
name = "watch-unwrapped";
text = ''
hpack
cabal build
cabal test --test-show-details=streaming --test-option=--color
'';
}}/bin/watch-unwrapped";
};
in
rec {
packages = {
@ -81,6 +96,10 @@
fourmolu
haskell-language-server
hpack
watch
pkgs.fd
pkgs.entr
pkgs.bat
];
shellHook = ''
export PS1=" GHC ${haskellPackages.ghc.version} $PS1"

View File

@ -1,16 +1,15 @@
{ inputs }:
{ inputs, system }:
#with pkgs.haskell.lib;
[
{ ghcVersion = "88"; }
{ ghcVersion = "90"; }
{ ghcVersion = "92"; }
{
ghcVersion = "94";
overrides = self: super: {
# we might need some fixes for 9.4
# a common example are libraries that have not yet updated version bounds for `base`
# but still build otherwise
# we can patch libraries individually
};
ghcVersion = "88";
haskellPackages = inputs.nixpkgs-stable.legacyPackages.${system}.haskellPackages;
}
{
ghcVersion = "90";
haskellPackages = inputs.nixpkgs-stable.legacyPackages.${system}.haskellPackages;
}
{ ghcVersion = "92"; }
{ ghcVersion = "94"; }
]

View File

@ -5,7 +5,7 @@ maintainer: marco.perone@tweag.io
copyright: 2022 Tweag I/O
license: OtherLicense
language: GHC2021 # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/control.html?highlight=ghc2021#extension-GHC2021
# language: GHC2021 # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/control.html?highlight=ghc2021#extension-GHC2021
default-extensions:
- DerivingStrategies # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/deriving_strategies.html#extension-DerivingStrategies
@ -13,6 +13,54 @@ default-extensions:
- OverloadedStrings # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/overloaded_strings.html#extension-OverloadedStrings
- PackageImports # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/package_qualified_imports.html#extension-PackageImports
# Enabled by GHC2021, which we don't use because it's only supported by GHC >= 9.2
- BangPatterns
- BinaryLiterals
- ConstrainedClassMethods
- ConstraintKinds
- DeriveDataTypeable
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveLift
- DeriveTraversable
- DoAndIfThenElse
- EmptyCase
- EmptyDataDecls
- EmptyDataDeriving
- ExistentialQuantification
- ExplicitForAll
#- FieldSelectors # Not supported by GHC 9.0
- FlexibleContexts
- FlexibleInstances
- ForeignFunctionInterface
- GADTSyntax
- GeneralisedNewtypeDeriving
- HexFloatLiterals
- ImplicitPrelude
- ImportQualifiedPost
- InstanceSigs
- KindSignatures
- MonomorphismRestriction
- MultiParamTypeClasses
- NamedFieldPuns
- NamedWildCards
- NumericUnderscores
- PatternGuards
- PolyKinds
- PostfixOperators
- RankNTypes
- RelaxedPolyRec
- ScopedTypeVariables
- StandaloneDeriving
- StandaloneKindSignatures
- StarIsType
- TraditionalRecordSyntax
- TupleSections
- TypeApplications
- TypeOperators
- TypeSynonymInstances
# Options inspired by: https://medium.com/mercury-bank/enable-all-the-warnings-a0517bc081c3
ghc-options:
# Enable every warning GHC supports
@ -26,7 +74,8 @@ ghc-options:
- -Wno-unsafe # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/safe_haskell.html#ghc-flag--Wunsafe
- -Wno-missing-safe-haskell-mode # https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/safe_haskell.html#ghc-flag--Wmissing-safe-haskell-mode
- -Wno-implicit-prelude # https://downloads.haskell.org/ghc/latest/docs/users_guide/using-warnings.html#ghc-flag--Wimplicit-prelude
- -Wno-missing-kind-signatures # https://downloads.haskell.org/ghc/latest/docs/users_guide/using-warnings.html#ghc-flag--Wmissing-kind-signatures
# Not supported by GHC 9.0
#- -Wno-missing-kind-signatures # https://downloads.haskell.org/ghc/latest/docs/users_guide/using-warnings.html#ghc-flag--Wmissing-kind-signatures
- -Wno-missing-export-lists # https://downloads.haskell.org/ghc/latest/docs/users_guide/using-warnings.html#ghc-flag--Wmissing-export-lists
- -Wno-missing-home-modules # https://downloads.haskell.org/ghc/latest/docs/users_guide/using-warnings.html#ghc-flag--Wmissing-home-modules
- -Wno-missing-import-lists # https://downloads.haskell.org/ghc/latest/docs/users_guide/using-warnings.html#ghc-flag--Wmissing-import-lists