Skip to content

Commit ab8a12e

Browse files
committed
feat: convert website to hugo with new design
1 parent 77dec50 commit ab8a12e

76 files changed

Lines changed: 4513 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
flake-check:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34, 2025-09-24
19+
with:
20+
nix_conf: |
21+
keep-env-derivations = true
22+
keep-outputs = true
23+
24+
- name: Restore and save Nix store
25+
uses: nix-community/cache-nix-action@106bba72ed8e29c8357661199511ef07790175e9 # v7, 2026-01-08
26+
with:
27+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
28+
restore-prefixes-first-match: nix-${{ runner.os }}-
29+
gc-max-store-size-linux: 1G
30+
purge: true
31+
purge-prefixes: nix-${{ runner.os }}-
32+
purge-created: 0
33+
purge-last-accessed: P1DT12H
34+
purge-primary-key: never
35+
36+
- name: nix flake check
37+
run: nix flake check --print-build-logs

.github/workflows/deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Build the Hugo site with Nix and deploy it to GitHub Pages.
2+
#
3+
# See ../../README.md or terranix.org for the live site.
4+
5+
name: Deploy Hugo site to Pages
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# Allow only one concurrent deployment; do not cancel in-progress runs.
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: false
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v5
31+
32+
- uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34, 2025-09-24
33+
with:
34+
nix_conf: |
35+
keep-env-derivations = true
36+
keep-outputs = true
37+
38+
- name: Restore and save Nix store
39+
uses: nix-community/cache-nix-action@106bba72ed8e29c8357661199511ef07790175e9 # v7, 2026-01-08
40+
with:
41+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
42+
restore-prefixes-first-match: nix-${{ runner.os }}-
43+
gc-max-store-size-linux: 1G
44+
purge: true
45+
purge-prefixes: nix-${{ runner.os }}-
46+
purge-created: 0
47+
purge-last-accessed: P1DT12H
48+
purge-primary-key: never
49+
50+
- name: Build site
51+
run: nix build .#site --out-link result
52+
53+
- name: Stage artifact
54+
# upload-pages-artifact can't follow Nix store symlinks (they point to
55+
# read-only paths with unusual permissions); copy contents out first.
56+
run: cp -rL result public
57+
58+
- uses: actions/upload-pages-artifact@v3
59+
with:
60+
path: ./public
61+
62+
deploy:
63+
environment:
64+
name: github-pages
65+
url: ${{ steps.deployment.outputs.page_url }}
66+
runs-on: ubuntu-latest
67+
needs: build
68+
steps:
69+
- name: Deploy to GitHub Pages
70+
id: deployment
71+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/public/
2+
/result
3+
/result-*
4+
/public-result
5+
.hugo_build.lock
6+
.direnv/

archetypes/default.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
3+
date = {{ .Date }}
4+
draft = false
5+
+++

archetypes/docs.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
+++
2+
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
3+
date = {{ .Date }}
4+
draft = false
5+
weight = 50
6+
aliases = []
7+
+++

archetypes/news.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
+++
2+
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
3+
date = {{ .Date }}
4+
draft = false
5+
tags = []
6+
summary = ''
7+
aliases = []
8+
+++

content/_index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
+++
2+
title = 'terranix'
3+
+++
4+
5+
{{< hero
6+
title="infrastructure as nix code"
7+
lead="terranix is a Nix-based infrastructure-as-code tool that combines the providers of <a href=\"https://www.terraform.io/\">Terraform</a> (or <a href=\"https://opentofu.org/\">OpenTofu</a>) and the lazy, functional configuration of <a href=\"https://nixos.org/\">NixOS</a>. terranix works as an alternative to <a href=\"https://github.com/hashicorp/hcl\">HCL</a> by generating <a href=\"https://developer.hashicorp.com/terraform/language/syntax/json\">Terraform JSON</a> that can then be applied using the same providers."
8+
ctaPrimary="Getting started|/docs/getting-started/"
9+
ctaSecondary="View on GitHub|https://github.com/terranix/terranix" >}}
10+
11+
{{< codetabs >}}
12+
13+
{{< features >}}
14+
{{< feature title="Full Nix language" >}}Use let-bindings, imports, conditionals, and module composition with the same language you already use for NixOS.{{< /feature >}}
15+
{{< feature title="NixOS module system" >}}Type-checked configuration with sensible defaults, overrides, and reusable modules.{{< /feature >}}
16+
{{< feature title="nixpkgs ecosystem" >}}Tap into `fetchgit`, `fetchurl`, `writers`, and pin Terraform / OpenTofu versions and providers reproducibly.{{< /feature >}}
17+
{{< feature title="Documentation generator" >}}Generate JSON or man-page documentation straight from your `config.nix` module options.{{< /feature >}}
18+
{{< /features >}}

content/docs/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
+++
2+
title = 'Documentation'
3+
date = '2026-05-30'
4+
draft = false
5+
weight = 10
6+
+++
7+
8+
Guides, references, and examples for using terranix to write Terraform / OpenTofu configuration in the Nix language.

