Skip to content

Commit 8277b6c

Browse files
committed
Add docs WIP
1 parent f3b874a commit 8277b6c

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
!.gitignore
44
!flake.lock
55

6+
!*.md
67
!*.nix
78
!*.sh

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright (c) 2024-present RGBCube
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# HTMNIX
2+
3+
Write composeable HTML with Nix!
4+
5+
Here is an example snippet:
6+
7+
```nix
8+
<html>
9+
<head>
10+
<title>"Hello, Internet!"<.title>
11+
<.head>
12+
<body>
13+
<p>"Yep, this is 100% Nix!"<.p>
14+
15+
<img.>{src="/foo.png"; alt="Attributes also work!";}
16+
<.body>
17+
<.html>
18+
```
19+
20+
You might be wondering, _How?_
21+
22+
If you are, go read my [blog post](https://rgbcu.be/blog/htmnix)!
23+
24+
## More Examples
25+
26+
> All of the examples here can be rendered with the following
27+
> command (assuming `html.nix` has the example content):
28+
>
29+
> ```sh
30+
> TARGET_FILE=$(realpath html.nix) nix eval github:RGBCube/HTMNIX#result --raw --impure
31+
> ```
32+
33+
Create a directory listing:
34+
35+
```nix
36+
<ul>
37+
(lib.mapAttrsToList
38+
(name: type: <li>"${name} (${type})"<.li>)
39+
(builtins.readDir ./.))
40+
<.ul>
41+
```
42+
43+
List metadata about a derivation:
44+
45+
```nix
46+
let
47+
pkg = (import <nixpkgs> {}).youtube-dl;
48+
in
49+
50+
<div>{class="package";}
51+
<p>"Name: ${pkg.pname}"<.p>
52+
<details>
53+
<summary>"See metadata"<.summary>
54+
<ul>
55+
<li>"Full name: ${pkg.name}"
56+
<li>"Version: ${pkg.version}"
57+
<li>(let
58+
license = if lib.isList pkg.meta.license then
59+
lib.elemAt pkg.meta.license 0
60+
else
61+
pkg.meta.license;
62+
in "License: ${license.fullName}")
63+
<.ul>
64+
<.details>
65+
<.div>
66+
```
67+
68+
## License
69+
70+
```
71+
MIT License
72+
73+
Copyright (c) 2024-present RGBCube
74+
75+
Permission is hereby granted, free of charge, to any person obtaining a copy
76+
of this software and associated documentation files (the "Software"), to deal
77+
in the Software without restriction, including without limitation the rights
78+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
79+
copies of the Software, and to permit persons to whom the Software is
80+
furnished to do so, subject to the following conditions:
81+
82+
The above copyright notice and this permission notice shall be included in all
83+
copies or substantial portions of the Software.
84+
85+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
89+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
90+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
91+
SOFTWARE.
92+
```

0 commit comments

Comments
 (0)