2022-09-17 19:54:28 -06:00
|
|
|
(define-module (system base-system)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (guix gexp)
|
|
|
|
|
2023-11-24 11:36:43 -07:00
|
|
|
#:use-module (nongnu system linux-initrd)
|
2022-09-17 19:28:48 -06:00
|
|
|
#:use-module (nongnu packages linux)
|
2023-11-29 17:52:49 -07:00
|
|
|
|
|
|
|
#:use-module (gnu bootloader)
|
|
|
|
#:use-module (gnu bootloader grub)
|
|
|
|
#:use-module (gnu system accounts)
|
|
|
|
#:use-module (gnu system shadow)
|
2023-11-24 11:36:43 -07:00
|
|
|
#:use-module (gnu system setuid)
|
2023-11-30 13:52:13 -07:00
|
|
|
#:use-module (gnu services configuration)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu system file-systems)
|
|
|
|
#:use-module (gnu system)
|
2022-09-17 19:28:48 -06:00
|
|
|
#:use-module (gnu system nss)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu services kerberos)
|
|
|
|
#:use-module (gnu services sssd)
|
|
|
|
#:use-module (gnu services base)
|
2023-11-27 18:08:03 -07:00
|
|
|
#:use-module (gnu services)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu services desktop)
|
2022-09-17 19:28:48 -06:00
|
|
|
#:use-module (gnu services networking)
|
|
|
|
#:use-module (gnu services ssh)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu services vpn)
|
|
|
|
#:use-module (gnu system pam)
|
|
|
|
#:use-module (gnu services dbus)
|
|
|
|
#:use-module (gnu system keyboard)
|
|
|
|
#:use-module (gnu packages admin)
|
2023-11-30 13:52:13 -07:00
|
|
|
|
|
|
|
#:use-module (gnu packages slapd)
|
|
|
|
#:use-module (gnu packages linux)
|
|
|
|
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu packages shells)
|
|
|
|
#:use-module (gnu packages gnome)
|
2023-11-26 14:58:54 -07:00
|
|
|
#:use-module (gnu packages ssh)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu packages dns)
|
|
|
|
#:use-module (gnu packages version-control)
|
2023-11-24 11:36:43 -07:00
|
|
|
#:use-module (gnu packages vim)
|
|
|
|
#:use-module (gnu packages certs)
|
2022-09-17 19:28:48 -06:00
|
|
|
#:use-module (gnu packages kerberos)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu packages vpn)
|
2022-09-17 19:28:48 -06:00
|
|
|
#:use-module (gnu packages wm)
|
|
|
|
#:use-module (gnu packages suckless)
|
|
|
|
#:use-module (gnu packages terminals)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:use-module (gnu packages gnuzilla)
|
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
#:export (%metznet-base-user-accounts)
|
|
|
|
#:export (%metznet-base-groups)
|
2023-11-29 17:52:49 -07:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
#:export (%metznet-desktop-packages)
|
2023-11-29 17:52:49 -07:00
|
|
|
#:export (%metznet-base-packages)
|
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
#:export (%kvm-udev-rule)
|
|
|
|
#:export (%usb-udev-rule)
|
|
|
|
#:export (%tun-udev-rule)
|
2023-11-29 17:52:49 -07:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
#:export (%metznet-desktop-services)
|
|
|
|
#:export (%metznet-server-services)
|
2023-11-29 17:52:49 -07:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
#:export (%metznet-base-server-system)
|
|
|
|
#:export (%metznet-base-desktop-system))
|
|
|
|
|
2023-11-29 17:52:49 -07:00
|
|
|
(define %domain-realm
|
|
|
|
"METZNET.CA")
|
|
|
|
|
|
|
|
(define %domain-name
|
|
|
|
"metznet.ca")
|
|
|
|
|
|
|
|
(define %domain-kadmin
|
|
|
|
(string-append "kerberos." %domain-name))
|
|
|
|
|
|
|
|
(define %domain-kdc
|
|
|
|
(string-append "kerberos." %domain-name))
|
|
|
|
|
|
|
|
(define %metznet-base-user-accounts
|
|
|
|
(append (list (user-account
|
|
|
|
(name "root")
|
|
|
|
(group "root")
|
|
|
|
(uid 0)
|
2023-11-30 18:26:00 -07:00
|
|
|
(password (crypt (or (getenv "GUIX_ROOT_PW") "root")
|
|
|
|
"$6$salt"))
|
2023-11-29 17:52:49 -07:00
|
|
|
(shell (file-append zsh "/bin/zsh")))) %base-user-accounts))
|
|
|
|
|
|
|
|
(define %metznet-base-groups
|
|
|
|
(append (list (user-group
|
|
|
|
(system? #t)
|
|
|
|
(name "realtime"))
|
|
|
|
(user-group
|
|
|
|
(system? #t)
|
|
|
|
(name "usb"))) %base-groups))
|
|
|
|
|
|
|
|
(define %metznet-base-packages
|
|
|
|
(append (list openssh
|
2023-11-30 13:52:13 -07:00
|
|
|
|
|
|
|
openldap-slapd
|
|
|
|
strace
|
|
|
|
|
2023-11-29 17:52:49 -07:00
|
|
|
git
|
|
|
|
neovim
|
|
|
|
zsh
|
|
|
|
le-certs
|
|
|
|
nss-certs
|
|
|
|
mit-krb5) %base-packages))
|
|
|
|
|
|
|
|
(define %metznet-desktop-packages
|
|
|
|
(append (list i3-wm i3status dmenu kitty icecat) %metznet-base-packages))
|
|
|
|
|
|
|
|
(define %desktop-setuid-programs
|
|
|
|
(append (list (setuid-program
|
|
|
|
(program #~(string-append #$openvpn "/sbin/openvpn")))
|
|
|
|
(setuid-program
|
|
|
|
(program #~(string-append #$openresolv "/sbin/resolvconf"))))
|
|
|
|
%setuid-programs))
|
|
|
|
|
|
|
|
(define %metznet-krb5-config
|
|
|
|
(krb5-configuration (default-realm %domain-realm)
|
|
|
|
(allow-weak-crypto? #t)
|
|
|
|
(rdns? #f)
|
|
|
|
(realms (list (krb5-realm (name %domain-realm)
|
|
|
|
(admin-server %domain-kadmin)
|
|
|
|
(kdc %domain-kdc))))))
|
|
|
|
|
|
|
|
(define %default-keyboard-layout
|
|
|
|
(keyboard-layout "us"))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %kvm-udev-rule
|
2023-11-29 17:52:49 -07:00
|
|
|
(udev-rule "65-kvm.rules"
|
|
|
|
"KERNEL==\"KVM\", GROUP=\"libvirt\", MODE=\"0660\""))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %usb-udev-rule
|
2023-11-29 17:52:49 -07:00
|
|
|
(udev-rule "51-usb.rules"
|
|
|
|
(string-append "SUBSYSTEM==\"usb\", GROUP=\"usb\"\n"
|
|
|
|
"SUBSYSTEM==\"usbmisc\", GROUP=\"usb\"")))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
|
|
|
(define %tun-udev-rule
|
2023-11-29 17:52:49 -07:00
|
|
|
(udev-rule "90-tun.rules"
|
|
|
|
"KERNEL==\"tun\", GROUP=\"netdev\", MODE=\"0660\", OPTIONS+=\"static_node=net/tun\""))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
|
|
|
(define %backlight-udev-rule
|
2023-11-29 17:52:49 -07:00
|
|
|
(udev-rule "55-backlight.rules"
|
|
|
|
"RUN+=\"/bin/chgrp video /sys/class/backlight/intel_backlight/brightness\""))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %metznet-name-service-switch
|
2023-11-27 18:08:03 -07:00
|
|
|
(let ((services (list (name-service (name "sss"))
|
2023-11-24 11:36:43 -07:00
|
|
|
(name-service (name "files")))))
|
2023-11-29 17:52:49 -07:00
|
|
|
(name-service-switch (password services)
|
|
|
|
(shadow services)
|
|
|
|
(group services))))
|
2023-11-22 12:26:17 -07:00
|
|
|
|
2023-11-30 18:26:00 -07:00
|
|
|
(define list-of-strings?
|
|
|
|
(list-of string?))
|
2023-11-30 13:52:13 -07:00
|
|
|
|
2023-11-30 18:26:00 -07:00
|
|
|
(define-configuration/no-serialization metznet-system-configuration
|
|
|
|
(certs (file-like le-certs)
|
|
|
|
"certificate package")
|
2023-11-30 19:48:47 -07:00
|
|
|
(channels-file (file-like (scheme-file
|
|
|
|
"channels.scm"
|
|
|
|
#~(append (list
|
|
|
|
(channel
|
|
|
|
(name 'metznet-channel)
|
|
|
|
(url
|
|
|
|
"https://git.metznet.ca/MetzNet/metznet-channel.git"))
|
|
|
|
(channel
|
|
|
|
(name 'nonguix)
|
|
|
|
(url
|
|
|
|
"https://gitlab.com/nonguix/nonguix.git"))
|
2023-11-30 19:56:49 -07:00
|
|
|
%default-channels))))
|
|
|
|
"channels.scm")
|
|
|
|
(pam-services (list-of-strings (list
|
|
|
|
"su"
|
|
|
|
"gdm-password"
|
|
|
|
"login"
|
|
|
|
"sshd"
|
|
|
|
"passwd"))
|
|
|
|
"list of pam services to configure"))
|
2023-11-30 13:52:13 -07:00
|
|
|
|
|
|
|
(define (pam-mkhomedir-service configuration)
|
2023-11-29 17:52:49 -07:00
|
|
|
(lambda (pam)
|
2023-11-30 18:26:00 -07:00
|
|
|
(if (member (pam-service-name pam)
|
|
|
|
(metznet-system-configuration-pam-services configuration))
|
2023-11-29 17:52:49 -07:00
|
|
|
(let ((required (pam-entry (control "required")
|
|
|
|
(module "pam_mkhomedir.so"))))
|
|
|
|
(pam-service (inherit pam)
|
|
|
|
(session (cons required
|
|
|
|
(pam-service-account pam))))) pam)))
|
2023-11-24 11:36:43 -07:00
|
|
|
|
2023-11-30 13:52:13 -07:00
|
|
|
(define (pam-mkhomedir-services configuration)
|
|
|
|
(list (pam-mkhomedir-service configuration)))
|
2023-11-24 11:36:43 -07:00
|
|
|
|
2023-11-30 13:52:13 -07:00
|
|
|
(define (metznet-activation configuration)
|
2023-11-29 17:52:49 -07:00
|
|
|
#~(if (access? "/bin/zsh" F_OK)
|
|
|
|
(display "zsh already linked")
|
|
|
|
(begin
|
|
|
|
(display "linking zsh")
|
|
|
|
(symlink (string-append #$zsh "/bin/zsh") "/bin/zsh"))))
|
2023-11-30 13:52:13 -07:00
|
|
|
|
|
|
|
(define (metznet-etc-service configuration)
|
2023-11-30 20:03:45 -07:00
|
|
|
`(("guix/channels.scm" ,(metznet-system-configuration-channels-file configuration))
|
|
|
|
("openvpn/ta.key" ,(local-file "ta.key"))
|
|
|
|
("openvpn/ca.crt" ,(local-file "ca.crt"))
|
|
|
|
("openvpn/client.crt" ,(local-file "client.crt"))
|
|
|
|
("openvpn/client.key" ,(local-file "client.key"))))
|
2023-11-30 13:52:13 -07:00
|
|
|
|
2023-11-24 11:36:43 -07:00
|
|
|
(define metznet-service-type
|
2023-11-29 17:52:49 -07:00
|
|
|
(service-type (name 'metznet-service)
|
|
|
|
(description "MetzNet Services")
|
|
|
|
(extensions (list (service-extension activation-service-type
|
|
|
|
metznet-activation)
|
2023-11-30 13:52:13 -07:00
|
|
|
(service-extension profile-service-type
|
2023-11-30 18:26:00 -07:00
|
|
|
(compose list
|
|
|
|
metznet-system-configuration-certs))
|
2023-11-30 13:52:13 -07:00
|
|
|
(service-extension etc-service-type
|
|
|
|
metznet-etc-service)
|
2023-11-29 17:52:49 -07:00
|
|
|
(service-extension pam-root-service-type
|
|
|
|
pam-mkhomedir-services)))
|
2023-11-30 13:52:13 -07:00
|
|
|
(default-value (metznet-system-configuration))))
|
2023-11-22 12:30:06 -07:00
|
|
|
|
2023-11-24 11:36:43 -07:00
|
|
|
(define %metznet-services
|
2023-11-29 17:52:49 -07:00
|
|
|
(list (service openssh-service-type
|
|
|
|
(openssh-configuration (extra-content
|
|
|
|
"KerberosAuthentication yes")))
|
|
|
|
(service krb5-service-type %metznet-krb5-config)
|
|
|
|
(service pam-krb5-service-type
|
|
|
|
(pam-krb5-configuration (pam-krb5 pam-krb5)
|
|
|
|
(minimum-uid 1000)))
|
|
|
|
(service sssd-service-type
|
2023-11-30 18:26:00 -07:00
|
|
|
(sssd-configuration (pam-services (list "su" "gdm-password"
|
|
|
|
"login" "sshd"
|
|
|
|
"passwd"))))
|
2023-11-30 13:52:13 -07:00
|
|
|
(service metznet-service-type)))
|
2023-11-29 17:52:49 -07:00
|
|
|
|
|
|
|
(define %metznet-nscd-configuration
|
|
|
|
(nscd-configuration (caches (append (list (nscd-cache (database 'passwd)
|
|
|
|
(positive-time-to-live
|
|
|
|
(* 3600 12))
|
|
|
|
(negative-time-to-live
|
|
|
|
20)
|
|
|
|
(persistent? #t))
|
|
|
|
(nscd-cache (database 'group)
|
|
|
|
(positive-time-to-live
|
|
|
|
(* 3600 12))
|
|
|
|
(negative-time-to-live
|
|
|
|
20)
|
|
|
|
(persistent? #t)))
|
|
|
|
%nscd-default-caches))))
|
2023-11-24 11:36:43 -07:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %metznet-desktop-services
|
2023-11-29 17:52:49 -07:00
|
|
|
(append %metznet-services
|
|
|
|
(modify-services %desktop-services
|
|
|
|
(nscd-service-type config => %metznet-nscd-configuration)
|
|
|
|
(guix-service-type config =>
|
|
|
|
(guix-configuration (inherit config)
|
|
|
|
(substitute-urls (append (list
|
|
|
|
"https://substitutes.nonguix.org")
|
|
|
|
%default-substitute-urls))
|
|
|
|
(authorized-keys (append (list
|
|
|
|
(plain-file
|
|
|
|
"nonguix.pub"
|
|
|
|
"(public-key\n (ecc\n (curve Ed25519)\n (q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)))"))
|
|
|
|
%default-authorized-guix-keys))))
|
|
|
|
(udev-service-type config =>
|
|
|
|
(udev-configuration (inherit config)
|
|
|
|
(rules (append (list
|
|
|
|
%tun-udev-rule
|
|
|
|
%backlight-udev-rule)
|
|
|
|
(udev-configuration-rules
|
|
|
|
config)))))
|
|
|
|
(network-manager-service-type config =>
|
|
|
|
(network-manager-configuration (inherit
|
|
|
|
config)
|
|
|
|
(vpn-plugins
|
|
|
|
(list
|
|
|
|
network-manager-openvpn)))))))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-27 11:26:54 -07:00
|
|
|
(define %metznet-server-services
|
|
|
|
(append %metznet-services
|
2023-11-29 17:52:49 -07:00
|
|
|
(list (dbus-service)
|
|
|
|
(service dhcp-client-service-type)
|
|
|
|
(openvpn-client-service #:config (openvpn-client-configuration
|
|
|
|
(openvpn openvpn)
|
|
|
|
(pid-file
|
|
|
|
"/var/run/openvpn/client.pid")
|
|
|
|
(persist-key? #f)
|
2023-11-30 16:24:50 -07:00
|
|
|
(remote (list (openvpn-remote-configuration
|
2023-11-30 18:26:00 -07:00
|
|
|
(name
|
|
|
|
"vpn.metznet.ca"))))
|
2023-11-29 17:52:49 -07:00
|
|
|
(tls-auth
|
|
|
|
"/etc/openvpn/ta.key"))))
|
|
|
|
(modify-services %base-services
|
|
|
|
(nscd-service-type config => %metznet-nscd-configuration))))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %metznet-base-operating-system
|
2022-09-17 19:28:48 -06:00
|
|
|
(operating-system
|
|
|
|
;; Hostname and localization information
|
|
|
|
(host-name "base")
|
|
|
|
(timezone "America/Edmonton")
|
|
|
|
(locale "en_CA.utf8")
|
|
|
|
(keyboard-layout %default-keyboard-layout)
|
2023-11-21 19:05:13 -07:00
|
|
|
(name-service-switch %metznet-name-service-switch)
|
2022-09-17 19:28:48 -06:00
|
|
|
;; Kernel and firmware definitions
|
|
|
|
(kernel linux)
|
|
|
|
(kernel-arguments (append '("console=ttyS0") %default-kernel-arguments))
|
|
|
|
(firmware (list linux-firmware))
|
|
|
|
(initrd microcode-initrd)
|
|
|
|
;; Grub UEFI Bootloader installed to /boot/efi
|
2023-11-29 17:52:49 -07:00
|
|
|
(bootloader (bootloader-configuration
|
|
|
|
(bootloader grub-efi-bootloader)
|
|
|
|
(targets '("/boot/efi"))
|
|
|
|
(keyboard-layout keyboard-layout)))
|
|
|
|
(file-systems (cons* (file-system
|
|
|
|
(mount-point "/")
|
2023-11-30 17:52:15 -07:00
|
|
|
(device (file-system-label "guix-data"))
|
2023-11-30 18:19:49 -07:00
|
|
|
(type "ext4")
|
2023-11-30 17:52:15 -07:00
|
|
|
(check? #f))
|
2023-11-30 18:26:00 -07:00
|
|
|
(file-system
|
2023-11-30 17:52:15 -07:00
|
|
|
(mount-point "/boot/efi")
|
|
|
|
(device (file-system-label "guix-boot"))
|
|
|
|
(type "fat32")
|
2023-11-30 18:26:00 -07:00
|
|
|
(check? #f)) %base-file-systems))
|
2023-11-21 19:05:13 -07:00
|
|
|
(users %metznet-base-user-accounts)
|
|
|
|
(groups %metznet-base-groups)
|
|
|
|
(packages %metznet-base-packages)
|
2023-11-29 17:52:49 -07:00
|
|
|
(services
|
|
|
|
(append %metznet-services %base-services))))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %metznet-base-server-system
|
2023-11-29 17:52:49 -07:00
|
|
|
(operating-system
|
|
|
|
(inherit %metznet-base-operating-system)
|
|
|
|
(host-name "metznet-base-server")
|
|
|
|
(packages %metznet-base-packages)
|
|
|
|
(services
|
|
|
|
%metznet-server-services)))
|
2022-09-17 19:28:48 -06:00
|
|
|
|
2023-11-21 19:05:13 -07:00
|
|
|
(define %metznet-base-desktop-system
|
2023-11-29 17:52:49 -07:00
|
|
|
(operating-system
|
|
|
|
(inherit %metznet-base-operating-system)
|
|
|
|
(host-name "metznet-base-desktop")
|
|
|
|
(setuid-programs %desktop-setuid-programs)
|
|
|
|
(packages %metznet-desktop-packages)
|
|
|
|
(services
|
|
|
|
%metznet-desktop-services)))
|