citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

nix-eval (664B)


      1 #/usr/bin/env bash
      2 
      3 usage () {
      4   echo "nix-eval [--nixpkgs|-n] <expr>"
      5   echo ""
      6   echo "  examples"
      7   echo ""
      8   echo "    \$ nix-eval '1+1'"
      9   echo "    2"
     10   echo ""
     11   echo "    \$ nix-eval -n '\"\${pkgs.xlibs.xset}\"'"
     12   echo "    \"/nix/store/6n5f894ndps4rnrvdx8z95sw4pmd1989-xset-1.2.3\""
     13   echo ""
     14   exit 1
     15 }
     16 
     17 prelude=""
     18 
     19 [ "$#" -eq 0 ] && usage
     20 
     21 while [ "$#" -gt 1 ]; do
     22     i="$1"; shift 1
     23     case "$i" in
     24       --help)
     25         usage
     26         ;;
     27       --nixpkgs|-n)
     28         prelude="with import <nixpkgs> {}; "
     29         ;;
     30       *)
     31         echo "$0: unknown option \`$i'"
     32         exit 1
     33         ;;
     34     esac
     35 done
     36 
     37 nix-instantiate --eval --expr "${prelude}$@"