[Nix-dev] my recent work: ruby, mercurial, zsh support & more

Marc Weber marco-oweber at gmx.de
Mon Feb 21 21:47:30 CET 2011


Hi community,

You can find my recent work here:
http://mawercer.de:7000 (git instaweb)

I'm still evaluating gitorious to find out whether its the hosting
service I'd like to use for the future. I'm not sure I like the hierarchy that 
you have to create projects containing branches.

So I'll delay talking about that.

For some changes you need a patched nix allowing arbitrary strings in
attr names. The nix expressions in the nixpkgs repo have the patch
applied.

Pick whatever you like.

You've seen much of this in patches I've send to the mailinglist earlier.

The .topmsg files of the branches contain more details about the changes.

Now that ruby support is done I'll also focus on Python support (pypi) again.

Enjoy
Marc Weber


TOPICS:

= overlay support:
==================
  reference repositories beneath nixpkgs so that you can put
  huge amounts of stuff only a minority is interested in into separate packages.

  Example:
  overlay haskell (based on hack-nix). For whatever reason nobody is interested
  in it altough I think it gets the job done pretty well


= RUBY support
==============
  overlays (gitorious)
  --------------------
  1.9 (trunk because older versions ship with an too old version of rubygems eg
  for hoe)

  nixpgks-ruby-overlay
    - spec patches + simple solver
    - ruby .nix code providing ruby environments, see below

  nixpgks-ruby-overlay-specs
    100.000 spec dumped by a gem patch - yielding 20.000 files
    Yuri: thanks for showing me how to write external ruby gem plugins

    Eg the first rails example can be run.

    Yes - importang all specs is crazy - it took more than a day to fetch all
    hashes. Hoever when I need a library I don't want to start waiting for
    something. So for now I'm done.
    I may setup a cronjob updating the dump occasionally

  ruby environments
  -----------------
  can be defined in this way finding their deps automatically and failing
  if two different specs require different versions of the same package.
  You can filter the package pool to resolve this issue, see
  example definition for a rails env [1]. The result is a shell script
  setting PATH, RUBYLIB and GEM_PATH. Example usage:
    
  ruby-env-rails bash # start a new shell with ruby and ruby libs in env
  Optionally tag all libraries so that you can lookup symbols fast (TAG_FILES
  will be exported the same way it was done for hack-nix)

  However to make this work I had to patch /etc/bashrc (-> multi shell patch)

  attention
  ---------
  my nixpkgs patches also remove the current ruby-libraries provided by nixpkgs
  favoring the overlay which you may think means adding more bloat than value ..

= multi shell patch
===================
  I love zsh and I wanted a way to add some unobstrusive shell code to all
  accounts easily. So I refactored /etc/bashrc and /etc/skel/* files.
  
  The result is:
  - /etc/* files only define PATH because without that nothing works on nixos.
  - some unobstrusive opt-outable bash completion support (eg upstart)
  - In zsh the nix PATHs are defined properly
  - nixos options:

    * supportedShells 
      enable zsh support by setting it to [ "bash" "zsh" ] 

    * interactiveShellInit
      code to sourced by ~/.bashrc ~/.bash_profile  for interactive shells
      So I moved some code from /etc/bashrc to user files because /etc/*
      files can't be changed by users so they should contain a bare minimum
      only

    * shellInit
      always sourced. Keep it to a minimum. Should define essential env vars only
    
  You can assemble shell code snippets this way now:

  [ "# some code "
    { bash = "# bash only code"; 
      zsh = "# zsh oly code";
    }
    "# some more shared code
  ]

  Maybe this is overkill - but it should scale well.

  also adding 
  /etc/skel/.nixpgks/config.nix # demo file
  /etc/skel/.vimrc (comment only to make vi startup as vim nocomp)

= mercurial update & plugin support
===================================
  put in your config.nix and be happy:

  mercurial = {
    atticSupport = true;
    guiSupport = true;
    pbranchSupport = true;
    hgsubversionSupport = true;
    mqSupport = true;
    histeditSupport = true;
    hgextconvertSupport = true;
    collapseSupport = true;
    record = true;
  };

= nixos postfix update 2.8.x
============================
  - version bump because current version is (very?) outdated
  - fixed "restart postfix"
  - added some map abstraction so that you can setup virtual accounts easily
  details see .topmsg

= misc
=================================
  various smaller fixes or updates including:

  adding:
    umtsmon
    smlnj
    tinyproxy
    ziproxy
    fish shell
    linuxtv_dvb_apps

  fixing / updating
    bash upstart completion
    nvi
    buildenv.pl: fix some cases viric discovered
    wvdial
    opera (add support for gtk/ qt, ..)
    builderDefs: add parallel building support
    sourceAndTags: ruby support
    texLive: remove man. It was broken anyway and it shadowed the man command you
             want to use

  adding many parallel building for many packages

  shadow useradd patch causing it to dereference /etc/skel/* symlinks so that
  ~/.bashrc is a file instead of a symlink

  And of course some patches I prefer - eg having only one php derivation for
  both: PHP-5.2 and PHP-5.3

  NixOS:
  * enhance php xdebug support
  * add ids.nix merge function failing if two attr names are set to the same
    uid / gid



[1] Example definition of a environment providing essential packages for
    running some simple rails apps:

    # example usage of a ruby environment you can load easily
    railsEnv = rubyEnv19 {
        name = "rails";
        p = {
          # filters (force specific version)
          # bundler= [["~>" "1.1.2" ]];

          rails  = [["="  "3.0.3" ]]; # rake requires exactly this version ?
          activesupport = [[ "=" "3.0.3" ]];
          builder = [[ "=" "2.1.2" ]];
        };
        
        # lit of specs to be included in environment
        names = [
          "rake" "rails" 
          "bundler"
          "builder"
          "haml"

          # comomnly used databases
          "sqlite3-ruby"

          # tool
          "haml"
          "sinatra"
        ];
    };



More information about the nix-dev mailing list