content/docs/functions/_index.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
+++
2+
title = 'Functions'
3+
date = '2026-05-30'
4+
draft = false
5+
weight = 30
6+
aliases = ['/functions.html', '/documentation/functions.html']
7+
+++
8+
9+
> some Functions which are useful. They are all documented at the [NixOS Website](https://nixos.org/manual/nixpkgs/stable/)
10+
11+
## optionalAttrs
12+
13+
Useful to create a resource depending on a condition.
14+
The following example adds a bastion host only if
15+
the variable `bastionHostEnable` is set to true.
16+
17+
This is just an example for illustration, such things
18+
are better solved using
19+
[modules](/docs/modules/).
20+
21+
```nix
22+
{ lib, ... }:
23+
let
24+
bastionHostEnable = true;
25+
in
26+
{
27+
resource.aws_instance = lib.optionalAttrs bastionHostEnable {
28+
"bastion" = {
29+
ami = "ami-969ab1f6";
30+
instance_type = "t2.micro";
31+
associate_public_ip_address = true;
32+
};
33+
};
34+
}
35+
```
36+
37+
## mapping and zipping
38+
39+
Useful to create multiple resources, contains a lot of similar data,
40+
out of a small set of information that differ.
41+
42+
- `map`
43+
: map a list to another list.
44+
- `zipAttrs`
45+
: Merge sets of attributes and combine each attribute value in to a list.
46+
47+
The following Example shows how to create 3 S3-buckets with similar configuration.
48+
49+
```nix
50+
{ lib, ... }:
51+
let
52+
s3Buckets = [
53+
{ name = "awesome-com"; domain = "awesome.com"; }
54+
{ name = "awesome-org"; domain = "awesome.org"; }
55+
{ name = "awesome-live"; domain = "awesome.live"; }
56+
];
57+
createBucket = { name, domain }:
58+
{
59+
"${name}" = {
60+
bucket = name;
61+
acl = "public-read";
62+
63+
cors_rule = {
64+
allowed_headers = ["*"];
65+
allowed_methods = ["PUT" "POST" "GET"];
66+
allowed_origins = [ "https://${domain}" ];
67+
expose_headers = ["ETag"];
68+
max_age_seconds = 3000;
69+
};
70+
};
71+
};
72+
in
73+
{
74+
resource.aws_s3_bucket = lib.zipAttrs (lib.map createBucket s3Buckets);
75+
}
76+
```
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
+++
2+
title = 'evalTerranixConfiguration'
3+
date = '2026-05-30'
4+
draft = false
5+
weight = 20
6+
aliases = ['/eval-terranix-configuration.html']
7+
+++
8+
9+
`lib.evalTerranixConfiguration` evaluates terranix modules and returns
10+
the Terraform configuration as a Nix attrset, without writing anything
11+
to the Nix store.
12+
13+
```nix
14+
terranix.lib.evalTerranixConfiguration {
15+
system = "x86_64-linux"; # or set pkgs directly
16+
modules = [ ./config.nix ];
17+
extraArgs = { }; # extra arguments passed to modules
18+
strip_nulls = true; # remove null values from the output
19+
}
20+
```
21+
22+
The return value is an attrset containing `config`, like so:
23+
24+
```nix
25+
{
26+
config = {
27+
resource = { ... };
28+
provider = { ... };
29+
# ...
30+
};
31+
}
32+
```
33+
34+
## Exploring in nix repl
35+
36+
The primary use case is inspecting your Terraform configuration interactively.
37+
38+
For example, with `nix repl` you can produce a terranix configuration like so:
39+
40+
```
41+
$ nix repl
42+
nix-repl> terranix = builtins.getFlake "github:terranix/terranix"
43+
44+
nix-repl> result = terranix.lib.evalTerranixConfiguration {
45+
system = "x86_64-linux";
46+
modules = [{
47+
resource.local_file.example = {
48+
content = "hello";
49+
filename = "./example.txt";
50+
};
51+
}];
52+
}
53+
54+
nix-repl> result.config.resource.local_file.example
55+
{ content = "hello"; filename = "./example.txt"; }
56+
```
57+
58+
You can also load modules from files:
59+
60+
```
61+
nix-repl> result = terranix.lib.evalTerranixConfiguration {
62+
system = "x86_64-linux";
63+
modules = [ ./config.nix ];
64+
}
65+
66+
nix-repl> builtins.attrNames result.config
67+
[ "provider" "resource" ]
68+
```
69+
70+
## Accessing config from `terranixConfiguration`
71+
72+
`lib.terranixConfiguration` produces a `config.tf.json` store derivation.
73+
It now also carries the evaluated configuration as a passthru attribute,
74+
so you can access the attrset without a separate call:
75+
76+
```nix
77+
let
78+
tfConfig = terranix.lib.terranixConfiguration {
79+
inherit system;
80+
modules = [ ./config.nix ];
81+
};
82+
in
83+
{
84+
# tfConfig is the config.tf.json derivation
85+
# tfConfig.config is the Terraform attrset
86+
inherit (tfConfig) config;
87+
}
88+
```
89+
90+
This is convenient when your flake already uses `terranixConfiguration`
91+
and you want to inspect or reuse the configuration in other Nix expressions.
92+
93+
## Migrating from terranixConfigurationAst
94+
95+
`lib.terranixConfigurationAst` is deprecated. Replace calls with `lib.evalTerranixConfiguration`:
96+
97+
```nix
98+
# Old
99+
terranix.lib.terranixConfigurationAst { system = "x86_64-linux"; modules = [ ./config.nix ]; }
100+
101+
# New
102+
terranix.lib.evalTerranixConfiguration { system = "x86_64-linux"; modules = [ ./config.nix ]; }
103+
```
104+
105+
The return value is the same: `{ config = { ... }; }`.

0 commit comments

Comments
 (0)