The stackage2nix package

[ Tags: bsd3, distribution, library, nix, program ] [ Propose Tags ]

[Skip to Readme]

Properties

Versions 0.3.0, 0.4.0
Change log CHANGELOG.md
Dependencies aeson, base (>4.7 && <5), bytestring, Cabal (>1.24), cabal2nix (>=2.5), containers, deepseq, distribution-nixpkgs (>=1.1), exceptions (>0.8), filepath, gitlib (>3), gitlib-libgit2 (>3), hopenssl (>2.2), inflections (>=0.3), language-nix, lens, network-uri, optparse-applicative, pretty, QuickCheck, stackage-curator (>=0.15), stackage2nix, text, unordered-containers, yaml [details]
License BSD3
Author Dmitry Bushev , Benno Fünfstück
Maintainer bushevdv@gmail.com
Category Distribution, Nix
Home page https://github.com/typeable/stackage2nix#readme
Source repository head: git clone https://github.com/typeable/stackage2nix
Uploaded Mon Jan 1 12:26:50 UTC 2018 by dbushev
Distributions NixOS:0.4.0
Executables stackage2nix
Downloads 212 total (141 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2018-01-01 [all 2 reports]
Hackage Matrix CI

Modules

  • Distribution
    • Nixpkgs
      • Haskell
        • Distribution.Nixpkgs.Haskell.FromStack
          • Distribution.Nixpkgs.Haskell.FromStack.Package
        • Packages
          • Distribution.Nixpkgs.Haskell.Packages.PrettyPrinting
        • Distribution.Nixpkgs.Haskell.Stack
          • Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting
  • Language
    • Nix
      • Language.Nix.FilePath
  • Runner
    • Runner.Cli
  • Stack
    • Stack.Config
      • Stack.Config.TH
      • Stack.Config.Yaml
    • Stack.Types

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for stackage2nix-0.4.0

[back to package description]

stackage2nix

Build Status

stackage2nix converts a Stack file into a Nix Haskell packages set. It creates LTS Stackage packages set, and applies appropriate overrides on top of it.

Install

You can install stackage2nix from the Nix expression:

nix-env -i -f ./nix/stackage2nix

It provides pre-configured wrapper around the raw executable with runtime PATH and all auxiliary flags set up.

Build project

Generate derivations from stack.yaml config using Nix wrapper:

stackage2nix ./stack.yaml

if you're using the raw executable, you should supply additional flags. See section 'Flags' below for details.

This command will result in a Haskell packages set, similar to pkgs.haskell.packages.<compiler>, containing only packages that are required to build targets listed in stackage.yaml. To build a package run:

nix-build -A my-package

Build stackage

Generate complete Stackage packages set from resolver:

stackage2nix --resolver lts-9.0

Flags

stackage2nix \
  --lts-haskell "$LTS_HASKELL_REPO" \
  --all-cabal-hashes "$ALL_CABAL_HASHES_REPO" \
  .

stackage2nix has three required arguments:

Produced Nix derivation split on following files:

  • packages.nix - Base Stackage packages set
  • configuration-packages.nix - Compiler configuration
  • default.nix - Final Haskell packages set with all overrides applied

A particular package from result Haskell packages set can be built with:

nix-build -A <package-name>

See also the blog post about history and motivation behind the project.

Runtime dependencies

  • nix-env is required to be on PATH by the distribution-nixpkgs dependency
  • nix-prefetch-scripts is required on PATH if you have git dependencies in stack.yaml

Override result derivation

Complex projects may require some extra customization. Snippet override.nix below shows a minimal example of how to apply additional overrides on top of Haskell packages set produced by stackage2nix.

with import <nixpkgs> {};
with pkgs.haskell.lib;
let haskellPackages = import ./. {};
in haskellPackages.override {
  overrides = self: super: {
    stackage2nix = disableSharedExecutables super.stackage2nix;
  };
}
nix-build -A stackage2nix override.nix

For more complex overrides and detailed information on how to work with Haskell packages in Nix, see Nixpkgs manual User’s Guide to the Haskell Infrastructure

Tests

Integration tests that build stackage2nix form different stack configs:

STACKAGE_REPO=<path/to/stackage/repo> \
ALL_CABAL_HASHES=<path/to/all-cabal-hashes/repo> \
STACK_FILE=stack-ghc-7103.yaml \
./ci-stackage2nix