Skip to content

Commit bce6b4b

Browse files
authored
fix: update nix shell to work with current bounds, add flake (#1791)
* update pinned nixpkgs to latest release, set default GHC to 9.2 * chore: make ghc directions more resilient to nixpkgs changes * chore: add flake * fix: add lzma flag
1 parent 2dff6e8 commit bce6b4b

File tree

8 files changed

+132
-13
lines changed

8 files changed

+132
-13
lines changed

cabal.project

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ if(impl(ghc >= 9.6.1))
7070
package servant-server
7171
ghc-options: -fprint-redundant-promotion-ticks
7272

73+
package lzma
74+
flags: -pkgconfig
75+
7376
-- This block is for GHC 9.10.1.
7477
allow-newer: servant-openapi3:base
7578
allow-newer: openapi3:base

default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ with (builtins.fromJSON (builtins.readFile ./nix/nixpkgs.json));
44
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
55
inherit sha256;
66
}) {}
7-
, compiler ? "ghc883"
7+
, compiler ? "ghc92"
88
}:
99
let
1010
overrides = self: super: {

flake.lock

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
description = "Servant development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs { inherit system; };
13+
14+
mkDevShell = { compiler ? "ghc92", tutorial ? false }:
15+
let
16+
ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (_: []);
17+
docstuffs = pkgs.python3.withPackages (ps: with ps; [ recommonmark sphinx sphinx_rtd_theme ]);
18+
in
19+
pkgs.mkShell {
20+
buildInputs = with pkgs; [
21+
ghc
22+
zlib
23+
python3
24+
wget
25+
cabal-install
26+
postgresql
27+
openssl
28+
stack
29+
haskellPackages.hspec-discover
30+
] ++ (if tutorial then [docstuffs postgresql] else []);
31+
32+
shellHook = ''
33+
eval $(grep export ${ghc}/bin/ghc)
34+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"${pkgs.zlib}/lib";
35+
'';
36+
};
37+
in
38+
{
39+
devShells = {
40+
default = mkDevShell {};
41+
tutorial = mkDevShell { tutorial = true; };
42+
};
43+
}
44+
);
45+
}

nix/README.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ a particular ghc version, e.g:
2222
$ nix-shell nix/shell.nix --argstr compiler ghcHEAD
2323
```
2424

25-
**Possible GHC versions**
26-
- `ghc865Binary`
27-
- `ghc884`
28-
- `ghc8104` - default
29-
- `ghc901`
25+
The default is `ghc92`.
26+
27+
To check which which ghc compiler options are available:
28+
29+
```sh
30+
$ nix-env -f nix/nixpkgs.nix -qaP -A haskell.compiler
31+
```
32+
33+
If you prefer to use flakes, the `flake.nix` file provides an
34+
equivalent default devShell to `shell.nix`. In addition, the
35+
tutorial is provided as a separate flake output:
36+
37+
```sh
38+
$ nix develop .#tutorial
39+
```
3040

3141
### Cabal users
3242

@@ -38,4 +48,4 @@ GHC version can be chosen via the nix-shell parameter
3848

3949
Since the ghc version is set by the LTS version, it is preferable to use the `ghc8104` version parameter for the nix-shell.
4050

41-
`stack --no-nix --system-ghc <command>`
51+
`stack --no-nix --system-ghc <command>`

nix/nixpkgs.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"rev" : "05f0934825c2a0750d4888c4735f9420c906b388",
3-
"sha256" : "1g8c2w0661qn89ajp44znmwfmghbbiygvdzq0rzlvlpdiz28v6gy"
2+
"rev" : "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
3+
"sha256" : "1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx"
44
}

nix/nixpkgs.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import (builtins.fetchTarball {
2-
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz";
3-
sha256 = "sha256:1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
2+
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/24.05.tar.gz";
3+
sha256 = "sha256:1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx";
44
}) {}

nix/shell.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{ compiler ? "ghc8104"
1+
{ compiler ? "ghc92"
22
, tutorial ? false
33
, pkgs ? import ./nixpkgs.nix
44
}:
5-
5+
66
with pkgs;
77

88
let

0 commit comments

Comments
 (0)