Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions source/_ext/contributors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from dataclasses import dataclass
from pathlib import Path

import docutils.nodes as nodes
from docutils.parsers.rst import directives
from sphinx.application import Sphinx
from sphinx.util.docutils import SphinxDirective
import yaml


@dataclass
class Contributor:
github: str
name: str | None = None

@classmethod
def from_dict(cls, handle, data):
if not data:
# a contributor may be only known by handle and nothing else
data = {}
return cls(github=handle, name=data.get("name"))

def as_reference(self) -> list[nodes.Node]:
ref = nodes.reference(
"", f"@{self.github}", refuri=f"https://github.com/{self.github}"
)
if self.name:
return [nodes.Text(f"{self.name} "), ref]
return [ref]


# FIXME(@fricklerhandwerk): Get up-to-date contributor information from Nixpkgs' `maintainers.nix`
with open(Path(__file__).parent.parent / "contributors.yaml") as f:
_registry = {
handle: Contributor.from_dict(handle, data)
for handle, data in (yaml.safe_load(f) or {}).items()
}


def resolve(handles: list[str]) -> list[Contributor]:
result = []
for handle in handles:
if handle not in _registry:
raise ValueError(f"unknown contributor '{handle}'")
result.append(_registry[handle])
return result


def contributors_field(label: str, people: list[Contributor]) -> nodes.field:
para = nodes.paragraph()
first, *rest = [p.as_reference() for p in people]
para += first
for ref in rest:
para += nodes.Text(", ")
para += ref
return nodes.field("", nodes.field_name("", label), nodes.field_body("", para))


class ContributorsDirective(SphinxDirective):
option_spec = {
"authors": directives.unchanged,
"editors": directives.unchanged,
}

def run(self) -> list[nodes.Node]:
field_list = nodes.field_list(classes=["contributors"])
for option, label in [("authors", "Author"), ("editors", "Editor")]:
raw = self.options.get(option, "")
handles = [h.strip() for h in raw.split(",") if h.strip()]
people = resolve(handles)
if len(people) > 1:
label += "s"
if people:
field_list += contributors_field(label, people)
return [field_list] if field_list.children else []


def setup(app: Sphinx) -> dict:
app.add_directive("contributors", ContributorsDirective)
return {}
8 changes: 8 additions & 0 deletions source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ html[data-theme="dark"] .highlight .gd {
html[data-theme="dark"] iframe[title="GitHub"] {
filter: invert(0.93) hue-rotate(100deg);
}

.contributors {
color: var(--pst-color-text-muted);
background: var(--pst-color-surface);
border-color: var(--pst-color-info);
border-radius: 0.25rem;
padding: 0.5rem;
}
4 changes: 4 additions & 0 deletions source/concepts/flakes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(flakes-definition)=
# Flakes

```{contributors}
:authors: kiara
```

## What are flakes?

Flakes offer an entrypoint file `flake.nix` aimed at sharing Nix code.
Expand Down
1 change: 1 addition & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"sphinx_copybutton",
"sphinx_design",
"extractable_code_block",
"contributors",
"sphinx_sitemap",
"notfound.extension",
]
Expand Down
26 changes: 26 additions & 0 deletions source/contributors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
djacu:
name: Daniel Baker
domenkozar:
name: Domen Kožar
fricklerhandwerk:
name: Valentin Gagarin
grahamc:
name: Graham Christensen
infinisil:
name: Silvan Mosberger
kiara:
name: Kiara Grouwstra
github: KiaraGrouwstra
mmesch:
name: Matthias Meschede
NobbZ:
name: Norbert Melzer
olafklingt:
proofconstruction:
name: Alexander Groleau
rapenne-s:
name: Solène Rapenne
tfc:
name: Jacek Galowicz
zmitchell:
name: Zach Mitchell
5 changes: 5 additions & 0 deletions source/guides/best-practices.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Best practices

