Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/srid/haskell-flake
A `flake-parts` Nix module for Haskell development
https://github.com/srid/haskell-flake
flake-parts haskell nix
Last synced: 37 minutes ago
JSON representation
A `flake-parts` Nix module for Haskell development
- Host: GitHub
- URL: https://github.com/srid/haskell-flake
- Owner: srid
- License: mit
- Created: 2022-05-30T13:01:57.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-19T14:00:31.000Z (6 days ago)
- Last Synced: 2025-01-23T00:38:16.591Z (3 days ago)
- Topics: flake-parts, haskell, nix
- Language: Nix
- Homepage: https://community.flake.parts/haskell-flake
- Size: 550 KB
- Stars: 167
- Watchers: 8
- Forks: 21
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nix - haskell-flake - A `flake-parts` Nix module for Haskell development. (Programming Languages / Haskell)
README
[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://nixos.zulipchat.com/#narrow/stream/413949-haskell-flake)
[![Harmeless Code of Conduct](https://img.shields.io/badge/harmless-8A2BE2)](https://srid.ca/coc "This project follows the 'Harmlessness Code of Conduct'")# haskell-flake - Manage Haskell projects conveniently with Nix
There are [several ways](https://nixos.asia/en/haskell) to manage Haskell packages using [Nix](https://nixos.asia/en/nix) with varying degrees of integration. `haskell-flake` makes Haskell development, packaging and deployment with Nix flakes a lot [simpler](https://community.flake.parts/haskell-flake/start#under-the-hood) than other existing approaches. This project is set up as a modern [`flake-parts`](https://flake.parts/) module to integrate easily into other Nix projects and shell development environments in a lightweight and modular way.
To see more background information, guides and best practices, visit https://community.flake.parts/haskell-flake
Caveat: `haskell-flake` only supports the Haskell package manager [Cabal](https://www.haskell.org/cabal/),
so your project must have a top-level `.cabal` file (single package project) or a `cabal.project` file
(multi-package project).## Getting started
The minimal changes to your `flake.nix` to introduce the `haskell-flake` and [`flake-parts`](https://flake.parts/) modules will look similar to:
```nix
# file: flake.nix
{
inputs = {
...
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux", ... ];
imports = [
...
inputs.haskell-flake.flakeModule
];
perSystem = { self', system, lib, config, pkgs, ... }: {
haskellProjects.default = {
# basePackages = pkgs.haskellPackages;# Packages to add on top of `basePackages`, e.g. from Hackage
packages = {
aeson.source = "1.5.0.0"; # Hackage version
};# my-haskell-package development shell configuration
devShell = {
hlsCheck.enable = false;
};# What should haskell-flake add to flake outputs?
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};devShells.default = pkgs.mkShell {
name = "my-haskell-package custom development shell";
inputsFrom = [
...
config.haskellProjects.default.outputs.devShell
];
nativeBuildInputs = with pkgs; [
# other development tools.
];
};
};
};
}
````haskell-flake` scans your folder automatically for a `.cabal` or `cabal.project` file.
In this example an imaginary `my-haskell-package.cabal` project is used.To see in more detail how to use `haskell-flake` in a realistic Haskell project
with several other development tools, take a look at
the corresponding [Haskell single-package project Nix template](https://github.com/srid/haskell-template) and
this [Haskell multi-package project Nix example](https://github.com/srid/haskell-multi-nix).## Documentation
https://community.flake.parts/haskell-flake
## Discussion
[Zulip](https://nixos.zulipchat.com/#narrow/stream/413949-haskell-flake) is the primary venue for discussion; we also have [Github Discussions](https://github.com/srid/haskell-flake/discussions) enabled.