Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update nix shell to work with current bounds, add flake #1791

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ if(impl(ghc >= 9.6.1))
package servant-server
ghc-options: -fprint-redundant-promotion-ticks

package lzma
flags: -pkgconfig

-- This block is for GHC 9.10.1.
allow-newer: servant-openapi3:base
allow-newer: openapi3:base
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ with (builtins.fromJSON (builtins.readFile ./nix/nixpkgs.json));
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
}) {}
, compiler ? "ghc883"
, compiler ? "ghc92"
}:
let
overrides = self: super: {
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
description = "Servant development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };

mkDevShell = { compiler ? "ghc92", tutorial ? false }:
let
ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (_: []);
docstuffs = pkgs.python3.withPackages (ps: with ps; [ recommonmark sphinx sphinx_rtd_theme ]);
in
pkgs.mkShell {
buildInputs = with pkgs; [
ghc
zlib
python3
wget
cabal-install
postgresql
openssl
stack
haskellPackages.hspec-discover
] ++ (if tutorial then [docstuffs postgresql] else []);

shellHook = ''
eval $(grep export ${ghc}/bin/ghc)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"${pkgs.zlib}/lib";
'';
};
in
{
devShells = {
default = mkDevShell {};
tutorial = mkDevShell { tutorial = true; };
};
}
);
}
22 changes: 16 additions & 6 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@ a particular ghc version, e.g:
$ nix-shell nix/shell.nix --argstr compiler ghcHEAD
```

**Possible GHC versions**
- `ghc865Binary`
- `ghc884`
- `ghc8104` - default
- `ghc901`
The default is `ghc92`.

To check which which ghc compiler options are available:

```sh
$ nix-env -f nix/nixpkgs.nix -qaP -A haskell.compiler
```

If you prefer to use flakes, the `flake.nix` file provides an
equivalent default devShell to `shell.nix`. In addition, the
tutorial is provided as a separate flake output:

```sh
$ nix develop .#tutorial
```

### Cabal users

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

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

`stack --no-nix --system-ghc <command>`
`stack --no-nix --system-ghc <command>`
4 changes: 2 additions & 2 deletions nix/nixpkgs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rev" : "05f0934825c2a0750d4888c4735f9420c906b388",
"sha256" : "1g8c2w0661qn89ajp44znmwfmghbbiygvdzq0rzlvlpdiz28v6gy"
"rev" : "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
"sha256" : "1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx"
}
4 changes: 2 additions & 2 deletions nix/nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz";
sha256 = "sha256:1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/24.05.tar.gz";
sha256 = "sha256:1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx";
}) {}
4 changes: 2 additions & 2 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ compiler ? "ghc8104"
{ compiler ? "ghc92"
, tutorial ? false
, pkgs ? import ./nixpkgs.nix
}:

with pkgs;

let
Expand Down
Loading