stackage2nix: Convert Stack files into Nix build instructions.

[ bsd3, distribution, library, nix, program ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Last Documentation]

  • 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

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2
Change log CHANGELOG.md
Dependencies aeson, base (>4.7 && <5), bytestring, Cabal (>2.2), cabal2nix (>=2.7.2), 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 BSD-3-Clause
Author Dmitry Bushev , Benno Fünfstück
Maintainer bushevdv@gmail.com
Category Distribution, Nix
Home page https://github.com/typeable/stackage2nix#readme
Source repo head: git clone https://github.com/typeable/stackage2nix
Uploaded by typeable at 2018-07-26T13:46:03Z
Distributions
Executables stackage2nix
Downloads 4325 total (21 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2018-07-26 [all 3 reports]

Readme for stackage2nix-0.7.2

[back to package description]

stackage2nix

Build Status

stackage2nix converts a Stack file into a Nix Haskell packages set.

Create build derivation from stack.yaml

Generate targets from stack.yaml only

stack exec -- stackage2nix .

Command creates file default.nix which overrides haskell.packages.stackage packages set. You should use typeable/nixpkgs-stackage overlay that adds LTS Stackage packages to Nixpkgs.

Build package with overlay installed:

nix-build -A stackage2nix

Generate Stackage packages for the build

If you don't want to use Stackage overlay, stackage2nix can generate required packages with --with-stackage-closure flag.

stack exec -- stackage2nix \
  --all-cabal-hashes /path/to/commercialhaskell/all-cabal-hashes \
  --lts-haskell /path/to/fpco/lts-haskell \
  --with-stackage-closure \
  ./stack.yaml

To generate Stackage packages, you should supply additional --all-cabal-hashes and --lts-haskell flags that points to commercialhaskell/all-cabal-hashes checked out to hackage branch and fpco/lts-haskell respectively.

stackage2nix wrapper

You can use stackage2nix wrapper from nix directory that adds required flags:

nix-env -i -f ./nix/stackage2nix
stackage2nix --with-stackage-closure ./stack.yaml

This command will produce packages.nix and configuration-packages.nix Stackage packages and its override in default.nix

Generate full Stackage

--with-stackage parameter generates full Stackage LTS in addition to the targets from stack.yaml

nix-env -i -f ./nix/stackage2nix
stackage2nix --with-stackage ./stack.yaml

Generate Stackage from LTS resolver

You can also generate only Stackage packages set from the resolver:

nix-env -i -f ./nix/stackage2nix
stackage2nix --resolver lts-10.0

This command will produce Stackage packages packages.nix, packages config configuration-packages.nix and a Haskell packages set default.nix.

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 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 yaml configs:

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