Re: [Nix-dev] [haskell NG] Override package

2015-02-24 Thread YCH
Hello,

I've done successfully using method 1) .

Thanks.

~~~
~/hdevtools $ cabal2nix . > default.nix

~/ $ cat ~/.nixpkgs/config.nix
{
  allowUnfree = true;
  haskellPackageOverrides = self: super: {
  hdevtools = self.callPackage ../hdevtools {};
  };
}

~/cis194 $ cat shell.nix
with (import  {}).pkgs;
let pkg = haskellngPackages.callPackage
({ mkDerivation, base, MissingH, QuickCheck, stdenv, tasty
 , tasty-hunit, tasty-quickcheck, tasty-rerun, tasty-th
 }:
 mkDerivation {
   pname = "cis194";
   version = "0.1.0.0";
   src = ./.;
   isLibrary = false;
   isExecutable = true;
   buildDepends = [
 base MissingH QuickCheck tasty tasty-hunit tasty-quickcheck
 tasty-rerun tasty-th
   ];
   buildTools = [
 haskellngPackages.hdevtools
 haskellngPackages.cabal-install
   ];
   license = stdenv.lib.licenses.unfree;
 }) {};
in
  pkg.env
~~~

On Wed, Feb 18, 2015 at 8:18 AM, Daniel Bergey  wrote:
> On 2015-02-16 at 08:42, YCH  wrote:
>> I've read quite many document. Wiki, nix pills, ... . But I'm confused about
>> so many different ways doing similar things. And I'm worried about haskell-ng
>> specific things. There is already 'haskellngPackages.hdevtools'. So I should
>> override using ~/hdevtools. I'll attach my current setup information.
>
> Nix certainly has an overwhelming number of options for similar things.
> Here are two options for your situation:
>
> 1. Override hdevtools for all your builds, editing
> ~/.nixpkgs/config.nix, following the explanation in [1].  This is
> probably the right thing; I expect you always want the patched
> hdevtools.  A complete config.nix:
>
> 2. Override hdevtools in your shell.nix, just for this build.  This is
> useful when you need a patched version of some Haskell library, rather
> than a build tool.  In this case, add to the let definitions (before
> pkg)
>
> hdevtools = haskellngPackages.callPackage ~/hdevtools {};
>
> I think you'll need to replace the ~ with your homedir; ISTR Nix doesn't
> interpret ~.  Then change your buildTools line to refer to hdevtools,
> not haskellngPackages.hdevtools.
>
> cheers,
> bergey
>
> Footnotes:
> [1]  http://lists.science.uu.nl/pipermail/nix-dev/2015-January/015601.html
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] [haskell NG] Override package

2015-02-19 Thread Shea Levy

> On Feb 17, 2015, at 6:18 PM, Daniel Bergey  wrote:
> 
> I think you'll need to replace the ~ with your homedir; ISTR Nix doesn't
> interpret ~.  Then change your buildTools line to refer to hdevtools,
> not haskellngPackages.hdevtools.

You inspired me: https://github.com/NixOS/nix/pull/480
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] [haskell NG] Override package

2015-02-19 Thread Daniel Bergey
On 2015-02-16 at 08:42, YCH  wrote:
> I've read quite many document. Wiki, nix pills, ... . But I'm confused about
> so many different ways doing similar things. And I'm worried about haskell-ng
> specific things. There is already 'haskellngPackages.hdevtools'. So I should
> override using ~/hdevtools. I'll attach my current setup information.

Nix certainly has an overwhelming number of options for similar things.
Here are two options for your situation:

1. Override hdevtools for all your builds, editing
~/.nixpkgs/config.nix, following the explanation in [1].  This is
probably the right thing; I expect you always want the patched
hdevtools.  A complete config.nix:

2. Override hdevtools in your shell.nix, just for this build.  This is
useful when you need a patched version of some Haskell library, rather
than a build tool.  In this case, add to the let definitions (before
pkg)

hdevtools = haskellngPackages.callPackage ~/hdevtools {};

I think you'll need to replace the ~ with your homedir; ISTR Nix doesn't
interpret ~.  Then change your buildTools line to refer to hdevtools,
not haskellngPackages.hdevtools.

cheers,
bergey

Footnotes: 
[1]  http://lists.science.uu.nl/pipermail/nix-dev/2015-January/015601.html

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] [haskell NG] Override package

