https://github.com/NixOS/cabal2nix
Generate Nix build instructions from a Cabal file
https://github.com/NixOS/cabal2nix
cabal cabal2nix hackage haskell nix nixpkgs
Last synced: 8 months ago
JSON representation
Generate Nix build instructions from a Cabal file
- Host: GitHub
- URL: https://github.com/NixOS/cabal2nix
- Owner: NixOS
- License: other
- Created: 2011-08-05T15:31:37.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2025-04-30T18:08:53.000Z (8 months ago)
- Last Synced: 2025-05-05T19:23:37.147Z (8 months ago)
- Topics: cabal, cabal2nix, hackage, haskell, nix, nixpkgs
- Language: Haskell
- Homepage: https://nixos.org/manual/nixpkgs/unstable/#haskell
- Size: 3.26 MB
- Stars: 370
- Watchers: 15
- Forks: 155
- Open Issues: 89
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-nix - cabal2nix - Converts a Cabal file into a Nix build expression. (Programming Languages / Haskell)
- best-of-nix - GitHub - 23% open · ⏱️ 31.10.2025) (Programming Languages)
README
# The cabal2nix monorepo

## Components
### cabal2nix
Tool that generates Nix build instructions from a Cabal file. Also contains
hackage2nix, the tool that generates the `haskellPackages` set in nixpkgs.
### distribution-nixpkgs
Utility library implementing nixpkgs-specific tasks and concepts: Looking
up packages, `meta` sets, Nix-style integrity hashes etc.
### language-nix
Simplistic library to parse and render a subset of the Nix language.
### hackage-db
Library for working with the Hackage database created and updated
using `cabal update`.
## Development
At the top-level, a `cabal.project` and `shell.nix` are provided for working
on all packages in the repository. You can use `direnv` and (optionally)
lorri to make the environment available in your normal shell as well.
## Maintenance
The monorepo has been assembled using [josh]. You can obtain it from nixpkgs
using `nix-shell -p josh`. Below, some common tasks are documented.
### Extracting the original git history
[josh]'s history filtering capabilities are quite powerful, allowing us to
extract the original git histories of the repositories that have been vendored
in. For example, for `distribution-nixpkgs`:
```console
$ josh-filter ':/distribution-nixpkgs'
$ git checkout FILTERED_HEAD
$ ls *.cabal
distribution-nixpkgs.cabal
```
The `FILTERED_HEAD` ref has the original `HEAD` of the `distribution-nixpkgs`
`HEAD` when it was vendored as its ancestor and can thus be pushed to the
original repository.
### Vendoring components
This probably won't come up in the future, but the process that was used to
vendor the additional libraries is documented here:
```console
$ name=…
$ git fetch https://github.com/nixos/$name.git
$ josh-filter ":prefix=$name" FETCH_HEAD
$ git merge --allow-unrelated-histories FILTERED_HEAD -m "$name: subtree upstream repo"
```
Also refer to the relevant [josh
documentation](https://josh-project.github.io/josh/guide/importing.html).
[josh]: https://josh-project.github.io/josh/