Skip to content

Commit 475a1da

Browse files
committed
Refactor Guix deployment into separate module
This sets the foundation for being able to test changes to Turing locally via `guix system`.
1 parent da06b9a commit 475a1da

12 files changed

Lines changed: 30 additions & 20 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: end-of-file-fixer
1212
- id: trailing-whitespace
1313
args: [--markdown-linebreak-ext=md]
14-
exclude: ^guix/guix-acl-keys/
14+
exclude: ^guix/resources/guix-acl-keys/
1515

1616
- repo: local
1717
hooks:

guix/deployment.scm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(define-module (deployment))
2+
(add-to-load-path (dirname (current-filename)))
3+
(use-modules (gnu machine)
4+
(gnu machine ssh)
5+
(machines turing))
6+
7+
8+
; local deployments:
9+
; SSHKEY=path/to/key USER=myuser guix deploy turing.scm
10+
; USER is usually implicitly declared somewhere
11+
(list (machine
12+
(operating-system %turing-os)
13+
(environment managed-host-environment-type)
14+
(configuration (machine-ssh-configuration
15+
(host-name "turing.box.chrisjl.dev")
16+
(build-locally? #f)
17+
(system "x86_64-linux")
18+
(host-key "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvvi6P/G+rZ2qUZ+anluvFQwYM/WFZkERygd9X9+xqU")
19+
(user (getenv "USER"))
20+
(identity (getenv "SSHKEY"))))))
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
;; Module imports
2+
(define-module (machines turing)
3+
#:export (%turing-os))
24
(use-modules (gnu)
35
(guix)
46
(gnu packages databases)
@@ -25,16 +27,16 @@
2527
;; # Save
2628
;; sudo guix system reconfigure turing.scm
2729

28-
(define %this-dir (dirname (current-filename)))
30+
(define %guix-dir (dirname (dirname (canonicalize-path (current-filename)))))
2931

30-
(define (file-from-cwd path)
31-
(local-file (string-append %this-dir path)))
32+
(define (resource path)
33+
(local-file (string-append %guix-dir "/resources/" path)))
3234

3335
(define (ssh-key name)
34-
(file-from-cwd (string-append "/ssh-keys/" name ".pub")))
36+
(resource (string-append "/ssh-keys/" name ".pub")))
3537

3638
(define (guix-archive-key name)
37-
(file-from-cwd (string-append "/guix-acl-keys/" name ".pub")))
39+
(resource (string-append "/guix-acl-keys/" name ".pub")))
3840

3941
(define %hidden-service-turing
4042
(simple-service 'hidden-service-turing tor-service-type
@@ -43,7 +45,7 @@
4345
(mapping '((22 "127.0.0.1:22")))))))
4446

4547
(define %motd
46-
(file-from-cwd "/resources/motd.txt"))
48+
(resource "/motd.txt"))
4749

4850
(define %certbot-deploy-hook
4951
(program-file
@@ -183,16 +185,4 @@
183185
(guix-archive-key "joe-lovelace"))
184186
%default-authorized-guix-keys))))))))
185187

186-
; local deployments:
187-
; SSHKEY=path/to/key USER=myuser guix deploy turing.scm
188-
; USER is usually implicitly declared somewhere
189-
(list (machine
190-
(operating-system %turing-os)
191-
(environment managed-host-environment-type)
192-
(configuration (machine-ssh-configuration
193-
(host-name "turing.box.chrisjl.dev")
194-
(build-locally? #f)
195-
(system "x86_64-linux")
196-
(host-key "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvvi6P/G+rZ2qUZ+anluvFQwYM/WFZkERygd9X9+xqU")
197-
(user (getenv "USER"))
198-
(identity (getenv "SSHKEY"))))))
188+
%turing-os
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)