[Nix-dev] ANN: Ruby packaging changes coming soon

2015-07-05 Thread Charles Strahan
Hello all,

In the next day or two, I intend to merge this PR:
https://github.com/NixOS/nixpkgs/pull/8612

This will greatly improve the way we handle Ruby/Bundler packages.

Before I introduce the benefits, I'd like to draw attention to a
breaking change: you should now pass `gemName` and `version` to
`buildRubyGem`, instead of passing `name`. For example:

  buildRubyGem {
name = "some-name"; # name now specifies the drv name,
# which defaults to
--
gemName = "some-gem";
version = "1.2.3";
sha256  = "08p5gx18yrbnwc6xc0mxvsfaxzgy2y9i78xq7ds0qmdm67q39y4z";
gemPath = [ /* other gem deps go here */ ];
  }

Now, on to the bundlerEnv improvements.

These changes greatly simplify things over the existing approach. A lot
of grossness originally came from the fact that Bundler _requires_ a
single prefix in order to function. So, I originally wrote enough hacks
and monkey-patches to get Bundler to install all gems in one go,
patching over internals to prevent Bundler from trying to reach out to
the internet (Bundler has practically no useful, public, stable API, so
patching is the only way to go). The hacks I wrote were incredibly ugly
and hard to follow, and they've weighed considerably on my conscience
for quite some time.

Going forward, we'll have a much, much smaller set of patches to get
Bundler to install into individual prefixes, and then we create a
symlink forest at the very end to appease Bundler. Even with a little
extra added documentation, the diff still comes out with fewer lines
added than removed, and (I think) the implementation is a little less
bat-shit-crazy.

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


Re: [Nix-dev] nixos modules: Setting attrsOf sub-options

2015-07-05 Thread Nicolas Pierron
Hi,

On Wed, Jul 1, 2015 at 12:31 AM, Rickard Nilsson
 wrote:
>top = mkMerge (
>  map (a: { ${a}.opt2 = f a; }) (attrNames config.top)
>)

This would work, only if you were not redefining top, or if you knew
the list of names ahead.

