Skip to content

Commit

Permalink
Merge pull request #1 from telostat/vst/update-haskell-toolchain
Browse files Browse the repository at this point in the history
Update Haskell Toolchain
  • Loading branch information
vst authored Sep 27, 2022
2 parents 7204c0d + 969d4ab commit 7c846dc
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 50 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ niv add telostat/telos.nix -n telosnix -b <branch>

Currently, following expressions are exported:

| Path | Description |
| --------------------------------- | ----------------------------------------------------------------- |
| `pkgs.stable` | Stable `nixpkgs` (based on `release-22.05` `nixpkgs` branch) |
| `pkgs.unstable` | Unstable `nixpkgs` (based on `nixpkgs-unstable` `nixpkgs` branch) |
| `tools.haskell.haskell` | Haskell set based on `ghc902` compiler with overrides |
| `tools.haskell.packages.fourmolu` | [fourmolu](https://hackage.haskell.org/package/fourmolu) v0.8.2.0 |
| Path | Description |
| ----------------------- | ------------------------------------------------------------------------ |
| `pkgs-sources.stable` | Stable `nixpkgs` source (based on `release-22.05` `nixpkgs` branch) |
| `pkgs-sources.unstable` | Unstable `nixpkgs` source (based on `nixpkgs-unstable` `nixpkgs` branch) |
| `tools.haskell` | Various functions to make building Haskell development tools |

## License

Expand Down
16 changes: 11 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{ ... }:

let
nix = (import ./nix);
sources = import ./nix/sources.nix;
in
{
pkgs = {
stable = nix.pkgs;
unstable = nix.pkgs-unstable;
## Pinned Nix package sources.
##
## These can be used in various projects to benefit from Nix caching.
pkgs-sources = {
stable = sources.nixpkgs;
unstable = sources.nixpkgs-unstable;
};

## Categorized tools.
tools = {
haskell = import ./tools/haskell.nix { };
haskell = import ./tools/haskell.nix;
};
}
15 changes: 0 additions & 15 deletions nix/default.nix

This file was deleted.

12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7e27b838cd7ac90fed03d0d5a8487848c4b0b6d2",
"sha256": "027l6ihbgaqk2k20x5zq9x55vgs556xlv5yfdjbvd4v35dclx55m",
"rev": "82379884b2e9cf1ba65f5b14bbcb9d1438abb745",
"sha256": "0zh7h0hsbasl4d527zz7mr2msnffpf269si3jpw2sd62lk8zikz4",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/7e27b838cd7ac90fed03d0d5a8487848c4b0b6d2.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/82379884b2e9cf1ba65f5b14bbcb9d1438abb745.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-unstable": {
Expand All @@ -17,10 +17,10 @@
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e14f9fb57315f0d4abde222364f19f88c77d2b79",
"sha256": "0hzdy6bfj9xn5yjksa918n1hsj1kd584mapyyvhspbcqlr2b096h",
"rev": "ff9793cfd1a25145a7e591af604675b3d6f68987",
"sha256": "087fgyq4q1nr44h52zz3q3h21i1svgip27fp5csa5mz6yzqkqakv",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/e14f9fb57315f0d4abde222364f19f88c77d2b79.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/ff9793cfd1a25145a7e591af604675b3d6f68987.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
79 changes: 61 additions & 18 deletions tools/haskell.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,67 @@
{ compiler ? "ghc902"
, ...
}:

let
## Pinned nixpkgs:
pkgs = (import ../nix).pkgs-unstable;

## Get the haskell set with overrides:
haskell = pkgs.haskell.packages.${compiler}.override {
overrides = self: super: with pkgs.haskell.lib; {
fourmolu = super.fourmolu_0_8_2_0;
Cabal = super.Cabal_3_6_3_0;
ghc-lib-parser = super.ghc-lib-parser_9_2_4_20220729;
## Nix packages override configuration for Haskell development
## tools.
##
## Usage:
##
## devpkgs = import <nixpkgs-unstable> { inherit config-dev-hs; };
## devpkgs = import telosnix.pkgs-sources.unstable { inherit config-dev-hs; };
##
## Note that this is NOT for the package being developed. It can
## have its own Nix packages source and configuration. This is
## rather for the Haskell tools such as language server, linters,
## formatters etc...
##
## The motivation is to:
##
## 1. Use latest Haskell development tools.
## 2. Benefit from Nix binary caches.
##
## For the latter, you should be using the same underlying package
## sources and GHC.
config-dev-hs = {
packageOverrides = pkgs: rec {
haskellPackages = pkgs.haskellPackages.override {
overrides = new: old: rec {
apply-refact = old.apply-refact_0_10_0_0;
Cabal = old.Cabal_3_6_3_0;
fourmolu = old.fourmolu_0_8_2_0;
ghc-lib-parser = old.ghc-lib-parser_9_2_4_20220729;
hlint = old.hlint_3_5;
};
};
};
};

## Imports and returns a given Nix packages source with our custom
## Nix packages override configuration for Haskell development
## tools.
get-haskell-development-packages = source:
import source { inherit config-dev-hs; };

## Imports and returns a compiler specific Haskell packages set with
## our custom Nix packages override configuration for Haskell
## development tools.
get-haskell-development-compiler = source: compiler:
(get-haskell-development-packages source).haskell.packages.${compiler};

## Returns common Haskell development tools for the given Nix
## packages source with our custom Nix packages override
## configuration for Haskell development tools.
get-haskell-development-tools = source: compiler:
let
haskell = get-haskell-development-compiler source compiler;
in
[
haskell.apply-refact
haskell.fourmolu
haskell.haskell-language-server
haskell.hlint
];
in
{
haskell = haskell;

packages = {
fourmolu = haskell.fourmolu;
};
config-dev-hs = config-dev-hs;
get-haskell-development-packages = get-haskell-development-packages;
get-haskell-development-compiler = get-haskell-development-compiler;
get-haskell-development-tools = get-haskell-development-tools;
}

0 comments on commit 7c846dc

Please sign in to comment.