Skip to content

Commit 7955d03

Browse files
committed
New "Flakes" chapter
This also includes two other changes: - Upgrade the Nix / Nixpkgs version - Lock the flake files Unfortunately it will be a bit tricky to decouple those changes so I'm bundling them together.
1 parent d323ca8 commit 7955d03

23 files changed

+1449
-56
lines changed

manuscript/AdvancedModules.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ I will make use of this trick in a few examples below, so that we can simulate m
3636

3737
## `lib` utilities
3838

39-
Nixpkgs provides several utility functions for NixOS modules that are stored underneath the "`lib`" hierarchy, and you can find the source code for those functions in [`lib/modules.nix`](https://github.com/NixOS/nixpkgs/blob/22.05/lib/modules.nix).
39+
Nixpkgs provides several utility functions for NixOS modules that are stored underneath the "`lib`" hierarchy, and you can find the source code for those functions in [`lib/modules.nix`](https://github.com/NixOS/nixpkgs/blob/23.11/lib/modules.nix).
4040

4141
{blurb, class: information}
4242
If you want to become a NixOS module system expert, take the time to read and understand all of the code in `lib/modules.nix`.
@@ -318,7 +318,7 @@ error: The option `systemd.services.nginx.serviceConfig.RestartSec' has conflict
318318
(use '--show-trace' to show detailed location information)
319319
```
320320

321-
The problem is that when we enable `nginx` that automatically defines a whole bunch of other NixOS options, [including `systemd.services.nginx.serviceConfig.RestartSec`](https://github.com/NixOS/nixpkgs/blob/nixos-22.05/nixos/modules/services/web-servers/nginx/default.nix#L890). This option is a scalar string option that disallows multiple distinct values because the NixOS module system by default has no way to known which one to pick to resolve the conflict.
321+
The problem is that when we enable `nginx` that automatically defines a whole bunch of other NixOS options, [including `systemd.services.nginx.serviceConfig.RestartSec`](https://github.com/NixOS/nixpkgs/blob/23.11/nixos/modules/services/web-servers/nginx/default.nix#L1234). This option is a scalar string option that disallows multiple distinct values because the NixOS module system by default has no way to known which one to pick to resolve the conflict.
322322

323323
However, we can use `mkOverride` to annotate our value with a higher priority so that it overrides the other conflicting definition:
324324

@@ -472,7 +472,7 @@ If you launch the above NixOS configuration you should be able to verify that th
472472
[root@nixos:~]# systemctl status cowsay
473473
○ cowsay.service
474474
Loaded: loaded (/etc/systemd/system/cowsay.service; enabled; preset: enabl>
475-
Active: inactive (dead) since Sat 2022-11-05 20:11:05 UTC; 43s ago
475+
Active: inactive (dead) since Sat 2023-11-05 20:11:05 UTC; 43s ago
476476
Duration: 106ms
477477
Process: 683 ExecStart=/nix/store/v02wsh00gi1vcblpcl8p103qhlpkaifb-unit-scr>
478478
Main PID: 683 (code=exited, status=0/SUCCESS)

manuscript/Book.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Modules.md
77
AdvancedModules.md
88
Terraform.md
99
ContinuousIntegrationDeployment.md
10+
Flakes.md

manuscript/ContinuousIntegrationDeployment.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ You can use `nix repl` to explore flake outputs by running:
131131

132132
```bash
133133
$ nix repl .#
134-
Welcome to Nix 2.11.0. Type :? for help.
134+
Welcome to Nix 2.18.1. Type :? for help.
135135

136136
Loading installable 'path:/Users/gabriella/proj/todo-app#'...
137137
Added 1 variables.
@@ -336,7 +336,7 @@ So `sops` doesn't completely solve the problem of secrets management (you still
336336
To use the `sops` command-line tool we'll need to convert our SSH primary key pair into an age key pair. This step is performed by the admin who has access to both the SSH public key and the SSH private key and requires the `ssh-to-age` command-line tool, which you can obtain like this:
337337

338338
```bash
339-
$ nix shell 'github:NixOS/nixpkgs/22.11#ssh-to-age'
339+
$ nix shell 'github:NixOS/nixpkgs/23.11#ssh-to-age'
340340
```
341341

342342
The public key of our age key pair will be stored in a `.sops.yaml` configuration file which lives in version control. To create the age public key, run:
@@ -380,7 +380,7 @@ Create a [fine-grained personal access token](https://docs.github.com/en/authent
380380
Fetch the `sops` command-line tool by running:
381381

382382
```bash
383-
$ nix shell 'github:NixOS/nixpkgs/22.11#sops'
383+
$ nix shell 'github:NixOS/nixpkgs/23.11#sops'
384384
```
385385

386386
… and then create a new secrets file by running:
@@ -461,7 +461,7 @@ Now we can distribute the GitHub personal access token stored inside of `secrets
461461

462462
```nix
463463
{ inputs = {
464-
nixpkgs.url = "github:NixOS/nixpkgs/22.11";
464+
nixpkgs.url = "github:NixOS/nixpkgs/23.11";
465465
466466
sops-nix.url = "github:Mic92/sops-nix/bd695cc4d0a5e1bead703cc1bec5fa3094820a81";
467467
};

0 commit comments

Comments
 (0)