aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple.nix
blob: ad62b84b660f76829728cb58b3aa006196fa9a01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
let
  pkgs = import <nixpkgs> { overlays = [ (import ../pkgs) ]; };
in {
  bash = pkgs.writeBash "hello-world" ''
   if [[ "test" == "test" ]]; then echo "bash features"; fi
  '';
  # cc -L/nix/store/...blah/lib -I/nix/store/...blah/include
  dash = pkgs.writeDash "hello-world" ''
   test '~' = '~' && echo 'dash features'
  '';
  haskell = pkgs.writeHaskell "hello-world" [ "acme-cuteboy" ] ''
    import Acme.CuteBoy

    main :: IO ()
    main = print Rolf
  '';
  perl = pkgs.writePerl "simple.pl" { deps = [ pkgs.perlPackages.boolean ]; } ''
    use boolean;
    print "Howdy!\n" if true;
  '';
  python2 = pkgs.writePython2 "hello-world" { deps = [ pkgs.python2Packages.pyyaml ]; } ''
    import yaml

    print yaml.load("""
      - some
      - random
      - variables
    """)
  '';
  python3 = pkgs.writePython3 "hello-world" { deps = [ pkgs.python3Packages.pyyaml ]; } ''
    import yaml

    print(yaml.load("""
      - some
      - random
      - variables
    """))
  '';
  sed = pkgs.writeDash "sed-example" ''
    echo hello | ${pkgs.writeSed "hello-world" "s/hello/& world/"}
  '';
}