lix/scripts
Eelco Dolstra a957893b26 Allow nix-shell to be used as a #! interpreter
This allows scripts to fetch their own dependencies via nix-shell. For
instance, here is a Haskell script that, when executed, pulls in GHC
and the HTTP package:

  #! /usr/bin/env nix-shell
  #! nix-shell -i runghc -p haskellPackages.ghc haskellPackages.HTTP

  import Network.HTTP

  main = do
    resp <- Network.HTTP.simpleHTTP (getRequest "http://nixos.org/")
    body <- getResponseBody resp
    print (take 100 body)

Or a Perl script that pulls in Perl and some CPAN packages:

  #! /usr/bin/env nix-shell
  #! nix-shell -i perl -p perl perlPackages.HTMLTokeParserSimple perlPackages.LWP

  use HTML::TokeParser::Simple;

  my $p = HTML::TokeParser::Simple->new(url => 'http://nixos.org/');

  while (my $token = $p->get_tag("a")) {
      my $href = $token->get_attr("href");
      print "$href\n" if $href;
  }

Note that the options to nix-shell must be given on a separate line
that starts with the magic string ‘#! nix-shell’. This is because
‘env’ does not allow passing arguments to an interpreter directly.
2015-01-08 14:32:45 +01:00
..
build-remote.pl.in build-remote.pl.in: Add some more trace messages 2014-11-12 13:56:01 +01:00
copy-from-other-stores.pl.in Use proper quotes everywhere 2014-08-20 18:03:48 +02:00
download-from-binary-cache.pl.in Doh 2014-12-09 20:43:12 +01:00
download-using-manifests.pl.in Shut up "Wide character" warnings in Perl scripts 2014-08-29 17:48:25 +02:00
find-runtime-roots.pl.in Revert "Scan /proc/<pid>/cmdline for GC roots" 2013-12-20 14:18:24 +01:00
install-nix-from-closure.sh Install cacert before running nix-channel 2014-12-13 16:53:21 +01:00
local.mk Fix "make dist" 2014-02-01 14:38:12 +01:00
nix-build.in Allow nix-shell to be used as a #! interpreter 2015-01-08 14:32:45 +01:00
nix-channel.in nix-channel: Add --rollback flag 2014-10-14 12:08:04 +02:00
nix-collect-garbage.in nix-collect-garbage: Add --delete-older-than option 2014-03-30 00:54:16 +01:00
nix-copy-closure.in Fix nix-copy-closure --from 2014-10-15 15:05:13 -04:00
nix-generate-patches.in Use $XDG_RUNTIME_DIR for temporary files 2014-08-13 23:12:57 +02:00
nix-http-export.cgi.in Replace wrong (w.r.t. PATH) sed call with in-shell substitution 2009-02-19 20:46:45 +00:00
nix-install-package.in Pass through --set from nix-install-package command line to nix-env 2014-09-23 15:11:24 +02:00
nix-prefetch-url.in Shut up "Wide character" warnings in Perl scripts 2014-08-29 17:48:25 +02:00
nix-profile.sh.in Always use https to fetch the Nixpkgs channel 2014-12-10 11:35:56 +01:00
nix-pull.in Shut up "Wide character" warnings in Perl scripts 2014-08-29 17:48:25 +02:00
nix-push.in Shut up "Wide character" warnings in Perl scripts 2014-08-29 17:48:25 +02:00
nix-reduce-build.in Add support for ‘make installcheck’ 2013-11-25 18:47:03 +01:00
show-duplication.pl * `show-duplication.pl', a small utility that shows the amount of 2006-09-19 13:53:35 +00:00