Skip to content

Commit 0cedfca

Browse files
committed
Initial guix-sops configuration
This allows us to deploy secrets without making them publicly accessible in the store.
1 parent 7ee8597 commit 0cedfca

6 files changed

Lines changed: 59 additions & 2 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ secret.yaml filter=git-crypt diff=git-crypt
55
secret.yml filter=git-crypt diff=git-crypt
66
ghcr-pull-secrets.yaml filter=git-crypt diff=git-crypt
77
ssh-secrets.yaml filter=git-crypt diff=git-crypt
8+
guix/resources/age-key filter=git-crypt diff=git-crypt

guix/.sops.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
keys:
2+
- &user_pydis age1knt932vn0rgunzh9zzjs8cf7yjdx233gy2dt3w3uzm3apkp3g3qsralf2e
3+
- &host_turing age1gtw67lnhtcxnut3dl2keqm684zxy27cydc42xj5fazaq56uclvrslf6vta
4+
5+
creation_rules:
6+
- path_regex: .*secrets\.yaml$
7+
key_groups:
8+
- age:
9+
- *user_pydis
10+
- *host_turing

guix/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,39 @@ as a playground for ideas.
1616
--generate-key` as root.
1717
- This is needed for the remote Guix instance to accept packages we build
1818
locally.
19+
- `sops-guix` configured as a channel. For this, add:
20+
21+
```scheme
22+
(cons* (channel
23+
(name 'sops-guix)
24+
(url "https://github.com/fishinthecalculator/sops-guix.git")
25+
(branch "main")
26+
;; Enable signature verification:
27+
(introduction
28+
(make-channel-introduction
29+
"0bbaf1fdd25266c7df790f65640aaa01e6d2dbc9"
30+
(openpgp-fingerprint
31+
"8D10 60B9 6BB8 292E 829B 7249 AED4 1CC1 93B7 01E2"))))
32+
%default-channels)
33+
```
34+
35+
to your `~/.config/guix/channels.scm`. After adding it, run `guix pull`.
36+
- [`sops`](https://github.com/getsops/sops) installed locally, along with
37+
[`age`](https://github.com/FiloSottile/age).
38+
39+
40+
**Host prerequisites**
41+
42+
One-time setup for Turing:
43+
44+
- `sudo age-keygen -o /root/pydis.txt`
45+
46+
Note down the public key and add it to `.sops.yaml`.
1947

2048
**Testing**
2149

50+
It is recommended to test building the image locally first to catch errors.
51+
2252
```sh
2353
# Note that you presently need to run this as root, see
2454
# https://codeberg.org/guix/guix/issues/4788

guix/machines/turing.scm

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
(use-modules (gnu)
55
(guix)
66
(gnu packages databases)
7+
(gnu packages golang-crypto)
78
(gnu packages linux)
89
(gnu packages tmux)
910
(gnu packages vim)
1011
(gnu services admin)
1112
(gnu services certbot)
1213
(gnu services databases)
1314
(gnu services networking)
14-
(gnu services web))
15+
(gnu services web)
16+
(sops secrets)
17+
(sops services sops))
1518
(use-service-modules networking ssh)
1619
(use-package-modules bootloaders)
1720

@@ -29,6 +32,8 @@
2932

3033
(define %guix-dir (dirname (dirname (canonicalize-path (current-filename)))))
3134

35+
(define %secrets-yaml (local-file (string-append %guix-dir "/secrets.yaml")))
36+
3237
(define (resource path)
3338
(local-file (string-append %guix-dir "/resources/" path)))
3439

@@ -119,6 +124,17 @@
119124
; (uri "/.well-known")
120125
; (body (list "root /var/www; "))))))))))
121126
;
127+
(service sops-secrets-service-type
128+
(sops-service-configuration
129+
(generate-key? #f)
130+
(secrets
131+
(list
132+
(sops-secret
133+
(key '("good"))
134+
(file %secrets-yaml)
135+
(user "root")
136+
(group "root")
137+
(permissions #o400))))))
122138
(service certbot-service-type
123139
(certbot-configuration
124140
(email "ops@owlcorp.uk")
@@ -171,7 +187,7 @@
171187
(home-directory "/home/j")
172188
(supplementary-groups '("wheel" "netdev" "audio" "video")))
173189
%base-user-accounts))
174-
(packages (cons* %base-packages))
190+
(packages (cons* age %base-packages))
175191
(sudoers-file (plain-file "sudoers" "root ALL=(ALL) ALL
176192
%wheel ALL=NOPASSWD: ALL
177193
"))

guix/resources/age-key

211 Bytes
Binary file not shown.

guix/secrets.yaml

2.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)