Below is some conix code for generating a readme file1 as HTML and Markdown files.
(import <nixpkgs> { overlays = import (builtins.fetchGit
{ ref = "master"; rev = "3d63e3087f69b379be0cd5efbf56c28c7bf79b69"; url = "https://github.com/theNerd247/conix.git"; });
}).conix.run(conix: with conix;
markdown "readme" (html "readme" ''
# My Readme
This is a readme file!
''))
Here’s the break down.
The first bit:
(import <nixpkgs> { overlays = import (builtins.fetchGit
{ ref = "master"; rev = "3d63e3087f69b379be0cd5efbf56c28c7bf79b69"; url = "https://github.com/theNerd247/conix.git"; });
})
is normal nix code. It fetches a commit of the conix library from a git repo and imports the library as an overlay.
The next bit:
.conix.run
runs the conix content and returns a derivation containing the rendered files (in this case an html and markdown file).
Finally, the conix content:
markdown "readme" (html "readme" ''
# My Readme
This is a readme file!
''))
The first line is a function that creates a markdown file called “readme”. The text in this readme file is produced by the argument content. In this example, the argument content to markdown
is an expression that creates an HTML file called “readme”. The last argument to the readme file is a string of markdown code. Here’s the build pipeline:
From The Conix Language Reference, the function syntax:
Brings
data
,refs
, and the conix library into <content>’s scope.
Download Getting Started Sample Code↩︎