Skip to content

Commit

Permalink
chore: add flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristano8 committed Oct 16, 2024
1 parent 46dc3de commit 8530363
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
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; };
};
}
);
}
8 changes: 8 additions & 0 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ To check which which ghc compiler options are available:
$ 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

GHC version can be chosen via the nix-shell parameter
Expand Down

0 comments on commit 8530363

Please sign in to comment.