add examples

This commit is contained in:
lassulus
2018-09-11 20:07:04 +02:00
parent f765bef6be
commit 368a04fec3
2 changed files with 68 additions and 0 deletions

30
examples/hello_world.nix Normal file
View File

@@ -0,0 +1,30 @@
let
pkgs = import <nixpkgs> { overlays = [ (import ../pkgs) ]; };
in {
bash = pkgs.writeBash "hello-world" ''
echo 'hello world'
'';
c = pkgs.writeC "hello-world" {} ''
#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}
'';
dash = pkgs.writeDash "hello-world" ''
echo 'hello world'
'';
haskell = pkgs.writeHaskell "hello-world" [] ''
main = do
putStrLn "hello world"
'';
python2 = pkgs.writePython2 "hello-world" {} ''
print "hello world"
'';
python3 = pkgs.writePython3 "hello-world" {} ''
print("hello world")
'';
sed = pkgs.writeDash "sed-example" ''
echo xxx | ${pkgs.writeSed "hello-world" "s/xxx/hello world/"}
'';
}