Paste number 145436: Guix: Working custom initrd example

Paste number 145436: Guix: Working custom initrd example
Pasted by: dusxmt
When:6 years, 10 months ago
Share:Tweet this! | http://paste.lisp.org/+347W
Channel:None
Paste contents:
Raw Source | XML | Display As
(use-modules (gnu)
             (ice-9 match)
             (guix gexp)                 ;; For G-Expressions.
             (guix monads)               ;; For Monads.
             (guix store)                ;; For `%store-monad'
             (gnu system   linux-initrd) ;; For `expression->initrd'.
             (gnu packages linux-custom) ;; For `linux-libre-custom'.
             (gnu packages linux)        ;; For `e2fsck/static'.
             (gnu packages zile)         ;; For the removal of `zile'.
             (gnu packages emacs)        ;; For the removal of `emacs'.
             (gnu packages nano)         ;; For the removal of `nano'.
             (gnu packages nvi)          ;; For `nvi'.
             (gnu services networking)   ;; For `static-networking-service'.
             (gnu services xorg)         ;; For `slim-service'.
             (gnu services ssh))         ;; For `lsh-service'.

(define (file-system->spec fs)
  "Return a list corresponding to file-system FS that can be passed to the
initrd code."
  (match fs
    (($ <file-system> device title mount-point type flags options _ check?)
     (list device title mount-point type flags options check?))))

(operating-system
  (host-name "QemuGuixSDBox")
  (timezone "Europe/Bratislava")
  (locale "en_US.UTF-8")
  (kernel linux-libre-custom)
  (initrd
    (lambda (file-systems . rest)
      (mlet %store-monad ()
        (expression->initrd
           #~(begin
              (use-modules (gnu build linux-boot)
                           (guix build utils)
                           (srfi srfi-26))
              (with-output-to-port (%make-void-port "w")
                (lambda ()
                  (set-path-environment-variable "PATH" '("bin" "sbin")
                                                 (list #$e2fsck/static))))
              (boot-system #:mounts '#$(map file-system->spec file-systems)))

      #:name "bareboned-initrd"
      #:modules '((guix build utils)
                  (gnu build linux-boot)
                  (gnu build linux-modules)
                  (gnu build file-systems)
                  (guix elf))))))

  (bootloader
    (grub-configuration
      (device "/dev/sda")))

  (file-systems
    (append
      %base-file-systems
      (list
        ;; Root file system.
        (file-system
          (device "Guixotic-root")
          (mount-point "/")
          (type "ext4")
          (needed-for-boot? #t)
          (check? #t)))))
  (users
    (list
      ;; Me!
      (user-account
        (name "dusan")
        (uid 1000)
        (group "users")       ;; I can hear you now.
        (supplementary-groups '("audio"))
        (comment "Dusan Xmetov")
        (home-directory "/home/dusan"))))

  (packages
    (append
      (delete zile
        (delete emacs
          (delete nano
          %base-packages)))
      (list
        ;; No system is complete without a proper text editor.
        nvi)))

  (services
    (append
      %base-services
      (list 
        ;; X.
        (slim-service #:allow-empty-passwords? #f #:auto-login? #f
                      #:startx (xorg-start-command #:drivers '("cirrus" "vesa")
                                                   #:resolutions
                                                     '((1024 768) (640 480))))

        ;; Ethernet.
        (static-networking-service "enp0s3" "10.0.2.15"
                                   #:gateway "10.0.2.2"
                                   #:name-servers '("10.0.2.3"))
        ;; SSH Server.
        (lsh-service #:port-number 22 #:root-login? #f
                     #:allow-empty-passwords? #f)))))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.