aboutsummaryrefslogtreecommitdiff
path: root/crn/system/base.scm
blob: e1bd12a9c5359ea1d34540024f05c9ad19a9ea66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(define-module (system base)
  #:export (make-system))

(use-modules (gnu)
             (gnu system setuid)
             (nongnu packages linux)
             (nongnu system linux-initrd))
(use-package-modules avahi bash nfs)
(use-service-modules admin avahi cups dbus desktop networking nfs ssh xorg)

(define-public (make-swap swap-devices)
  (map (lambda (x)
         (swap-space
          (target x)))
       swap-devices))

(define-public (make-fs mount-point fs-device fs-type)
  (file-system
   (mount-point mount-point)
   (device fs-device)
   (type fs-type)))

(define* (make-system #:key
                      (use-nonguix? #f)
                      host-name
                      (locale "en_US.utf8")
                      (timezone "UTC")
                      (kbd-layout "us")
                      user-login
                      user-fullname
                      (packages '())
                      swap-device
                      root-device
                      efi-device
                      role)
  (operating-system
   (kernel (if use-nonguix?
             linux
             linux-libre))
   (initrd (if use-nonguix?
             microcode-initrd
             base-initrd))
   (firmware (if use-nonguix?
               (list linux-firmware)
               '()))

   (host-name host-name)
   (locale locale)
   (timezone timezone)
   (keyboard-layout (keyboard-layout kbd-layout))
   (name-service-switch %mdns-host-lookup-nss)

   (users (cons* (user-account
                  (name user-login)
                  (comment user-fullname)
                  (group "users")
                  (home-directory "/home/christopher")
                  (supplementary-groups '("wheel" "netdev" "audio" "video")))
                 %base-user-accounts))

   (packages (append (specifications->packages packages)
                     %base-packages))

   (setuid-programs
    (append (list (setuid-program
                   (program (file-append nfs-utils "/sbin/mount.nfs"))))
            %setuid-programs))

   (services
    (append (list
             (service dhcpcd-service-type)
             (service nfs-service-type (nfs-configuration))
             (service avahi-service-type (avahi-configuration))
             (service openssh-service-type
                      (openssh-configuration
                       (password-authentication? #f)))
             (service ntp-service-type)
             (service package-database-service-type)
             (service unattended-upgrade-service-type))

            (if use-nonguix?
              (modify-services %base-services
                               (guix-service-type config =>
                                                  (guix-configuration
                                                   (inherit config)
                                                   (substitute-urls
                                                    (append (list "https://substitutes.nonguix.org")
                                                            %default-substitute-urls))
                                                   (authorized-keys
                                                    (append (list (local-file "./nonguix-signing-key.pub"))
                                                            %default-authorized-guix-keys)))))
              %base-services)))

   (bootloader (bootloader-configuration
                (bootloader grub-efi-bootloader)
                (targets (list "/boot/efi"))
                (keyboard-layout keyboard-layout)))

   (swap-devices swap-device)
   (file-systems
    (cons* root-device
           efi-device
           %base-file-systems))))