modules/ryan-packages/bootloaders.scm
01132663060e0ace2badde34ba25a216b22db15d
· 5.9 KB · 148 lines
raw
| 1 | (define-module (ryan-packages bootloaders) |
| 2 | #:use-module ((guix licenses) #:prefix license:) |
| 3 | #:use-module (gnu packages efi) |
| 4 | #:use-module (gnu packages base) |
| 5 | #:use-module (gnu packages linux) |
| 6 | #:use-module (gnu packages gperf) |
| 7 | #:use-module (gnu packages crypto) |
| 8 | #:use-module (gnu packages python) |
| 9 | #:use-module (gnu packages python-xyz) |
| 10 | #:use-module (gnu packages python-crypto) |
| 11 | #:use-module (gnu packages pkg-config) |
| 12 | ;below for cryptsetup |
| 13 | #:use-module (gnu packages password-utils) |
| 14 | #:use-module (gnu packages cryptsetup) |
| 15 | #:use-module (gnu packages security-token) |
| 16 | #:use-module (gnu packages web) |
| 17 | #:use-module (gnu packages gnupg) |
| 18 | #:use-module (gnu packages tls) |
| 19 | #:use-module (guix gexp) |
| 20 | #:use-module (guix utils) |
| 21 | #:use-module (guix modules) |
| 22 | #:use-module (guix packages) |
| 23 | #:use-module (guix git-download) |
| 24 | #:use-module (guix build-system gnu) |
| 25 | #:use-module (guix build-system meson) |
| 26 | #:use-module (guix build-system python)) |
| 27 | |
| 28 | (define systemd-version "258") |
| 29 | (define systemd-source |
| 30 | (origin |
| 31 | (method git-fetch) |
| 32 | (uri (git-reference |
| 33 | (url "https://github.com/systemd/systemd") |
| 34 | (commit (string-append "v" systemd-version)))) |
| 35 | (file-name (git-file-name "systemd" systemd-version)) |
| 36 | (sha256 |
| 37 | (base32 |
| 38 | "18gnp45gl1154jra6qv95k8y7ny6phdm87yqi5jdq13cadlrklf6")))) |
| 39 | |
| 40 | (define-public (systemd-stub-name) |
| 41 | (let ((arch (cond ((target-x86-32?) "ia32") |
| 42 | ((target-x86-64?) "x64") |
| 43 | ((target-arm32?) "arm") |
| 44 | ((target-aarch64?) "aa64") |
| 45 | ((target-riscv64?) "riscv64")))) |
| 46 | (string-append "linux" arch ".efi.stub"))) |
| 47 | |
| 48 | (define-public systemd-stub |
| 49 | (package |
| 50 | (name "systemd-stub") |
| 51 | (version systemd-version) |
| 52 | (source systemd-source) |
| 53 | (build-system meson-build-system) |
| 54 | (arguments |
| 55 | (list |
| 56 | #:configure-flags |
| 57 | `(list "-Defi=true" "-Dsbat-distro=guix" |
| 58 | "-Dsbat-distro-generation=1" ; package revision! |
| 59 | "-Dsbat-distro-summary=Guix System" |
| 60 | "-Dsbat-distro-url=https://guix.gnu.org" |
| 61 | ,(string-append "-Dsbat-distro-pkgname=" name) |
| 62 | ,(string-append "-Dsbat-distro-version=" version)) |
| 63 | #:phases |
| 64 | #~(let ((stub #$(string-append "src/boot/" (systemd-stub-name)))) |
| 65 | (modify-phases %standard-phases |
| 66 | (replace 'build |
| 67 | (lambda* (#:key parallel-build? #:allow-other-keys) |
| 68 | (invoke "ninja" stub |
| 69 | "-j" (if parallel-build? |
| 70 | (number->string (parallel-job-count)) "1")))) |
| 71 | (replace 'install |
| 72 | (lambda _ |
| 73 | (install-file stub (string-append #$output "/libexec")))) |
| 74 | (delete 'check))))) |
| 75 | (inputs (list libcap python-pyelftools `(,util-linux "lib"))) |
| 76 | (native-inputs (list libxcrypt gperf pkg-config python-3 python-jinja2)) |
| 77 | (home-page "https://systemd.io") |
| 78 | (synopsis "Unified kernel image UEFI stub") |
| 79 | (description "Simple UEFi boot stub that loads a conjoined kernel image and |
| 80 | supporting data to their proper locations, before chainloading to the kernel. |
| 81 | Supports measured and/or verified boot environments.") |
| 82 | (license license:lgpl2.1+))) |
| 83 | |
| 84 | (define-public ukify |
| 85 | (package |
| 86 | (name "ukify") |
| 87 | (version systemd-version) |
| 88 | (source systemd-source) |
| 89 | (build-system python-build-system) |
| 90 | (arguments |
| 91 | (list #:phases |
| 92 | #~(modify-phases %standard-phases |
| 93 | (replace 'build |
| 94 | (lambda _ |
| 95 | (substitute* "src/ukify/ukify.py" ; added in python 3.11 |
| 96 | (("datetime\\.UTC") "datetime.timezone.utc")))) |
| 97 | (delete 'check) |
| 98 | (replace 'install |
| 99 | (lambda* (#:key inputs #:allow-other-keys) |
| 100 | (let* ((bin (string-append #$output "/bin")) |
| 101 | (file (string-append bin "/ukify")) |
| 102 | (binutils (assoc-ref inputs "binutils")) |
| 103 | (sbsign (assoc-ref inputs "sbsigntools"))) |
| 104 | (mkdir-p bin) |
| 105 | (copy-file "src/ukify/ukify.py" file) |
| 106 | (wrap-program file |
| 107 | `("PATH" ":" prefix |
| 108 | (,(string-append binutils "/bin") |
| 109 | ,(string-append sbsign "/bin")))))))))) |
| 110 | (inputs (list binutils python-cryptography python-pefile sbsigntools)) |
| 111 | (home-page "https://systemd.io") |
| 112 | (synopsis "Unified kernel image UEFI tool") |
| 113 | (description "@command{ukify} joins together a UKI stub, linux kernel, initrd, |
| 114 | kernel arguments, and optional secure boot signatures into a single, UEFI-bootable |
| 115 | image.") |
| 116 | (license license:lgpl2.1+))) |
| 117 | |
| 118 | (define-public systemd-cryptsetup |
| 119 | (package |
| 120 | (name "systemd-cryptsetup") |
| 121 | (version systemd-version) |
| 122 | (source systemd-source) |
| 123 | (build-system meson-build-system) |
| 124 | (arguments |
| 125 | (list |
| 126 | #:build-type "release" |
| 127 | #:configure-flags |
| 128 | `(list "-Dlibcryptsetup=true" "-Dlibfido2=true" |
| 129 | "-Dopenssl=true") |
| 130 | #:phases |
| 131 | #~(modify-phases %standard-phases |
| 132 | (replace 'build |
| 133 | (lambda* (#:key parallel-build? #:allow-other-keys) |
| 134 | (invoke "ninja" "systemd-cryptsetup" |
| 135 | "-j" (if parallel-build? |
| 136 | (number->string (parallel-job-count)) "1")))) |
| 137 | (replace 'install |
| 138 | (lambda _ |
| 139 | (install-file "systemd-cryptsetup" (string-append #$output "/libexec")) |
| 140 | (install-file "src/shared/libsystemd-shared-258.so" (string-append #$output "/lib")))) |
| 141 | (delete 'check)))) |
| 142 | (native-inputs (list `(,util-linux "lib") eudev lvm2 cryptsetup libfido2 libxcrypt gperf pkg-config python-3 python-jinja2 libcap argon2 json-c libgcrypt openssl)) |
| 143 | (home-page "test") |
| 144 | (synopsis "test") |
| 145 | (description "test") |
| 146 | (license license:lgpl2.1+))) |
| 147 | |
| 148 | systemd-cryptsetup |