```{contributors}
:authors: domenkozar
:editors: fricklerhandwerk, infinisil
```

## URLs

The Nix language syntax supports bare URLs, so one could write `https://example.com` instead of `"https://example.com"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ myst:

# Continuous integration with GitHub Actions

```{contributors}
:authors: domenkozar
```

Set up [GitHub Actions](https://github.com/features/actions) as your continuous integration (CI) workflow for commits and pull requests.

Nix lets CI build and cache developer environments for every project on every branch using binary caches.
Expand Down
4 changes: 4 additions & 0 deletions source/guides/recipes/post-build-hook.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(post-build-hooks)=
# Setting up post-build hooks

```{contributors}
:authors: grahamc
```

This guide shows how to use the Nix [`post-build-hook`](https://nix.dev/manual/nix/2.22/command-ref/conf-file#conf-post-build-hook) configuration option to automatically upload build results to an [S3-compatible binary cache](https://nix.dev/manual/nix/2.22/store/types/s3-binary-cache-store).

## Implementation caveats
Expand Down
9 changes: 5 additions & 4 deletions source/tutorials/callpackage.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
---
date: 2022-09-08
authors:
- Norbert Melzer
- Valentin Gagarin
- Matthias Meschede
myst:
html_meta:
"keywords": "tutorial, callPackage, override, package, customise, parameters, nix, nixpkgs"
Expand All @@ -12,6 +8,11 @@ myst:
(callpackage-tutorial)=
# Package parameters and overrides with `callPackage`

```{contributors}
:authors: NobbZ
:editors: mmesch, fricklerhandwerk
```

Nix ships with a special-purpose programming language for creating packages and configurations: the Nix language.
It is used to build the Nix package collection, known as {term}`Nixpkgs`.

Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/first-steps/ad-hoc-shell-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Ad hoc shell environments

```{contributors}
:authors: domenkozar
:editors: fricklerhandwerk
```

In a Nix shell environment, you can immediately use any program packaged with Nix, without installing it permanently.

You can also share the command invoking such a shell with others, and it will work on all Linux distributions, WSL, and macOS[^1].
Expand Down
4 changes: 4 additions & 0 deletions source/tutorials/first-steps/declarative-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ myst:
(declarative-reproducible-envs)=
# Declarative shell environments with `shell.nix`

```{contributors}
:authors: domenkozar, zmitchell
:editors: fricklerhandwerk
```
## Overview

Declarative shell environments allow you to:
Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/first-steps/reproducible-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Reproducible interpreted scripts

```{contributors}
:authors: rapenne-s
:editors: fricklerhandwerk
```

In this tutorial, you will learn how to use Nix to create and run reproducible interpreted scripts, also known as [shebang] scripts.

## Requirements
Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/module-system/a-basic-module/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# A basic module

```{contributors}
:authors: djacu
:editors: fricklerhandwerk
```

What is a module?

* A module is a function that takes an attribute set and returns an attribute set.
Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/module-system/deep-dive.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

Or: *Wrapping the world in modules*

```{contributors}
:authors: infinisil
:editors: fricklerhandwerk, proofconstruction
```

In this tutorial you will follow an extensive demonstration of how to wrap an existing API with Nix modules.

## Overview
Expand Down
6 changes: 6 additions & 0 deletions source/tutorials/nix-language.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
(reading-nix-language)=


# Nix language basics

```{contributors}
:authors: fricklerhandwerk
:editors: infinisil
```

The Nix language is designed for conveniently creating and composing *derivations* – precise descriptions of how contents of existing files are used to derive new files.
It is a domain-specific, purely functional, lazily evaluated, dynamically typed programming language.

Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/nixos/binary-cache-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ myst:
(setup-http-binary-cache)=
# Setting up an HTTP binary cache

```{contributors}
:authors: tfc
:editors: fricklerhandwerk
```

A binary cache stores pre-built [Nix store objects](https://nix.dev/manual/nix/latest/store/store-object) and provides them to other machines over the network.
Any machine with a Nix store can be a binary cache for other machines.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ myst:
(nixos-docker-images)=
# Building and running Docker images

```{contributors}
:authors: domenkozar
```

[Docker](https://www.docker.com/) is a set of tools and services used to build, manage and deploy containers.

Many cloud platforms offer Docker-based container hosting.
Expand Down
4 changes: 4 additions & 0 deletions source/tutorials/nixos/building-bootable-iso-image.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(bootable-iso-image)=
# Building a bootable ISO image

```{contributors}
:authors: domenkozar
```

:::{note}
If you need to build images for a different platform, see [Cross compiling](https://github.com/nix-community/nixos-generators#user-content-cross-compiling).
:::
Expand Down
3 changes: 3 additions & 0 deletions source/tutorials/nixos/deploying-nixos-using-terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ myst:
(deploy-nixos-using-terraform)=
# Deploying NixOS using Terraform

```{contributors}
:authors: domenkozar
```
This tutorial assumes you're [familiar with the basics of Terraform](https://www.terraform.io/intro/index.html).
By the end, you will have provisioned an Amazon Web Services (AWS) instance with Terraform and used Nix to deploy incremental changes to NixOS running on the instance.

Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/nixos/distributed-builds-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ myst:
(distributed-build-setup-tutorial)=
# Setting up distributed builds

```{contributors}
:authors: tfc
:editors: fricklerhandwerk
```

Nix can speed up builds by spreading the work across multiple computers at once.

## Introduction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ myst:

# Installing NixOS on a Raspberry Pi

```{contributors}
:authors: domenkozar
:editors: proofconstruction
```

This tutorial assumes you have a [Raspberry Pi 4 Model B with 4GB RAM](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/).

Before starting this tutorial, make sure you have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Integration testing with NixOS virtual machines

```{contributors}
:authors: olafklingt, domenkozar
:editors: fricklerhandwerk
```

## What will you learn?

This tutorial introduces Nixpkgs functionality for testing NixOS configurations.
Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/nixos/nixos-configuration-on-vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# NixOS virtual machines

```{contributors}
:authors: olafklingt, domenkozar
:editors: fricklerhandwerk
```

One of the most important features of NixOS is the ability to configure the entire system declaratively, including packages to be installed, services to be run, as well as other settings and options.

NixOS configurations can be used to test and use NixOS using a virtual machine, which is a lighter weight option compared to a full "bare metal" installation.
Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/nixos/provisioning-remote-machines.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ myst:
(provisioning-remote-machines-tutorial)=
# Provisioning remote machines via SSH

```{contributors}
:authors: tfc
:editors: fricklerhandwerk
```

It is possible to replace any Linux installation with a NixOS configuration on running systems using [`nixos-anywhere`] and [`disko`].

[`nixos-anywhere`]: https://nix-community.github.io/nixos-anywhere/
Expand Down
5 changes: 5 additions & 0 deletions source/tutorials/packaging-existing-software.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ myst:
(packaging-tutorial)=
# Packaging existing software with Nix

```{contributors}
:authors: proofconstruction
:editors: fricklerhandwerk
```

One of Nix's primary use-cases is in addressing common difficulties encountered with packaging software, such as specifying and obtaining dependencies.

In the long term, Nix alleviates such problems.
Expand Down
4 changes: 4 additions & 0 deletions source/tutorials/working-with-local-files.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(file-sets-tutorial)=
# Working with local files

```{contributors}
:authors: infinisil
```

To build a local project in a Nix derivation, source files must be accessible to its [`builder` executable](https://nix.dev/manual/nix/stable/language/derivations#attr-builder).
By default, the `builder` runs in an [isolated environment](https://nix.dev/manual/nix/stable/command-ref/conf-file.html#conf-sandbox) that only allows reading from the Nix store.
The Nix language has built-in features to copy local files to the store and expose the resulting store paths.
Expand Down
Loading