Skip to content

Commit

Permalink
Use latest nixpkgs (adnelson#131)
Browse files Browse the repository at this point in the history
* add some macros to conditionally skip dropSuffix

* explicitly import Control.Monad.Catch
  • Loading branch information
adnelson authored Apr 17, 2018
1 parent d3247a7 commit b89beea
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<version: 2
version: 2
jobs:
build:
docker:
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ $ nix-shell
[nix-shell:nixfromnpm]$ cabal run -- <arguments>
```

#### Customizing `nixpkgs` and GHC versions

By default, we pin the version of `nixpkgs` in order to maintain a
reliable build. However, if you'd like to build off of `nixpkgs` in
your `NIX_PATH` or some other custom location:

```bash
$ nix-env -f release.nix -iA nixfromnpm --arg nixpkgs '<nixpkgs>'
```

The GHC version can also be set explicitly, although of course, the
package is not guaranteed to build with any arbitrary GHC version:

```bash
$ nix-env -f release.nix -iA nixfromnpm --argstr compiler ghc802
```

Note that the above options also apply to `nix-build`, `nix-shell`, etc.

### Usage

#### Using the `nix-node-packages` repo
Expand Down
30 changes: 11 additions & 19 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
{ mkDerivation, aeson, ansi-terminal, base, bytestring
, classy-prelude, containers, curl, data-default, data-fix
, directory, hnix, hspec, lifted-base, MissingH, monad-control, mtl
, directory, exceptions, hnix, hspec, lifted-base, MissingH
, monad-control, mono-traversable, mtl, neat-interpolation
, network-uri, optparse-applicative, parsec, pcre-heavy, QuickCheck
, semver-range, SHA, shelly, stdenv, system-filepath, temporary
, text, text-render, transformers, unix, unordered-containers
, neat-interpolation
}:
mkDerivation {
pname = "nixfromnpm";
version = "0.13.0";
src = ./.;
isLibrary = true;
isExecutable = true;
enableSeparateDataOutput = true;
libraryHaskellDepends = [
aeson ansi-terminal base bytestring classy-prelude containers curl
data-default data-fix directory hnix lifted-base MissingH
monad-control mtl network-uri optparse-applicative parsec
pcre-heavy semver-range SHA shelly system-filepath temporary text
text-render transformers unix unordered-containers
];
executableHaskellDepends = [
aeson ansi-terminal base bytestring classy-prelude containers curl
data-default data-fix directory hnix lifted-base MissingH
monad-control mtl network-uri optparse-applicative parsec
pcre-heavy semver-range SHA shelly system-filepath temporary text
text-render transformers unix unordered-containers
data-default data-fix directory exceptions hnix lifted-base
MissingH monad-control mono-traversable mtl network-uri
optparse-applicative parsec pcre-heavy semver-range SHA shelly
system-filepath temporary text text-render transformers unix
unordered-containers
];
executableHaskellDepends = [ base optparse-applicative ];
testHaskellDepends = [
aeson ansi-terminal base bytestring classy-prelude containers curl
data-default data-fix directory hnix hspec lifted-base MissingH
monad-control mtl network-uri optparse-applicative parsec
pcre-heavy QuickCheck semver-range SHA shelly system-filepath
temporary text text-render transformers unix unordered-containers
neat-interpolation
aeson base bytestring classy-prelude hnix hspec mono-traversable
neat-interpolation QuickCheck text
];
description = "Generate nix expressions from npm packages";
license = stdenv.lib.licenses.mit;
Expand Down
4 changes: 4 additions & 0 deletions nixfromnpm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ library
, NixFromNpm.Options
other-modules: Filesystem.Path.Wrappers
, NixFromNpm.HttpTools
, NixFromNpm.Merge
, NixFromNpm.Npm.Resolve
, Paths_nixfromnpm
other-extensions: NoImplicitPrelude
build-depends: base >=4.8 && < 5.0
, classy-prelude
, mono-traversable
, text
, bytestring
, mtl
Expand Down Expand Up @@ -79,6 +81,7 @@ library
, semver-range >=0.2.7
, data-fix
, pcre-heavy
, exceptions
default-language: Haskell2010

executable nixfromnpm
Expand All @@ -98,6 +101,7 @@ test-suite unit-tests
, OverloadedStrings
build-depends: base >=4.8 && < 5.0
, classy-prelude
, mono-traversable
, aeson
, bytestring
, hnix
Expand Down
12 changes: 8 additions & 4 deletions release.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{ nixpkgs ? (import ./nix/17_09.nix) }:
{
nixpkgs ? import ./nix/17_09.nix,
compiler ? null,
}:
let

config = { allowUnfree = true; };

overlays = [
(newPkgs: oldPkgs: {
(newPkgs: oldPkgs: rec {

haskellPackages = oldPkgs.haskellPackages.override {
origHaskellPackages = if compiler == null then oldPkgs.haskellPackages
else oldPkgs.haskell.packages."${compiler}";
haskellPackages = origHaskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld:
{ semver-range =
haskellPackagesNew.callPackage ./nix/semver-range.nix { };
Expand Down
6 changes: 5 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
args@{...}: (import ./release.nix args).nixfromnpm.env
{
nixpkgs ? import ./nix/17_09.nix,
compiler ? null
}:
(import ./release.nix {inherit nixpkgs compiler;}).nixfromnpm.env
13 changes: 11 additions & 2 deletions src/NixFromNpm/Common.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
Expand All @@ -12,6 +13,7 @@ module NixFromNpm.Common (
module Control.Applicative,
module Control.Exception.Lifted,
module Control.Monad,
module Control.Monad.Catch,
module Control.Monad.Except,
module Control.Monad.Identity,
module Control.Monad.Reader,
Expand All @@ -35,19 +37,24 @@ module NixFromNpm.Common (
module Control.Monad.Trans.Control,
module System.Console.ANSI,
Name, AuthToken, Record, (//), (<>),
uriToText, uriToString, putStrsLn, putStrs, dropSuffix, maybeIf, failC,
uriToText, uriToString, putStrsLn, putStrs, maybeIf, failC,
errorC, joinBy, mapJoinBy, getEnv, modifyMap, unsafeParseURI,
parseURIText, withColor, withUL, warn, warns, assert, fatal, fatalC,
partitionEither, throw, eitherToMaybe
#if !MIN_VERSION_mono_traversable(1,0,7)
, dropSuffix
#endif
) where

import ClassyPrelude hiding (assert, asList, find, FilePath, bracket,
maximum, maximumBy, (</>), (<>),
minimum, try, stripPrefix, ioError,
mapM_, sequence_, foldM, forM_, throw, throwIO,
filterM, replicateM, writeFile, readFile,
writeFileUtf8, readFileUtf8)
writeFileUtf8, readFileUtf8, catch, catches,
Handler)
import Control.Exception (throw)
import Control.Monad.Catch (catch, catches, Handler(..))
import qualified Prelude as P
import Control.Monad.RWS.Strict hiding (Any, (<>))
import Control.Monad (when)
Expand Down Expand Up @@ -141,11 +148,13 @@ putStrsLn = putStrLn . concat
putStrs :: MonadIO m => [Text] -> m ()
putStrs = putStr . concat

#if !MIN_VERSION_mono_traversable(1,0,7)
-- | Strip the given suffix from the given string.
dropSuffix :: Text -> Text -> Text
dropSuffix suffix input = case T.stripSuffix suffix input of
Nothing -> input
Just stripped -> stripped
#endif

-- | Return a Just value if the argument is True, else Nothing.
maybeIf :: Bool -> a -> Maybe a
Expand Down

0 comments on commit b89beea

Please sign in to comment.