Re: [Nix-dev] Project environment setup

2016-07-19 Thread Daniel Hlynskyi
Looks like gradle25 package doesn't follow nixpkgs conventions here. It has
no `.override` attribute, which, as I remember, is added by `callPackage`
function.
I think this is a bug, but there is a workaround:

```
# shell.nix

{ pkgs ? import  {} }:
let
  mygradle = (pkgs.gradleGen.override {
jdk = pkgs.openjdk8;
  }).gradle25;
in pkgs.stdenv.mkDerivation {
name = "myproject";
buildInputs = [ mygradle ];
}
```

You didn't want `.overrideDerivation` here, I think, just `.override`.

2016-07-19 3:53 GMT+03:00 Ryan Eckbo :

> I've been reading the docs and blog posts but I'm still unsure on the
> proper
> way to configure a local shell.nix with my required modified packages.
> Specifically, I need gradle built with jdk 8, something like
>
>pkgs.gradle25.override { jdk = pkgs.openjdk8; }
>
> and I also have some local nix expressions. But I only want this for one
> project (so no
> setting of .nixpkgs/config.nix).  Can someone point me in the right
> direction?
>
> Thanks!
> Ryan
>
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Project environment setup

2016-07-18 Thread Ryan Eckbo

Ok I figured it out, sorry for the public conversation with myself but I
hope that it can help other new Nix users.  The use case is: you have 
some
private nix expressions and would like to configure a project 
environment
that includes those as well as some modified packages provided by 
nixpkgs.

Here's an example how to do it:

# nixpkgs-custom.nix - add your custom expressions to nixpkgs
{ system ? builtins.currentSystem }:

let
pkgs = import  { inherit system; };
callPackage = pkgs.lib.callPackageWith (pkgs // self);
self = {
  ITK = callPackage ./ITK { };
  SlicerExecutionModel = callPackage ./SlicerExecutionModel { };
  DWIConvert = callPackage ./DWIConvert { };
  teem = callPackage ./teem { };
  };
in
  pkgs // self


# shell.nix - the environment you want for a project
{ pkgs ? import  {} }:

let
  mygradle = pkgs.gradleGen.override  {
jdk = pkgs.openjdk8;  // build a gradle that uses JDK 8
};
in
pkgs.stdenv.mkDerivation {
name = "myproject";
src = ./.;
buildInputs = [ mygradle.gradle25 pkgs.DWIConvert pkgs.teem ];  // 
your software environment

}

# Run as
nix-shell --arg pkgs 'import path/to/nixpkgs-custom.nix {}'

And don't be surprised when you wait over 2 minutes for the nix shell 
prompt when
you're running it in a directory that's 900M -- nix will load it all 
into memory!


cheers,
Ryan


On 19 Jul 2016, at 13:17, Ryan Eckbo wrote:


For example, the shell.nix I wrote below doesn't make a gradle
available with openjdk8, and also takes 2m20s to load (!) when
I run `nix-shell`:

# shell.nix
# nix-shell prints 'warning: dumping very large path (> 256 MiB); this 
may run out of memory'

{ pkgs ? import  {} }:

let
  mygradle = pkgs.lib.overrideDerivation pkgs.gradle25 (oldAttrs: {
jdk = pkgs.openjdk8;
});
in
pkgs.stdenv.mkDerivation {
name = "myproject";
src = ./.;
buildInputs = [ mygradle ];
}



On 19 Jul 2016, at 10:53, Ryan Eckbo wrote:

I've been reading the docs and blog posts but I'm still unsure on the 
proper
way to configure a local shell.nix with my required modified 
packages.

Specifically, I need gradle built with jdk 8, something like

   pkgs.gradle25.override { jdk = pkgs.openjdk8; }

and I also have some local nix expressions. But I only want this for 
one project (so no
setting of .nixpkgs/config.nix).  Can someone point me in the right 
direction?


Thanks!
Ryan

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

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

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


Re: [Nix-dev] Project environment setup

2016-07-18 Thread Alex Berg
Also, you probably already found it, but there is some docs in the nixpkgs
manual, called "11.2.5. How to create ad hoc environments for nix-shell"

On Mon, Jul 18, 2016 at 9:41 PM, Alex Berg  wrote:

> Looks like that shell.nix file is correct.
>
> That load-time is only the first time, right? On the first run, all
> dependencies are fetched, but after that there is no need.
>
> What are you expecting? If you enter that nix-shell, you'll have a
> `gradle` command. Are you expecting a `java` command, also? If you want a
> `java` command, then you need to add a jdk to the "buildInputs". You can
> add `pkgs.openjdk7`, and the `java` command will run that while the
> `gradle` command refers to openjdk8. If you want `java` command to use
> openjdk8, then add `pkgs.openjdk8` to the "buildInputs".
>
>
> On Mon, Jul 18, 2016 at 8:17 PM, Ryan Eckbo  wrote:
>
>> For example, the shell.nix I wrote below doesn't make a gradle
>> available with openjdk8, and also takes 2m20s to load (!) when
>> I run `nix-shell`:
>>
>> # shell.nix
>> # nix-shell prints 'warning: dumping very large path (> 256 MiB); this
>> may run out of memory'
>> { pkgs ? import  {} }:
>>
>> let
>>   mygradle = pkgs.lib.overrideDerivation pkgs.gradle25 (oldAttrs: {
>> jdk = pkgs.openjdk8;
>> });
>> in
>> pkgs.stdenv.mkDerivation {
>> name = "myproject";
>> src = ./.;
>> buildInputs = [ mygradle ];
>>
>> }
>>
>>
>>
>> On 19 Jul 2016, at 10:53, Ryan Eckbo wrote:
>>
>> I've been reading the docs and blog posts but I'm still unsure on the
>>> proper
>>> way to configure a local shell.nix with my required modified packages.
>>> Specifically, I need gradle built with jdk 8, something like
>>>
>>>pkgs.gradle25.override { jdk = pkgs.openjdk8; }
>>>
>>> and I also have some local nix expressions. But I only want this for one
>>> project (so no
>>> setting of .nixpkgs/config.nix).  Can someone point me in the right
>>> direction?
>>>
>>> Thanks!
>>> Ryan
>>>
>>> ___
>>> nix-dev mailing list
>>> nix-dev@lists.science.uu.nl
>>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>>
>> ___
>> nix-dev mailing list
>> nix-dev@lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>
>
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Project environment setup

2016-07-18 Thread Alex Berg
Looks like that shell.nix file is correct.

That load-time is only the first time, right? On the first run, all
dependencies are fetched, but after that there is no need.

What are you expecting? If you enter that nix-shell, you'll have a `gradle`
command. Are you expecting a `java` command, also? If you want a `java`
command, then you need to add a jdk to the "buildInputs". You can add
`pkgs.openjdk7`, and the `java` command will run that while the `gradle`
command refers to openjdk8. If you want `java` command to use openjdk8,
then add `pkgs.openjdk8` to the "buildInputs".


On Mon, Jul 18, 2016 at 8:17 PM, Ryan Eckbo  wrote:

> For example, the shell.nix I wrote below doesn't make a gradle
> available with openjdk8, and also takes 2m20s to load (!) when
> I run `nix-shell`:
>
> # shell.nix
> # nix-shell prints 'warning: dumping very large path (> 256 MiB); this may
> run out of memory'
> { pkgs ? import  {} }:
>
> let
>   mygradle = pkgs.lib.overrideDerivation pkgs.gradle25 (oldAttrs: {
> jdk = pkgs.openjdk8;
> });
> in
> pkgs.stdenv.mkDerivation {
> name = "myproject";
> src = ./.;
> buildInputs = [ mygradle ];
>
> }
>
>
>
> On 19 Jul 2016, at 10:53, Ryan Eckbo wrote:
>
> I've been reading the docs and blog posts but I'm still unsure on the
>> proper
>> way to configure a local shell.nix with my required modified packages.
>> Specifically, I need gradle built with jdk 8, something like
>>
>>pkgs.gradle25.override { jdk = pkgs.openjdk8; }
>>
>> and I also have some local nix expressions. But I only want this for one
>> project (so no
>> setting of .nixpkgs/config.nix).  Can someone point me in the right
>> direction?
>>
>> Thanks!
>> Ryan
>>
>> ___
>> nix-dev mailing list
>> nix-dev@lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Project environment setup

2016-07-18 Thread Ryan Eckbo

For example, the shell.nix I wrote below doesn't make a gradle
available with openjdk8, and also takes 2m20s to load (!) when
I run `nix-shell`:

# shell.nix
# nix-shell prints 'warning: dumping very large path (> 256 MiB); this 
may run out of memory'

{ pkgs ? import  {} }:

let
  mygradle = pkgs.lib.overrideDerivation pkgs.gradle25 (oldAttrs: {
jdk = pkgs.openjdk8;
});
in
pkgs.stdenv.mkDerivation {
name = "myproject";
src = ./.;
buildInputs = [ mygradle ];
}



On 19 Jul 2016, at 10:53, Ryan Eckbo wrote:

I've been reading the docs and blog posts but I'm still unsure on the 
proper

way to configure a local shell.nix with my required modified packages.
Specifically, I need gradle built with jdk 8, something like

   pkgs.gradle25.override { jdk = pkgs.openjdk8; }

and I also have some local nix expressions. But I only want this for 
one project (so no
setting of .nixpkgs/config.nix).  Can someone point me in the right 
direction?


Thanks!
Ryan

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

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


[Nix-dev] Project environment setup

2016-07-18 Thread Ryan Eckbo
I've been reading the docs and blog posts but I'm still unsure on the 
proper

way to configure a local shell.nix with my required modified packages.
Specifically, I need gradle built with jdk 8, something like

   pkgs.gradle25.override { jdk = pkgs.openjdk8; }

and I also have some local nix expressions. But I only want this for one 
project (so no
setting of .nixpkgs/config.nix).  Can someone point me in the right 
direction?


Thanks!
Ryan

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