2015-02-18 Thread Kirill Elagin
There are multiple ways to override a package in haskell-ng. Personally I
use the most general one, that is `haskellngPackages.override`.

`haskellngPackages` is itself a function with default arguments provided in
`top-level/all-packages.nix`, but you can call `haskellngPackages.override`
passing it an attrset with arguments to override, and in our case we want
to override the `overrides` argument (huh), which is internally appended to
the haskell packages set. The `overrides` argument should be a function,
taking two arguments, `self` (the resulting set of haskell packages) and
`super` (the original set of haskell packages); and it should return the
attrset of new or overriden packages.

Inside of that attrset you might want to use `overrideCabal` to alter the
derivation.

Here is an example. That’s how I override the `hoq` package to use my local
git checkout with fixes I need:

~~~
{
  <...>

  packageOverrides = pkgs_: let pkgs = pkgs_.pkgs; in with pkgs; {

<...>

haskellngPackages = pkgs_.haskellngPackages.override {
  overrides = self: super: {
hoq = haskell-ng.lib.overrideCabal super.hoq
  (drv: {
src = fetchgit {
  url = "/home/kirrun/proj/hoq";
  rev = "dc78b0f9600163670a3bdd6259dbdd69acc63087";
  sha256 =
"0v4mll94xkjfpw8dpdgdm71zmdmvbp64pn77yw8xzrczyn06q46l";
};
  });
  };
};
  };
}
~

Here is how it works:

1. Is override the whole `haskellngPackages` using `packageOverrides` as
one does with all other (not necessariliy haskell-related) packages.
2. I use `pkgs` for the new `pkgs` and `pkgs_` for the original ones. This
is needed because `haskellngPackages` is defined using `haskellngPackages`
which causes infinite recursion otherwise.
3. I use `haskell-ng.lib.overrideCabal` to override the derivation of
`hoq`, which takes a function from the original derivation to the attrset
of attributes to replace. I replace ontly the `src` attribute.

Note that the net result is that the only thing changed in the derivation
is its `src` attribute. In case you want to do more intrusive changes it
_might_ (or, more likely, might not!) be easier to put together a brand new
derivation and just `callPackage` it.


On Mon Feb 16 2015 at 11:42:12 AM YCH  wrote:

