Skip to content

Commit

Permalink
Doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy committed Aug 26, 2016
1 parent 6cf5bb2 commit 67c8189
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ The `nix::PrimOpFun` API is not necessarily stable from version to version of
`nix`. As such, scripts should inspect `builtins.nixVersion` to ensure that
loaded dynamic objects are compatible.

Example
Examples
-------

This prints out the arguments passed to it, one per line:
Expand Down Expand Up @@ -191,5 +191,30 @@ This prints out the arguments passed to it, one per line:
in printArgs args
```

Sketch of what `nix-exec`-based `nixops` might look like:

```nix
#!/usr/bin/env nix-exec
{ args, lib }: let
nixops-src = lib.builtins.fetchgit { url = git://github.com/NixOS/nix-exec.git; rev = "v3.0.4"; };
nixops-import = lib.join (lib.map (src: import src lib) nixops-src);
in lib.join (lib.map (nixops: let
lib = nixops.lib.nix-exec;
processed = nixops.process-args args;
info = lib.bind processed (args: nixops.query-db args.uuid);
drv = info: nixops.eval-network info.expr info.args info.nix-path;
build = info: drv: lib.mapM (host: nixops.build-remote drv.${host} host) info.hosts;
activate = info: drv: lib.mapM (host: nixops.activate drv.${host} host) info.hosts;
in lib.bind info (info: lib.bind (drv info) (drv: lib.bind (build info drv) (results:
if lib.all-success results then lib.bind (activate info drv) (results: if lib.all-success results then nixops.exit 0 else nixops.exit 1) else nixops.exit 1
)))) nixops-import)
```

[1]: http://en.wikipedia.org/wiki/Monad_(functional_programming)
[2]: http://en.wikipedia.org/wiki/Monad_(functional_programming)#fmap_and_join

0 comments on commit 67c8189

Please sign in to comment.