Skip to content

Commit

Permalink
build: add flake.nix
Browse files Browse the repository at this point in the history
run `nix develop` to get a development environment
  • Loading branch information
teto committed Dec 21, 2021
1 parent 8aeef87 commit 87ec451
Show file tree
Hide file tree
Showing 3 changed files with 263 additions and 0 deletions.
195 changes: 195 additions & 0 deletions flake.lock

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

59 changes: 59 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
description = "My haskell library";

nixConfig = {
extra-substituters = [
"https://haskell-language-server.cachix.org"
];
extra-trusted-public-keys = [
"haskell-language-server.cachix.org-1:juFfHrwkOxqIOZShtC4YC1uT1bBcq2RSvC7OMKx0Nz8="
];
};

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
hls.url = "github:haskell/haskell-language-server/854d2c5a1aa3095c93e3f38ef3731be89b4ab09a";

flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};

outputs = { self, nixpkgs, flake-utils, hls, ... }:
flake-utils.lib.eachSystem ["x86_64-linux"] (system: let

pkgs = nixpkgs.legacyPackages.${system};

ghc8107 = pkgs.haskell.packages."ghc8107";

# modifier used in haskellPackages.developPackage
myModifier = hsPkgs: drv: let
compilerVersion = pkgs.lib.replaceStrings [ "." ] [ "" ] hsPkgs.ghc.version;
in
pkgs.haskell.lib.addBuildTools drv ([
hsPkgs.cabal-install
hls.packages.${system}."haskell-language-server-${compilerVersion}"
pkgs.openssl.dev
pkgs.zlib
]);

mkPackage = hsPkgs:
hsPkgs.developPackage {
root = pkgs.lib.cleanSource ./. ;
name = "cabal2nix";
returnShellEnv = false;
withHoogle = true;
modifier = myModifier hsPkgs;
};

in {
packages = {
cabal2nix = self.packages.${system}.cabal2nix-8107;
cabal2nix-8107 = mkPackage ghc8107;
};

defaultPackage = self.packages.${system}.cabal2nix;
});
}
9 changes: 9 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).shellNix

0 comments on commit 87ec451

Please sign in to comment.