diff options
| author | Ryan Schanzenbacher <ryan@rschanz.org> | 2025-01-12 21:19:05 -0500 |
|---|---|---|
| committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2025-01-12 21:19:05 -0500 |
| commit | ce1c24e3100d48c9c210eb1ebc5ebadcc6b77659 (patch) | |
| tree | 0ad0ef2d30db557ad4fb7bf47473ef3508723cb9 /modules/ryan-packages/bootloaders.scm | |
| parent | 67da316096f98f9a3fc038a1deba1b2c5356dfab (diff) | |
added uki bootloader maybe
Diffstat (limited to 'modules/ryan-packages/bootloaders.scm')
| -rw-r--r-- | modules/ryan-packages/bootloaders.scm | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/modules/ryan-packages/bootloaders.scm b/modules/ryan-packages/bootloaders.scm new file mode 100644 index 0000000..10f38d1 --- /dev/null +++ b/modules/ryan-packages/bootloaders.scm | |||
| @@ -0,0 +1,110 @@ | |||
| 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 | #:use-module (guix gexp) | ||
| 13 | #:use-module (guix utils) | ||
| 14 | #:use-module (guix modules) | ||
| 15 | #:use-module (guix packages) | ||
| 16 | #:use-module (guix git-download) | ||
| 17 | #:use-module (guix build-system gnu) | ||
| 18 | #:use-module (guix build-system meson) | ||
| 19 | #:use-module (guix build-system python)) | ||
| 20 | |||
| 21 | (define systemd-version "255") | ||
| 22 | (define systemd-source | ||
| 23 | (origin | ||
| 24 | (method git-fetch) | ||
| 25 | (uri (git-reference | ||
| 26 | (url "https://github.com/systemd/systemd") | ||
| 27 | (commit (string-append "v" systemd-version)))) | ||
| 28 | (file-name (git-file-name "systemd" systemd-version)) | ||
| 29 | (sha256 | ||
| 30 | (base32 | ||
| 31 | "1qdyw9g3jgvsbc1aryr11gpc3075w5pg00mqv4pyf3hwixxkwaq6")))) | ||
| 32 | |||
| 33 | (define-public (systemd-stub-name) | ||
| 34 | (let ((arch (cond ((target-x86-32?) "ia32") | ||
| 35 | ((target-x86-64?) "x64") | ||
| 36 | ((target-arm32?) "arm") | ||
| 37 | ((target-aarch64?) "aa64") | ||
| 38 | ((target-riscv64?) "riscv64")))) | ||
| 39 | (string-append "linux" arch ".efi.stub"))) | ||
| 40 | |||
| 41 | (define-public systemd-stub | ||
| 42 | (package | ||
| 43 | (name "systemd-stub") | ||
| 44 | (version systemd-version) | ||
| 45 | (source systemd-source) | ||
| 46 | (build-system meson-build-system) | ||
| 47 | (arguments | ||
| 48 | (list | ||
| 49 | #:configure-flags | ||
| 50 | `(list "-Defi=true" "-Dsbat-distro=guix" | ||
| 51 | "-Dsbat-distro-generation=1" ; package revision! | ||
| 52 | "-Dsbat-distro-summary=Guix System" | ||
| 53 | "-Dsbat-distro-url=https://guix.gnu.org" | ||
| 54 | ,(string-append "-Dsbat-distro-pkgname=" name) | ||
| 55 | ,(string-append "-Dsbat-distro-version=" version)) | ||
| 56 | #:phases | ||
| 57 | #~(let ((stub #$(string-append "src/boot/efi/" (systemd-stub-name)))) | ||
| 58 | (modify-phases %standard-phases | ||
| 59 | (replace 'build | ||
| 60 | (lambda* (#:key parallel-build? #:allow-other-keys) | ||
| 61 | (invoke "ninja" stub | ||
| 62 | "-j" (if parallel-build? | ||
| 63 | (number->string (parallel-job-count)) "1")))) | ||
| 64 | (replace 'install | ||
| 65 | (lambda _ | ||
| 66 | (install-file stub (string-append #$output "/libexec")))) | ||
| 67 | (delete 'check))))) | ||
| 68 | (inputs (list libcap python-pyelftools `(,util-linux "lib"))) | ||
| 69 | (native-inputs (list libxcrypt gperf pkg-config python-3 python-jinja2)) | ||
| 70 | (home-page "https://systemd.io") | ||
| 71 | (synopsis "Unified kernel image UEFI stub") | ||
| 72 | (description "Simple UEFi boot stub that loads a conjoined kernel image and | ||
| 73 | supporting data to their proper locations, before chainloading to the kernel. | ||
| 74 | Supports measured and/or verified boot environments.") | ||
| 75 | (license license:lgpl2.1+))) | ||
| 76 | |||
| 77 | (define-public ukify | ||
| 78 | (package | ||
| 79 | (name "ukify") | ||
| 80 | (version systemd-version) | ||
| 81 | (source systemd-source) | ||
| 82 | (build-system python-build-system) | ||
| 83 | (arguments | ||
| 84 | (list #:phases | ||
| 85 | #~(modify-phases %standard-phases | ||
| 86 | (replace 'build | ||
| 87 | (lambda _ | ||
| 88 | (substitute* "src/ukify/ukify.py" ; added in python 3.11 | ||
| 89 | (("datetime\\.UTC") "datetime.timezone.utc")))) | ||
| 90 | (delete 'check) | ||
| 91 | (replace 'install | ||
| 92 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 93 | (let* ((bin (string-append #$output "/bin")) | ||
| 94 | (file (string-append bin "/ukify")) | ||
| 95 | (binutils (assoc-ref inputs "binutils")) | ||
| 96 | (sbsign (assoc-ref inputs "sbsigntools"))) | ||
| 97 | (mkdir-p bin) | ||
| 98 | (copy-file "src/ukify/ukify.py" file) | ||
| 99 | (wrap-program file | ||
| 100 | `("PATH" ":" prefix | ||
| 101 | (,(string-append binutils "/bin") | ||
| 102 | ,(string-append sbsign "/bin")))))))))) | ||
| 103 | (inputs (list binutils python-cryptography python-pefile sbsigntools)) | ||
| 104 | (home-page "https://systemd.io") | ||
| 105 | (synopsis "Unified kernel image UEFI tool") | ||
| 106 | (description "@command{ukify} joins together a UKI stub, linux kernel, initrd, | ||
| 107 | kernel arguments, and optional secure boot signatures into a single, UEFI-bootable | ||
| 108 | image.") | ||
| 109 | (license license:lgpl2.1+))) | ||
| 110 | |||
