Last active
August 10, 2025 05:33
-
-
Save dlakelan/6ac3606b14e85c1b37933eeab840e63b to your computer and use it in GitHub Desktop.
tottenham-networking example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define-module (staged tottenham-network-funs) | |
| #:use-module (ip link) | |
| #:use-module (ip addr) | |
| #:export (start-lan-networking!)) | |
| (define (rename-ifaces!) | |
| (let ((namemap '(("xxxx" . "lan") | |
| ("xxxx" . "iot") | |
| ("xxxx" . "wan") | |
| ("xxxx" . "wan2") | |
| )) | |
| (linkinfo (map (lambda (x) (cons (link-addr x) x)) (get-links)))) | |
| (for-each (lambda (x) | |
| (let ((name (assoc (car x) namemap))) | |
| (if name | |
| (link-set (link-name (cdr x)) #:name (cdr name))))) | |
| linkinfo))) | |
| (define (set-addrs!) | |
| (addr-add "lan" "fdxxxx/64" #:ipv6? #t) | |
| (addr-add "lan" "xxxx/24") | |
| (addr-add "guest" "xxxx/24") | |
| (addr-add "guest" "fdxxxx/64" #:ipv6? #t) | |
| ) | |
| (define (start-wireguard!) | |
| #t | |
| ) | |
| (define (start-lan-networking!) | |
| (rename-ifaces!) | |
| (set-addrs!) | |
| (start-wireguard!)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define-module (services tottenham-networking)) | |
| (use-modules ;(staged tottenham-network-funs) | |
| (gnu) (gnu services) (gnu services shepherd) (gnu packages guile-xyz) (guix gexp) | |
| (guix modules)) | |
| (define-public tottenham-networking-service | |
| (simple-service | |
| 'tottenham-networking shepherd-root-service-type | |
| (list (shepherd-service | |
| (documentation "Manual Network Startup for tottenham") | |
| (provision '(networking)) | |
| (start | |
| (with-extensions | |
| (list guile-netlink) | |
| (with-imported-modules | |
| '((staged tottenham-network-funs)) | |
| #~(lambda _ | |
| (use-modules (staged tottenham-network-funs)) | |
| (start-lan-networking!) | |
| (fork+exec-command `("dhcpcd" "-f" ,(plain-file "dhcpcd.conf" | |
| " | |
| allowinterfaces wan* | |
| interface wan | |
| ia_na 1 | |
| ia_pd 2 lan/0 | |
| interface wan2 | |
| ia_na 5 | |
| ia_pd 6 - | |
| "))))))) | |
| (stop #~(make-kill-destructor)) | |
| (auto-start? #t))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment