add examples
This commit is contained in:
30
examples/hello_world.nix
Normal file
30
examples/hello_world.nix
Normal 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/"}
|
||||||
|
'';
|
||||||
|
}
|
||||||
38
examples/simple.nix
Normal file
38
examples/simple.nix
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
|
'';
|
||||||
|
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/"}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user