> Hello,
>
> I'm very happily learning Haskell with nix-shell and haskell-ng
> environment. In
> comparison to previous 'haskell', there is no problem at all.
>
> But I've found problem that hdevtools does not see related build-depends
> options in cabal file.
>
> https://github.com/bitc/hdevtools/issues/38
>
> So I would try patched hdevtools from fork.
>
> https://github.com/maximkulkin/hdevtools
>
> Cloned, checked out proper branch. What is next step?
>
> I've read quite many document. Wiki, nix pills, ... . But I'm confused
> about
> so many different ways doing similar things. And I'm worried about
> haskell-ng
> specific things. There is already 'haskellngPackages.hdevtools'. So I
> should
> override using ~/hdevtools. I'll attach my current setup information.
>
> Arch Linux
> nix-unstable
>
> Thanks.
>
> ~~~
> $ nix-env -q
> cabal-install-1.22.0.0
> cabal2nix-2.0
> nix-1.8
> nox-0.0.1
>
> $ ls -1
> cis194.cabal
> HW01.hs
> HW02.hs
> LICENSE
> Main.hs
> Setup.hs
> shell.nix
> Test.hs
> ... snip ...
>
> $ cat cis194.cabal
>
> -- Initial cis194.cabal generated by cabal init.  For further
> -- documentation, see http://haskell.org/cabal/users-guide/
>
> name:cis194
> version: 0.1.0.0
> -- synopsis:
> -- description:
> -- license:
> license-file:LICENSE
> author:  dontdieych
> maintainer:  dontdie...@gmail.com
> -- copyright:
> -- category:
> build-type:  Simple
> -- extra-source-files:
> cabal-version:   >=1.10
>
> library
>   default-language:Haskell2010
>   build-depends:
> base >=4.7 && <4.8
> , MissingH
>   exposed-modules:
> HW01
> , HW02
>
> executable cis194
>   default-language:Haskell2010
>   main-is: Main.hs
>   -- hs-source-dirs:
>   -- other-modules:
>   -- other-extensions:
>   build-depends:
> base >=4.7 && <4.8
>
> test-suite test
>   default-language: Haskell2010
>   type: exitcode-stdio-1.0
>   main-is: Test.hs
>   build-depends:
> base >=4.7 && <4.8
> , tasty
> , tasty-th
> , tasty-quickcheck
> , tasty-rerun
> -- , QuickCheck
>
> $ cat shell.nix   # cabal2nix . --shell > shell.nix
>
> with (import  {}).pkgs;
> let pkg = haskellngPackages.callPackage
> ({ mkDerivation, base, MissingH, QuickCheck, stdenv, tasty
>  , tasty-hunit, tasty-quickcheck, tasty-rerun, tasty-th
>  }:
>  mkDerivation {
>pname = "cis194";
>version = "0.1.0.0";
>src = ./.;
>isLibrary = false;
>isExecutable = true;
>buildDepends = [
>  base MissingH QuickCheck tasty t

[Nix-dev] [haskell NG] Override package

2015-02-16 Thread YCH
Hello,

I'm very happily learning Haskell with nix-shell and haskell-ng environment. In
comparison to previous 'haskell', there is no problem at all.

But I've found problem that hdevtools does not see related build-depends
options in cabal file.

https://github.com/bitc/hdevtools/issues/38

So I would try patched hdevtools from fork.

https://github.com/maximkulkin/hdevtools

Cloned, checked out proper branch. What is next step?

I've read quite many document. Wiki, nix pills, ... . But I'm confused about
so many different ways doing similar things. And I'm worried about haskell-ng
specific things. There is already 'haskellngPackages.hdevtools'. So I should
override using ~/hdevtools. I'll attach my current setup information.

Arch Linux
nix-unstable

Thanks.

~~~
$ nix-env -q
cabal-install-1.22.0.0
cabal2nix-2.0
nix-1.8
nox-0.0.1

$ ls -1
cis194.cabal
HW01.hs
HW02.hs
LICENSE
Main.hs
Setup.hs
shell.nix
Test.hs
... snip ...

$ cat cis194.cabal

-- Initial cis194.cabal generated by cabal init.  For further
-- documentation, see http://haskell.org/cabal/users-guide/

name:cis194
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file:LICENSE
author:  dontdieych
maintainer:  dontdie...@gmail.com
-- copyright:
-- category:
build-type:  Simple
-- extra-source-files:
cabal-version:   >=1.10

library
  default-language:Haskell2010
  build-depends:
base >=4.7 && <4.8
, MissingH
  exposed-modules:
HW01
, HW02

executable cis194
  default-language:Haskell2010
  main-is: Main.hs
  -- hs-source-dirs:
  -- other-modules:
  -- other-extensions:
  build-depends:
base >=4.7 && <4.8

test-suite test
  default-language: Haskell2010
  type: exitcode-stdio-1.0
  main-is: Test.hs
  build-depends:
base >=4.7 && <4.8
, tasty
, tasty-th
, tasty-quickcheck
, tasty-rerun
-- , QuickCheck

$ cat shell.nix   # cabal2nix . --shell > shell.nix

with (import  {}).pkgs;
let pkg = haskellngPackages.callPackage
({ mkDerivation, base, MissingH, QuickCheck, stdenv, tasty
 , tasty-hunit, tasty-quickcheck, tasty-rerun, tasty-th
 }:
 mkDerivation {
   pname = "cis194";
   version = "0.1.0.0";
   src = ./.;
   isLibrary = false;
   isExecutable = true;
   buildDepends = [
 base MissingH QuickCheck tasty tasty-hunit tasty-quickcheck
 tasty-rerun tasty-th
   ];
   buildTools = [
 haskellngPackages.hdevtools # I've added this config.
   ];
   license = stdenv.lib.licenses.unfree;
 }) {};
in
  pkg.env

$ cat ../hdevtools/default.nix # via cabal2nix . > defult.nix

{ mkDerivation, base, Cabal, cmdargs, directory, filepath, ghc
, ghc-paths, network, stdenv, syb, time, transformers, unix
}:
mkDerivation {
  pname = "hdevtools";
  version = "0.1.0.6";
  src = ./.;
  isLibrary = false;
  isExecutable = true;
  buildDepends = [
base Cabal cmdargs directory filepath ghc ghc-paths network syb
time transformers unix
  ];
  homepage = "https://github.com/bitc/hdevtools/";;
  description = "Persistent GHC powered background server for FAST
haskell development tools";
  license = stdenv.lib.licenses.mit;
}
~~~
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev