;;; GNU Guix --- Functional package management for GNU ;;; ;;; Copyright © 2023 Stefan ;;; ;;; This file is not part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (zephyr) #:use-module (embedded) #:use-module (gnu packages bootloaders) #:use-module (gnu packages python) #:use-module (gnu packages python-xyz) #:use-module (guix build-system copy) #:use-module (guix build-system trivial) #:use-module (guix gexp) #:use-module (guix git-download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages)) ;; This is the common directory name for zephyr-modules to look for search-paths ;; to collect in the ZEPHYR_MODULES environment variable. The build-system of ;; Zephyr searches for a file zephyr/module.yml in all paths listed in the ;; environment variable ZEPHYR_MODULES. If that file is missing a name ;; property, then the parent directory name is used as the module name. Having ;; two modules with the same name is treated as an error. As Guix needs a ;; common directory name for search-path-specification, we need this ;; intermediate directory as a pattern to find unique module names. ;; Unfortunately search-path-specification is not powerful enough, so ;; complete-zephyr-application needs the correct-ZEPHYR_MODULES build-phase. (define-public %zephyr-module "zephyr-module") (define-public zephyr (let ((version "3.4.0")) (package (name "zephyr") (version version) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/zephyrproject-rtos/zephyr") (commit (string-append "zephyr-v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1gcry9fxv88js5nymi9akgrkghkwavggj3wqdgg2cz6brr5wg284")))) (build-system copy-build-system) (arguments (list #:install-plan #~(list (list "." "zephyr-base")) #:phases #~(modify-phases %standard-phases (add-after 'unpack 'set-USER_CACHE_DIR-and-BUILD_VERSION (lambda _ ;; Avoid fetching the BUILD_VERSION from the git repository. (substitute* "CMakeLists.txt" (("if *\\(DEFINED BUILD_VERSION\\)") (string-append "if (NOT DEFINED BUILD_VERSION)\n" " set(BUILD_VERSION " #$version ")\n" "elseif (DEFINED BUILD_VERSION)"))) ;; Avoid USER_CACHE_DIR to point to XDG_CACHE_HOME, HOME, or to ;; ZEPHYR_BASE inside the store. Instead use the build dir. (with-output-to-file "cmake/modules/user_cache.cmake" (lambda () (display "set(USER_CACHE_DIR ${CMAKE_BINARY_DIR}/cache)\n")))))))) (native-search-paths (list (search-path-specification (variable "ZEPHYR_BASE") (files '("zephyr-base")) (separator #f)) (search-path-specification (variable "ZEPHYR_MODULES") (files (list %zephyr-module))))) (home-page "https://zephyrproject.org") (synopsis "Zephyr Project RTOS") (description "The Zephyr Project is a scalable real-time operating system (RTOS) supporting multiple hardware architectures, optimized for resource constrained devices, and built with security in mind.") (license license:apsl2)))) (define-public zephyr-3.2+zmk-fixes (let ((revision "1") (commit "0a586db7b58269fb08248b081bdc3b43452da5f4")) (package/inherit zephyr (name "zephyr+zmk-fixes") (version (git-version "3.2.0" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/zmkfirmware/zephyr") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "04mqgzhgjb43ybryvpwrbq2g9i0gk7wd7s2ds3fsrakl4hxqss78")))) (home-page "https://github.com/zmkfirmware/zephyr")))) (define-public zephyr-build-tools (package (name "zephyr-build-tools") (version "1.0.0") (source #f) (build-system trivial-build-system) (arguments (list #:builder #~(mkdir #$output))) (propagated-inputs (list dtc python python-pyelftools python-pykwalify python-pyyaml python-packaging)) (home-page "https://zephyrproject.org") (synopsis "Zephyr build tools") (description "Required build tools to build the Zephyr RTOS.") (license license:apsl2)))