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

Flake-enable project #587

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(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 = ./.; }
).defaultNix
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.

87 changes: 87 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{ inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";

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

flake-utils.url = "github:numtide/flake-utils/v1.0.0";
};

outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
ghcVersion = "ghc90";

config = { };

overlay = self: super: {
haskell = super.haskell // {
packages = super.haskell.packages // {
"${ghcVersion}" = super.haskell.packages."${ghcVersion}".override (old: {
overrides =
self.lib.composeExtensions
(old.overrides or (_: _: { }))
(hself: hsuper: {
# The reason we stick these underneath a `local` attribute
# is to avoid infinite recursion (because `callCabal2nix`
# depends on all of these packages.
local = rec {
cabal2nix =
hself.callCabal2nix "cabal2nix" ./cabal2nix {
inherit distribution-nixpkgs hackage-db;
Gabriella439 marked this conversation as resolved.
Show resolved Hide resolved
};

distribution-nixpkgs =
hself.callCabal2nix
"distribution-nixpkgs"
./distribution-nixpkgs
{ inherit language-nix; };

hackage-db =
hself.callCabal2nix "hackage-db" ./hackage-db { };

language-nix =
hself.callCabal2nix "language-nix" ./language-nix { };
};
});
});
};
};
};

pkgs =
import nixpkgs { inherit config system; overlays = [ overlay ]; };

in
rec {
packages = rec {
inherit (pkgs.haskell.packages."${ghcVersion}".local)
cabal2nix
hackage-db
distribution-nixpkgs
language-nix
;

default = cabal2nix;
};

devShells = rec {
cabal2nix =
pkgs.haskell.packages."${ghcVersion}".local.cabal2nix.env;

distribution-nixpkgs =
pkgs.haskell.packages."${ghcVersion}".local.distribution-nixpkgs.env;

hackage-db =
pkgs.haskell.packages."${ghcVersion}".local.hackage-db.env;

language-nix =
pkgs.haskell.packages."${ghcVersion}".local.language-nix.env;

default = cabal2nix;
};
}
);
}
48 changes: 10 additions & 38 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
{ pkgs ? import <nixpkgs> { }
, ghcVersion ? pkgs.haskellPackages.ghc.version
, withHls ? true
}:

let
haskellPackages = pkgs.haskell.packages."ghc${
builtins.replaceStrings [ "." ] [ "" ] ghcVersion
}";
ghc = haskellPackages.ghcWithHoogle (hps: [
hps.ansi-wl-pprint
hps.hopenssl
hps.hpack
hps.lens
hps.optparse-applicative
hps.pretty
hps.split
hps.yaml
hps.monad-par
hps.monad-par-extras
hps.tasty
hps.tasty-golden
hps.utf8-string
hps.tar
hps.hspec
hps.parsec-class
]);

in pkgs.mkShell {
packages = [
ghc
pkgs.cabal-install
pkgs.haskell-ci
(pkgs.lib.getLib pkgs.openssl)
] ++ pkgs.lib.optionals withHls [
haskellPackages.haskell-language-server
];
}
(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