> {
>options.top = mkOption {
>  type = with types; attrsOf (submodule ({ name, config, ... }: {
>config.opt2 = f name;
>  };
>};
> }

On the other hand, this is the proper way to extend submodules.
Note that `opt1` can be accessed with `config.opt1` within each submodule.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Garbled man pages/incomplete environment

2015-07-05 Thread Jeffrey David Johnson
Yeah I think that's what caused it. I got all my normal environment variables 
back by removing the lib.mkForce and using lib.mkOverride instead on just 
NIX_PATH, and now my PAGER is set to that and man pages work.
Jeff

On Sun, 05 Jul 2015 20:53:35 +0200
Eelco Dolstra  wrote:

> Hi,
> 
> On 04/07/15 18:24, Jeffrey David Johnson wrote:
> 
> > Man pages are hard to read because they're full of control characters. For 
> > example:
> > 
> > NIXOS-REBUILD(8)  NixOS Reference Pages  
> > NIXOS-REBUILD(8)
> > 
> > ESC[1mNAMEESC[0m
> 
> This can be a symptom of $PAGER not being set to "less -R".
> 
> -- 
> Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/
> ___
> 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] Garbled man pages/incomplete environment

2015-07-05 Thread Jeffrey David Johnson
If I do that it complains that NIX_PATH is set elsewhere already. I
think it's merging the attribute sets but not individual attributes.
Which is good, wouldn't want it just concatenating strings or something
else magical. That's why I originally put in the lib.mkForce to
override it.

Thanks for mentioning it though, because that led me to figure it out! I
found the function that does the merging in
nixpkgs/nixos/modules/config/shells-environment.nix:

environment.variables = mkOption {
  default = {};
  description = ''
A set of environment variables used in the global environment.
These variables will be set on shell initialisation.
The value of each variable can be either a string or a list of
strings.  The latter is concatenated, interspersed with colon
characters.
  '';
  type = types.attrsOf (mkOptionType {
name = "a string or a list of strings";
merge = loc: defs:
  let
defs' = filterOverrides defs;
res = (head defs').value;
  in
  if isList res then concatLists (getValues defs')
  else if lessThan 1 (length defs') then
throw "The option `${showOption loc}' is defined multiple
times, in ${showFiles (getFiles defs)}." else if !isString res then
throw "The option `${showOption loc}' does not have a
string value, in ${showFiles (getFiles defs)}." else res;
  });
  apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v
else v); };

The mkOverrides looked related, so I found it in
nixpkgs/lib/modules.nix. It's a little over my head but the comments
explain:

  /* Given a list of config values, process the mkOverride properties,
 that is, return the values that have the highest (that is,
 numerically lowest) priority, and strip the mkOverride
 properties.  For example,

   [ { file = "/1"; value = mkOverride 10 "a"; }
 { file = "/2"; value = mkOverride 20 "b"; }
 { file = "/3"; value = "z"; }
 { file = "/4"; value = mkOverride 10 "d"; }
   ]

 yields

   [ { file = "/1"; value = "a"; }
 { file = "/4"; value = "d"; }
   ]

 Note that "z" has the default priority 100.
  */

So I used that, and it works!

  environment.variables = rec {
# other vars here
NIX_PATH = lib.mkOverride 10 "/git/hub/nixcfg"; # use anything below 100
  };

I think I even about that in the manual somewhere, but had forgotten it.
Jeff

On Sun, 5 Jul 2015 11:17:10 -0700
James Cook  wrote:

> What if you leave out the "config.environment.variables //" part (just
> environment.variables = { NIX_PATH = "/git/hub/nixcfg"; };)?
> 
> The NixOS config infrastructure is supposed to take care of the //
> part for you. I think the infinite recursion happens because
> config.environment.variables is partly based on the value you define
> for environment.variables.
> 
> James
> 
> On 5 July 2015 at 10:51, Jeffrey David Johnson  wrote:
> > Thanks, you're right that was it! I put the mkForce in while trying to
> > set NIX_PATH, then forgot to remove it after moving that to
> > interactiveShellInit instead. Man pages/environment variables back to
> > normal.
> >
> > That reminds me though, is there a way to force NIX_PATH while leaving
> > the rest in place? I tried:
> >
> > { config, ... }:
> > { environment.variables = config.environment.variables // {
> > # my other vars here
> > NIX_PATH = "/git/hub/nixcfg";
> >   };
> > }
> >
> > But it causes infinite recursion. I imagine there's a special hook
> > or override pattern for that?
> > Jeff
> >
> > On Sat, 4 Jul 2015 18:20:20 -0700
> > James Cook  wrote:
> >
> >> On 4 July 2015 at 09:24, Jeffrey David Johnson  wrote:
> >> > I'm having the same issue described here on the Gentoo forums:
> >> >
> >> > https://forums.gentoo.org/viewtopic-t-670013.html
> >> >
> >> > Man pages are hard to read because they're full of control characters. 
> >> > For example:
> >> >
> >> > NIXOS-REBUILD(8)  NixOS Reference Pages  
> >> > NIXOS-REBUILD(8)
> >> >
> >> > ESC[1mNAMEESC[0m
> >> >nixos-rebuild - reconfigure a NixOS machine
> >> >
> >> > ESC[1mSYNOPSISESC[0m
> >> >ESC[1mnixos-rebuild ESC[22m{ESC[1mswitch ESC[22m| ESC[1mboot 
> >> > ESC[22m| ESC[1mtest
> >> > ESC[22m| ESC[1mbuild ESC[22m| ESC[1mdry-build ESC[22m| 
> >> > ESC[1mdry-activate ESC[22m|
> >> > ...
> >> >
> >> > I expect it's a problem with my environment variables, so
> >> > here's my profile.nix which I import into configuration.nix:
> >> >
> >> > with import ;
> >> >
> >> > {
> >> >   programs.bash = {
> >> > enableCompletion = true;
> >> > # promptInit = "PS1=\"# \"";
> >> >   };
> >> >
> >> >   # replaces traditional xinitrc
> >> >   services.xserver.displayManager.sessionCommands = ''
> >> > export EDITOR=qvim # why no gvim?
> >> > xsetroot -cursor_name left_ptr &
> >> > [[ -a ~/.fehbg ]] && eval $(cat ~/.fehbg)
> >> > unclutter -

Re: [Nix-dev] Garbled man pages/incomplete environment

2015-07-05 Thread Eelco Dolstra
Hi,

On 04/07/15 18:24, Jeffrey David Johnson wrote:

> Man pages are hard to read because they're full of control characters. For 
> example:
> 
> NIXOS-REBUILD(8)  NixOS Reference Pages  
> NIXOS-REBUILD(8)
> 
> ESC[1mNAMEESC[0m

This can be a symptom of $PAGER not being set to "less -R".

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Garbled man pages/incomplete environment

2015-07-05 Thread James Cook
What if you leave out the "config.environment.variables //" part (just
environment.variables = { NIX_PATH = "/git/hub/nixcfg"; };)?

The NixOS config infrastructure is supposed to take care of the //
part for you. I think the infinite recursion happens because
config.environment.variables is partly based on the value you define
for environment.variables.

James

On 5 July 2015 at 10:51, Jeffrey David Johnson  wrote:
> Thanks, you're right that was it! I put the mkForce in while trying to
> set NIX_PATH, then forgot to remove it after moving that to
> interactiveShellInit instead. Man pages/environment variables back to
> normal.
>
> That reminds me though, is there a way to force NIX_PATH while leaving
> the rest in place? I tried:
>
> { config, ... }:
> { environment.variables = config.environment.variables // {
> # my other vars here
> NIX_PATH = "/git/hub/nixcfg";
>   };
> }
>
> But it causes infinite recursion. I imagine there's a special hook
> or override pattern for that?
> Jeff
>
> On Sat, 4 Jul 2015 18:20:20 -0700
> James Cook  wrote:
>
>> On 4 July 2015 at 09:24, Jeffrey David Johnson  wrote:
>> > I'm having the same issue described here on the Gentoo forums:
>> >
>> > https://forums.gentoo.org/viewtopic-t-670013.html
>> >
>> > Man pages are hard to read because they're full of control characters. For 
>> > example:
>> >
>> > NIXOS-REBUILD(8)  NixOS Reference Pages  
>> > NIXOS-REBUILD(8)
>> >
>> > ESC[1mNAMEESC[0m
>> >nixos-rebuild - reconfigure a NixOS machine
>> >
>> > ESC[1mSYNOPSISESC[0m
>> >ESC[1mnixos-rebuild ESC[22m{ESC[1mswitch ESC[22m| ESC[1mboot 
>> > ESC[22m| ESC[1mtest
>> > ESC[22m| ESC[1mbuild ESC[22m| ESC[1mdry-build ESC[22m| ESC[1mdry-activate 
>> > ESC[22m|
>> > ...
>> >
>> > I expect it's a problem with my environment variables, so
>> > here's my profile.nix which I import into configuration.nix:
>> >
>> > with import ;
>> >
>> > {
>> >   programs.bash = {
>> > enableCompletion = true;
>> > # promptInit = "PS1=\"# \"";
>> >   };
>> >
>> >   # replaces traditional xinitrc
>> >   services.xserver.displayManager.sessionCommands = ''
>> > export EDITOR=qvim # why no gvim?
>> > xsetroot -cursor_name left_ptr &
>> > [[ -a ~/.fehbg ]] && eval $(cat ~/.fehbg)
>> > unclutter -idle 1 &
>> > eval "$(ssh-agent -s)" &
>> >   '';
>> >
>> >   environment.variables = lib.mkForce rec {
>> > EDITOR   = "vim" ;
>> > TERM = TERMINAL;
>> > TERMINAL = "xfce4-terminal";
>> >   };
>> >
>> >   # this gets reset if in environment.variables for some reason
>> >   environment.interactiveShellInit = ''
>> > export NIX_PATH=/git/hub/nixcfg
>> >   '';
>> >
>> >   # TODO why can't nix-env find things on the regular NIX_PATH?
>> >   environment.shellAliases = {
>> > "nix-env" = "nix-env -f ${}";
>> >   };
>> > }
>> >
>> > As you can see I also have issues setting up NIX_PATH.
>> > The current kludgy solution is working OK, but if you know
>> > how to clean it up please mention that too! My worry is
>> > that I've deleted all the environment variables not
>> > mentioned here including some important ones, and man
>> > pages are just the first thing I noticed.
>> >
>> > Thanks
>> > Jeff
>>
>> The only thing that comes to mind: environment.varibles = lib.mkForce
>> ... looks suspicious to me. Does it work without the mkForce?
>>
>> (If environment.variables is like other configuration variables I've
>> met, then mkForce means discard whatever the defaults are, and leaving
>> out mkForce means append the values you specify to whatever the
>> defaults are.)
>>
>> You could always start commenting out parts of the configuration and
>> observing the changes, but of course that's tedious. Maybe using
>> nixos-rebuild build-vm could help.
>>
>> James
> ___
> 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] Garbled man pages/incomplete environment

2015-07-05 Thread Jeffrey David Johnson
Thanks, you're right that was it! I put the mkForce in while trying to
set NIX_PATH, then forgot to remove it after moving that to
interactiveShellInit instead. Man pages/environment variables back to
normal.

That reminds me though, is there a way to force NIX_PATH while leaving
the rest in place? I tried:

{ config, ... }:
{ environment.variables = config.environment.variables // {
# my other vars here
NIX_PATH = "/git/hub/nixcfg";
  };
}

But it causes infinite recursion. I imagine there's a special hook
or override pattern for that?
Jeff

On Sat, 4 Jul 2015 18:20:20 -0700
James Cook  wrote:

> On 4 July 2015 at 09:24, Jeffrey David Johnson  wrote:
> > I'm having the same issue described here on the Gentoo forums:
> >
> > https://forums.gentoo.org/viewtopic-t-670013.html
> >
> > Man pages are hard to read because they're full of control characters. For 
> > example:
> >
> > NIXOS-REBUILD(8)  NixOS Reference Pages  
> > NIXOS-REBUILD(8)
> >
> > ESC[1mNAMEESC[0m
> >nixos-rebuild - reconfigure a NixOS machine
> >
> > ESC[1mSYNOPSISESC[0m
> >ESC[1mnixos-rebuild ESC[22m{ESC[1mswitch ESC[22m| ESC[1mboot 
> > ESC[22m| ESC[1mtest
> > ESC[22m| ESC[1mbuild ESC[22m| ESC[1mdry-build ESC[22m| ESC[1mdry-activate 
> > ESC[22m|
> > ...
> >
> > I expect it's a problem with my environment variables, so
> > here's my profile.nix which I import into configuration.nix:
> >
> > with import ;
> >
> > {
> >   programs.bash = {
> > enableCompletion = true;
> > # promptInit = "PS1=\"# \"";
> >   };
> >
> >   # replaces traditional xinitrc
> >   services.xserver.displayManager.sessionCommands = ''
> > export EDITOR=qvim # why no gvim?
> > xsetroot -cursor_name left_ptr &
> > [[ -a ~/.fehbg ]] && eval $(cat ~/.fehbg)
> > unclutter -idle 1 &
> > eval "$(ssh-agent -s)" &
> >   '';
> >
> >   environment.variables = lib.mkForce rec {
> > EDITOR   = "vim" ;
> > TERM = TERMINAL;
> > TERMINAL = "xfce4-terminal";
> >   };
> >
> >   # this gets reset if in environment.variables for some reason
> >   environment.interactiveShellInit = ''
> > export NIX_PATH=/git/hub/nixcfg
> >   '';
> >
> >   # TODO why can't nix-env find things on the regular NIX_PATH?
> >   environment.shellAliases = {
> > "nix-env" = "nix-env -f ${}";
> >   };
> > }
> >
> > As you can see I also have issues setting up NIX_PATH.
> > The current kludgy solution is working OK, but if you know
> > how to clean it up please mention that too! My worry is
> > that I've deleted all the environment variables not
> > mentioned here including some important ones, and man
> > pages are just the first thing I noticed.
> >
> > Thanks
> > Jeff
> 
> The only thing that comes to mind: environment.varibles = lib.mkForce
> ... looks suspicious to me. Does it work without the mkForce?
> 
> (If environment.variables is like other configuration variables I've
> met, then mkForce means discard whatever the defaults are, and leaving
> out mkForce means append the values you specify to whatever the
> defaults are.)
> 
> You could always start commenting out parts of the configuration and
> observing the changes, but of course that's tedious. Maybe using
> nixos-rebuild build-vm could help.
> 
> James
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev