Skip to content

Commit 0fca1ef

Browse files
author
Matthieu Coudron
committed
build: add flake.nix
run `nix develop` to get a development environment
1 parent c4bcf64 commit 0fca1ef

File tree

3 files changed

+115
-30
lines changed

3 files changed

+115
-30
lines changed

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
description = "Generate Nix build instructions from a Cabal file";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
8+
flake-compat = {
9+
url = "github:edolstra/flake-compat";
10+
flake = false;
11+
};
12+
};
13+
14+
outputs = { self, nixpkgs, flake-utils, ... }:
15+
flake-utils.lib.eachDefaultSystem (system: let
16+
17+
pkgs = nixpkgs.legacyPackages.${system};
18+
19+
ghc8107 = pkgs.haskell.packages."ghc8107";
20+
21+
# modifier used in haskellPackages.developPackage
22+
myModifier = hsPkgs: drv:
23+
pkgs.haskell.lib.addBuildTools drv ([
24+
hsPkgs.cabal-install
25+
hsPkgs.haskell-language-server
26+
]);
27+
28+
mkPackage = hsPkgs:
29+
hsPkgs.developPackage {
30+
root = pkgs.lib.cleanSource ./. ;
31+
name = "cabal2nix";
32+
returnShellEnv = false;
33+
withHoogle = true;
34+
modifier = myModifier hsPkgs;
35+
};
36+
37+
in {
38+
packages = {
39+
cabal2nix = self.packages.${system}.cabal2nix-8107;
40+
cabal2nix-8107 = mkPackage ghc8107;
41+
};
42+
43+
devShell = self.packages.${system}.cabal2nix.envFunc {};
44+
45+
defaultPackage = self.packages.${system}.cabal2nix;
46+
});
47+
}

shell.nix

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
1-
{ pkgs ? import <nixpkgs> {} }:
2-
1+
(import (
32
let
4-
haskellPackages = pkgs.haskellPackages;
5-
ghc = haskellPackages.ghcWithHoogle (hps: [
6-
hps.ansi-wl-pprint
7-
hps.distribution-nixpkgs
8-
hps.hackage-db
9-
hps.hopenssl
10-
hps.hpack
11-
hps.language-nix
12-
hps.lens
13-
hps.optparse-applicative
14-
hps.pretty
15-
hps.split
16-
hps.yaml
17-
hps.monad-par
18-
hps.monad-par-extras
19-
hps.tasty
20-
hps.tasty-golden
21-
]);
22-
23-
in pkgs.stdenv.mkDerivation {
24-
name = "shell";
25-
buildInputs = [
26-
ghc
27-
haskellPackages.cabal-install
28-
haskellPackages.haskell-language-server
29-
(pkgs.lib.getLib pkgs.openssl)
30-
];
31-
}
3+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
4+
in fetchTarball {
5+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6+
sha256 = lock.nodes.flake-compat.locked.narHash; }
7+
) {
8+
src = ./.;
9+
}).shellNix

0 commit comments

Comments
 (0)