All Projects → NixOS → Cabal2nix

NixOS / Cabal2nix

Licence: other
Generate Nix build instructions from a Cabal file

Programming Languages

haskell
3896 projects

Labels

Projects that are alternatives of or similar to Cabal2nix

Musnix
Real-time audio in NixOS
Stars: ✭ 173 (-22.07%)
Mutual labels:  nix
Naersk
Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly.
Stars: ✭ 193 (-13.06%)
Mutual labels:  nix
Arion
Run docker-compose with help from Nix/NixOS
Stars: ✭ 202 (-9.01%)
Mutual labels:  nix
Legacy Old Hercules
Abandoned
Stars: ✭ 174 (-21.62%)
Mutual labels:  nix
Nix Docker
Docker images for the Nix package manager
Stars: ✭ 189 (-14.86%)
Mutual labels:  nix
Getting Started Nix Template
Based on nix.dev tutorials, repository template to get you started with Nix.
Stars: ✭ 196 (-11.71%)
Mutual labels:  nix
Nixpkgs Fmt
Nix code formatter for nixpkgs [[email protected]]
Stars: ✭ 171 (-22.97%)
Mutual labels:  nix
Nix 1p
A (more or less) one page introduction to Nix, the language.
Stars: ✭ 219 (-1.35%)
Mutual labels:  nix
Nixbox
NixOS Vagrant boxes [[email protected]]
Stars: ✭ 189 (-14.86%)
Mutual labels:  nix
All Hies
Cached Haskell IDE Engine Nix builds for all GHC versions
Stars: ✭ 201 (-9.46%)
Mutual labels:  nix
Pypi2nix
Abandoned! Generate Nix expressions for Python packages
Stars: ✭ 178 (-19.82%)
Mutual labels:  nix
Comma
Stars: ✭ 186 (-16.22%)
Mutual labels:  nix
Nix Index
Quickly locate nix packages with specific files
Stars: ✭ 197 (-11.26%)
Mutual labels:  nix
Nixpkgs Channels
DEPRECATED! Use NixOS/nixpkgs repository instead.
Stars: ✭ 173 (-22.07%)
Mutual labels:  nix
Nixfmt
A formatter for Nix code
Stars: ✭ 201 (-9.46%)
Mutual labels:  nix
Nixos Mailserver
A complete and Simple Nixos Mailserver
Stars: ✭ 172 (-22.52%)
Mutual labels:  nix
Emacs Overlay
Bleeding edge emacs overlay [[email protected]]
Stars: ✭ 194 (-12.61%)
Mutual labels:  nix
Site
The new frontend/backend code for https://christine.website
Stars: ✭ 220 (-0.9%)
Mutual labels:  nix
Nix Shorts
A collection of short notes about Nix, down to what is immediately needed for users.
Stars: ✭ 203 (-8.56%)
Mutual labels:  nix
Zkeme80
An assembler and operating system for the TI-84+ written in Scheme, Forth and Z80 assembly.
Stars: ✭ 200 (-9.91%)
Mutual labels:  nix

Cabal2nix

hackage release stackage LTS package stackage Nightly package Continous Integration

cabal2nix converts a single Cabal file into a single Nix build expression. For example:

$ cabal2nix cabal://mtl
{ mkDerivation, base, lib, transformers }:
mkDerivation {
  pname = "mtl";
  version = "2.2.1";
  sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";
  libraryHaskellDepends = [ base transformers ];
  homepage = "http://github.com/ekmett/mtl";
  description = "Monad classes, using functional dependencies";
  license = lib.licenses.bsd3;
}

Cabal files can be referred to using the magic URL cabal://NAME-VERSION, which will automatically download the file from Hackage. Alternatively, a direct http://host/path/pkg.cabal URL can be provided, as well as a file:///local/path/pkg.cabal URI that doesn't depend on network access. However, if the source hash is not already in cabal2nix's cache or provided using the --sha256 option, cabal2nix still needs to download the source code to compute the hash, which still causes network traffic. Run the utility with --help to see the complete list of supported command-line flags.

Detailed instructions on how to use those generated files with Nix can be found at https://haskell4nix.readthedocs.io/nixpkgs-users-guide.html#how-to-create-nix-builds-for-your-own-private-haskell-packages.

cabal2nix can also build derivations for projects from other sources than Hackage. You only need to provide a URI that points to a cabal project. The most common use-case for this is probably to generate a derivation for a project on the local file system:

$ cabal get mtl-2.2.1 && cd mtl-2.2.1
$ cabal2nix .
{ mkDerivation, base, lib, transformers }:
mkDerivation {
  pname = "mtl";
  version = "2.2.1";
  src = ./.;
  libraryHaskellDepends = [ base transformers ];
  homepage = "http://github.com/ekmett/mtl";
  description = "Monad classes, using functional dependencies";
  license = lib.licenses.bsd3;
}

This derivation will not fetch from hackage, but instead use the directory which contains the derivation as the source repository.

cabal2nix currently supports the following repository types:

  • directory
  • source archive (zip, tar.gz, ...) from http or https URL or local file.
  • git, mercurial, svn or bazaar repository

hackage2nix

This repository also contains, in the hackage2nix/ directory, the tool to update the Haskell packages in nixpkgs. It has its own README there.

Building

For ease of contribution, we support these methods to build cabal2nix:

  • stack build if you have Stack
    • The Stack build can use system dependencies from a pinned nixpkgs version for increased reproducibility (see stack.yaml). On NixOS this happens automatically. On non-NixOS, use stack --nix build for that.
  • cabal install if you have cabal-install installed
  • TODO: Add a build method that requires only nix preinstalled, also pins nixpkgs, and is thus fully reproducible.

When making changes, please ensure that all these methods continue to work.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].