Skip to content

Instantly share code, notes, and snippets.

@jkachmar
Created June 13, 2020 16:37
Show Gist options
  • Save jkachmar/e5415efb295b425ef13b7bbe7fecd341 to your computer and use it in GitHub Desktop.
Save jkachmar/e5415efb295b425ef13b7bbe7fecd341 to your computer and use it in GitHub Desktop.
Nix Haskell developPackages Demo

Quickstart

  1. Make a new directory and place the other files at their described paths relative to that directory's root
  • library.DemoLib.hs should be placed at library/DemoLib.hs, gists don't allow a naming convention of library/DemoLib.hs
  1. Run the following command:
nix-shell -E 'let pkgs = import ./pinned.nix {}; pkg =  pkgs.haskellPackages.developPackage { root = ./.; }; in pkg.overrideAttrs (attrs: { buildInputs = attrs.buildInputs ++ [ pkgs.cabal-install]; })'
  1. Run cabal update (to ensure that there's a valid $HOME/.cabal directory with relevant Hackage information, even though we're not going to use it)
  2. Run cabal build and verify that the package builds.
cabal-version: 3.0
name:
demo
version:
0.0.1
synopsis:
Demonstrate a pinned Nix package set with Nix Haskell developPackage
license:
MIT
author:
jkachmar
build-type:
Simple
extra-source-files:
readme.md
-------------------------------------------------------------------------------
common common
default-language: Haskell2010
ghc-options:
-Weverything
-Wno-all-missed-specializations
-Wno-implicit-prelude
-Wno-missing-export-lists
-Wno-missing-exported-signatures
-Wno-missing-import-lists
-Wno-missing-local-signatures
-Wno-missed-specialisations
-Wno-monomorphism-restriction
-Wno-safe
-Wno-unsafe
default-extensions:
OverloadedStrings
ScopedTypeVariables
build-depends:
-- Convenient libraries to keep around that are included with GHC anyway
base
-- External library
, unordered-containers
-------------------------------------------------------------------------------
library
import: common
hs-source-dirs: library
exposed-modules:
DemoLib
module DemoLib (demo) where
demo :: IO ()
demo = putStrLn "Hello!"
import (
builtins.fetchTarball {
# Latest commit on the nixpkgs-unstable branch as of 12 June 2020
url = "https://github.com/nixos/nixpkgs/archive/dcb64ea42e64aaecd8e6fef65cc86245c9666818.tar.gz";
sha256 = "0i77sgs0gic6pwbkvk9lbpfshgizdrqyh18law2ji1409azc09w0";
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment