aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;;
;;; This file is 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 <http://www.gnu.org/licenses/>.

(define-module (test-hexpm)
  #:use-module (guix import hexpm)
  #:use-module (guix base32)
  #:use-module (gcrypt hash)
  #:use-module (guix tests)
  #:use-module (srfi srfi-64)
  #:use-module (ice-9 binary-ports)
  #:use-module (ice-9 match))

(define test-bla-package
  "{\"name\": \"bla\",
    \"html_url\": \"https://hex.pm/packages/bla\",
    \"docs_html_url\": null,
    \"meta\": {
        \"description\": \"A cool package\",
        \"licenses\": [\"MIT\", \"Apache-2.0\"]
    },
    \"releases\": [
        {\"url\": \"https://hex.pm/api/packages/bla/releases/1.5.0\",
         \"version\": \"1.5.0\"},
        {\"url\": \"https://hex.pm/api/packages/bla/releases/1.4.7\",
         \"version\": \"1.4.7\"}
    ]
}")

(define test-bla-release
  "{
   \"version\": \"1.5.0\",
   \"url\": \"https://hex.pm/api/packages/bla/releases/1.5.0\",
   \"requirements\": {
     \"blubb\":{\"app\": \"blubb\",
        \"optional\": false,
        \"requirement\": \"~>0.3\"
         },
     \"fasel\":{\"app\": \"fasel\",
        \"optional\": false,
        \"requirement\": \"~>1.0\"
         }
   },
   \"meta\":{ \"build_tools\":[\"mix\", \"make\", \"rebar3\"] }
 }")

(define test-blubb-package
  "{\"name\": \"blubb\",
    \"latest_stable_version\": \"0.3.1\",
    \"latest_version\": \"0.3.1\",
    \"html_url\": \"https://hex.pm/packages/blubb\",
    \"docs_html_url\": null,
    \"meta\": {
        \"description\": \"Another cool package\",
        \"licenses\": [\"MIT\"]
    },
    \"releases\": [
        {\"url\": \"https://hex.pm/api/packages/blubb/releases/0.3.1\",
         \"version\": \"0.3.1\"},
        {\"url\": \"https://hex.pm/api/packages/blubb/releases/0.3.0\",
         \"version\": \"0.3.0\"}
    ]
}")

(define test-blubb-release
  "{
   \"version\": \"0.3.1\",
   \"url\": \"https://hex.pm/api/packages/blubb/releases/0.3.1\",
   \"requirements\": {
     \"fasel\":{\"app\": \"fasel\",
        \"optional\": false,
        \"requirement\": \"~>1.0\"
         }
   },
   \"meta\": { \"build_tools\":[\"mix\"] }
 }")

(define test-fasel-package
  "{\"name\": \"fasel\",
    \"latest_stable_version\": \"1.2.1\",
    \"latest_version\": \"1.2.1\",
    \"html_url\": \"https://hex.pm/packages/fasel\",
    \"docs_html_url\": null,
    \"meta\": {
        \"description\": \"Yet another cool package\",
        \"licenses\": [\"GPL\"]
    },
    \"releases\": [
        {\"url\": \"https://hex.pm/api/packages/fasel/releases/1.2.1\",
         \"version\": \"1.2.1\"}
    ]
}")

(define test-fasel-release
  "{
   \"version\": \"1.2.1\",
   \"url\": \"https://hex.pm/api/packages/fasel/releases/1.2.1\",
   \"requirements\" :{},
   \"meta\":{ \"build_tools\":[\"make\"] }
 }")

(test-begin "hexpm")

(test-assert "hexpm->guix-package"
  ;; Replace network resources with sample data.
  (mock ((guix http-client) http-fetch
         (lambda (url . rest)
           (match url
             ("https://hex.pm/api/packages/bla"
              (values (open-input-string test-bla-package)
                      (string-length test-bla-package)))
             ("https://hex.pm/api/packages/bla/releases/1.5.0"
              (values (open-input-string test-bla-release)
                      (string-length test-bla-release)))
             (_ (error "http-fetch got unexpected URL: " url)))))
  (mock ((guix build download) url-fetch
         (lambda* (url file-name
                       #:key
                       (mirrors '()) verify-certificate?)
           (with-output-to-file file-name
             (lambda ()
               (display
                (match url
                  ("https://repo.hex.pm/tarballs/bla-1.5.0.tar"
                   "source")
                  (_ (error "url-fetch got unexpected URL: " url))))))))
    (match (hexpm->guix-package "bla")
      (`(package
          (name "erlang-bla")
          (version "1.5.0")
          (source
           (origin
             (method url-fetch)
             (uri (hexpm-uri "bla" version))
             (sha256
              (base32
               "0zcl4dgcmqwl1g5xb901pd6dz61r1xgmac9mqlwvh022paa6gks1"))))
          (build-system rebar-build-system)
          (inputs (list erlang-blubb erlang-fasel))
          (synopsis "A cool package")
          (description "This package provides a cool package.")
          (home-page "https://hex.pm/packages/bla")
          (license (list license:expat license:asl2.0)))
       #t)
      (x
       (pk 'fail x #f))))))

(test-assert "hexpm-recursive-import"
  ;; Replace network resources with sample data.
  (mock ((guix http-client) http-fetch
         (lambda (url . rest)
           (match url
             ("https://hex.pm/api/packages/bla"
              (values (open-input-string test-bla-package)
                      (string-length test-bla-package)))
             ("https://hex.pm/api/packages/bla/releases/1.5.0"
              (values (open-input-string test-bla-release)
                      (string-length test-bla-release)))
             ("https://hex.pm/api/packages/blubb"
              (values (open-input-string test-blubb-package)
                      (string-length test-blubb-package)))
             ("https://hex.pm/api/packages/blubb/releases/0.3.1"
              (values (open-input-string test-blubb-release)
                      (string-length test-blubb-release)))
             ("https://hex.pm/api/packages/fasel"
              (values (open-input-string test-fasel-package)
                      (string-length test-fasel-package)))
             ("https://hex.pm/api/packages/fasel/releases/1.2.1"
              (values (open-input-string test-fasel-release)
                      (string-length test-fasel-release)))
             (_ (error "http-fetch got unexpected URL: " url)))))
  (mock ((guix build download) url-fetch
         (lambda* (url file-name
                       #:key
                       (mirrors '()) verify-certificate?)
           (with-output-to-file file-name
             (lambda ()
               (display
                (match url
                  ("https://repo.hex.pm/tarballs/bla-1.5.0.tar"
                   "bla-source")
                  ("https://repo.hex.pm/tarballs/blubb-0.3.1.tar"
                   "blubb-source")
                  ("https://repo.hex.pm/tarballs/fasel-1.2.1.tar"
                   "fasel-source")
                  (_ (error "url-fetch got unexpected URL: " url))))))))
        (match (hexpm-recursive-import "bla")
          (`((package
               (name "erlang-blubb")
               (version "0.3.1")
               (source
                (origin
                  (method url-fetch)
                  (uri (hexpm-uri "blubb" version))
                  (sha256
                   (base32
                    "17y88b5y8ld7s1c2bcwwwa04pf1cl4402i9zk3inna221ps3ppj2"))))
               (build-system mix-build-system)
               (inputs (list erlang-fasel))
               (synopsis "Another cool package")
               (description "Another cool package.")
               (home-page "https://hex.pm/packages/blubb")
               (license license:expat))
             (package
               (name "erlang-fasel")
               (version "1.2.1")
               (source
                (origin
                  (method url-fetch)
                  (uri (hexpm-uri "fasel" version))
                  (sha256
                   (base32
                    "1k6d70mxwqgq78jrbr7yqnw187yki74jnagybi7nacrj4a67qjha"))))
               (build-system gnu-build-system)
               (synopsis "Yet another cool package")
               (description "Yet another cool package.")
               (home-page "https://hex.pm/packages/fasel")
               (license "GPL"))
             (package
               (name "erlang-bla")
               (version "1.5.0")
               (source
                (origin
                  (method url-fetch)
                  (uri (hexpm-uri "bla" version))
                  (sha256
                   (base32
                    "0d3gj746c4swbb1m6ycylxb239jsavvdcizag6bfbg2aqccxwij8"))))
               (build-system rebar-build-system)
               (inputs (list erlang-blubb erlang-fasel))
               (synopsis "A cool package")
               (description "This package provides a cool package.")
               (home-page "https://hex.pm/packages/bla")
               (license (list license:expat license:asl2.0))))
           #t)
          (x
           (pk 'fail x #f))))))

(test-end "hexpm")
p'>* gnu/bootloader/grub.scm (grub-root-search): Set the root to "(tftp)" if the searched-for file is stored on NFS. Stefan 2020-09-07bootloader: Use "define" instead of "define*" for all records....* gnu/bootloader/grub.scm (grub-minimal-bootloader): Use "define". (grub-efi-bootloader): Use "define". (grub-mkrescue-bootloader): Use "define". Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> Stefan 2020-09-06bootloader: Add comment about grub configuration files....* gnu/bootloader/grub.scm: Add comment about grub configuration files. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> Stefan 2020-06-09bootloader: grub: Fix cross-compilation....This is a follow-up of 536c53d347291dcc75e1073af6e6c5c614e0fff4, that do not use the native version of "font-file", breaking cross-compilation. * gnu/bootloader/grub.scm (eye-candy): Use the native version of "font-file". Mathieu Othacehe 2020-06-09gnu: grub: Support graphical gfxterm on all systems....* gnu/bootloaders/grub.scm (eye-candy): Use gfxterm depending only on (bootloader-configuration (terminal-outputs …)), which defaults to '(gfxterm). This makes the system argument obsolete. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Stefan 2020-06-08bootloader: grub: Add support for multiboot....* gnu/bootloader/grub.scm (grub-configuration-file): Add support for multiboot. Jan (janneke) Nieuwenhuizen 2020-05-29bootloader: grub: Rename the btrfs-subvolume-file-name parameter....Following discussion in <https://issues.guix.gnu.org/37305>, it seems more appropriate to give the parameter a more generic name that better describes what it does. * gnu/bootloader/grub.scm (normalize-file): Rename the BTRFS-SUBVOLUME-FILE-NAME parameter to STORE-DIRECTORY-PREFIX, and always assume this argument to be a string. (eye-candy): Likewise. Default STORE-DIRECTORY-PREFIX to "". (grub-configuration-file): Likewise. * gnu/system.scm (operating-system-bootcfg): Adapt. Maxim Cournoyer 2020-05-29bootloader: grub: Use inheritance to define grub-minimal-bootloader....* gnu/bootloader/grub.scm (grub-minimal-bootloader): Inherit from grub-bootloader to avoid field redefinition. Mathieu Othacehe 2020-05-29bootloader: grub: Do not run grub-install when creating a disk-image....* gnu/bootloader/grub.scm (install-grub): When creating a disk-image, grub-install will fail because it lacks root permissions. In that case, do not run grub-install and only copy Grub modules to the /boot directory. Mathieu Othacehe 2020-05-29bootloader: Add 'disk-image-installer'....* gnu/bootloader.scm (<bootloader>)[disk-image-installer]: New field, (bootloader-disk-image-installer): export it. * gnu/bootloader/grub.scm (install-grub-disk-image): New procedure ... (grub-bootloader): ... used as "disk-image-installer" here. (grub-efi-bootloader): set "disk-image-installer" to #f. * gnu/system/image.scm (root-partition?, find-root-partition): Move to "Helpers" section. (root-partition-index): New procedure. (system-disk-image): Honor disk-image-installer, and use it to install the bootloader directly on the disk-image, if supported. Mathieu Othacehe 2020-05-20bootloader: grub: Allow booting from a Btrfs subvolume....* gnu/bootloader/grub.scm (strip-mount-point): Remove procedure. (normalize-file): Add procedure. (grub-configuration-file): New BTRFS-SUBVOLUME-FILE-NAME parameter. When defined, prepend its value to the kernel and initrd file names, using the NORMALIZE-FILE procedure. Adjust the call to EYE-CANDY to pass the BTRFS-SUBVOLUME-FILE-NAME argument. Normalize the KEYMAP file as well. (eye-candy): Add a BTRFS-SUBVOLUME-FILE-NAME parameter, and use it, along with the NORMALIZE-FILE procedure, to normalize the FONT-FILE and IMAGE nested variables. Adjust doc. * gnu/bootloader/depthcharge.scm (depthcharge-configuration-file): Adapt. * gnu/bootloader/extlinux.scm (extlinux-configuration-file): Likewise. * gnu/system/file-systems.scm (btrfs-subvolume?) (btrfs-store-subvolume-file-name): New procedures. * gnu/system.scm (operating-system-bootcfg): Specify the Btrfs subvolume file name the store resides on to the `operating-system-bootcfg' procedure, using the new BTRFS-SUBVOLUME-FILE-NAME argument. * doc/guix.texi (File Systems): Add a Btrfs subsection to document the use of subvolumes. * gnu/tests/install.scm (%btrfs-root-on-subvolume-os) (%btrfs-root-on-subvolume-os-source) (%btrfs-root-on-subvolume-installation-script) (%test-btrfs-root-on-subvolume-os): New variables. Maxim Cournoyer 2020-05-19gnu: grub: Allow a PNG image and replace "aspect-ratio" with "resolution"....* gnu/bootloaders/grub.scm (<grub-image>): Remove this record and replace it by ... (<grub-theme>)[image]: ... this field with the default from %background-image, (<grub-theme>)[resolution]: ... this field with the defaults from 'width' and 'height' of 'grub-background-image'. (<grub-theme>)[images]: Remove this field. (svg->png): Rename to ... (image->png): ... and use 'copy-file' instead of 'svg->png', if the suffix of the image file is not ".svg". (grub-background-image): Remove the arguments 'width' and 'height'. (grub-theme-image): Add function. (grub-theme-resolution): Add function. (grub-theme-gfxmode): Add function. (grub-image): Remove function. (grub-image?): Remove function. (grub-image-aspect-ratio): Remove function. (grub-image-file): Remove function. (grub-theme-images): Remove function. (%default-theme): Remove variable. (%background-image): Remove variable. Using image formats different to SVG was not possible. For a <grub-image> to be chosen, the 'aspect-ratio' of it had to be 4/3, as the resolution of any image was defaulting to 1024 x 768. There was no code to determine the proper boot-resolution to make any use of a list of images with different aspect-ratios. It seems to be a better solution to only define a single image with any format, and use a given resolution only for the conversion from a SVG file. This also makes the use of a special <grub-image> record unnecessary. Moving the default values from '%background-image' and '%default-theme' into <grub-theme> makes a customisation easier without (inherit) and allows to remove the undocumented variables %background-image' and '%default-theme'. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Stefan 2020-05-16bootloader: grub: Refer to the native 'grub-mklayout' and font file....* gnu/bootloader/grub.scm (eye-candy): Refer to the native FONT-FILE. (keyboard-layout-file): Refer to the native 'grub-mklayout'. Ludovic Courtès 2020-04-08Merge branch 'master' into core-updates... Conflicts: etc/news.scm gnu/local.mk gnu/packages/check.scm gnu/packages/cross-base.scm gnu/packages/gimp.scm gnu/packages/java.scm gnu/packages/mail.scm gnu/packages/sdl.scm gnu/packages/texinfo.scm gnu/packages/tls.scm gnu/packages/version-control.scm Marius Bakke 2020-04-06system: Allow for comma-separated keyboard layouts....Reported by Florian Pelz <pelzflorian@pelzflorian.de>. * gnu/bootloader/grub.scm (keyboard-layout-file): Replace commas with hyphens in the first argument to 'computed-file'. * gnu/system/keyboard.scm (keyboard-layout->console-keymap): Likewise. * doc/guix.texi (Keyboard Layout): Add example. Ludovic Courtès 2020-03-29gnu: bootloader: Add grub-minimal-bootloader....* gnu/bootloader/grub.scm (grub-minimal-bootloader): New variable. Jan Nieuwenhuizen 2020-03-17bootloader: grub: Refactor eye-candy a bit....* gnu/bootloader/grub.scm (eye-candy)[setup-gfxterm-body]: Define the GFXMODE binding using AND-LET* instead of chained AND=>. Add a comment about supporting graphical mode on other systems than x86. Generate configuration string using FORMAT rather than STRING-APPEND. Maxim Cournoyer 2020-03-17bootloader: grub: Use the all_video module in graphic mode....* gnu/bootloader/grub.scm (eye-candy): Load the module 'all_video' which automatically loads all the available and relevant video modules. Maxim Cournoyer 2020-01-25bootloader: grub: Add gfxmode (resolution) override....* gnu/bootloader/grub.scm (<grub-theme>): Add `gfxmode' entry. (eye-candy): Use it. * doc/guix.texi (Bootloader Configuration): Document it. Jan Nieuwenhuizen 2020-01-07Revert "bootloader: grub: Add gfxmode (resolution) override."...This reverts commit a23091880d4dc6115acbfa3b7ef09d731fc5abb0. It causes ‘guix pull’ to fail: <https://paste.debian.net/plain/1125061>. Tobias Geerinckx-Rice 2020-01-07bootloader: grub: Add gfxmode (resolution) override....* gnu/bootloader/grub.scm (<grub-theme>): Add `gfxmode' entry. (eye-candy): Use it. * doc/guix.texi (Bootloader Configuration): Document it. Jan Nieuwenhuizen 2020-01-06Adjust module autoloads....In Guile < 2.9.7, autoloading a module would give you access to all its bindings. In future versions, autoloading a module gives access only to the listed bindings, as per #:select (see <https://bugs.gnu.org/38895>). This commit adjusts autoloads to the new semantics, allowing Guix to be built with Guile 2.9.7/2.9.8. * guix/build/download.scm <top level>: Remove call to 'module-autoload!'. (load-gnutls): New procedure. (tls-wrap): Call it. * guix/git.scm <top level>: Remove call to 'module-autoload!'. (load-git-submodules): New procedure. (update-submodules): Call it instead of 'resolve-interface'. * gnu/bootloader/grub.scm: Replace #:autoload with #:use-module. * gnu/packages.scm: Likewise. * gnu/packages/ssh.scm: Likewise. * gnu/packages/tex.scm: Likewise. * gnu/services/cuirass.scm: Likewise. * gnu/services/mcron.scm: Likewise. * guix/lint.scm: Augment list of bindings in #:autoload. * guix/scripts/build.scm: Likewise. * guix/scripts/gc.scm: Likewise. * guix/scripts/pack.scm: Likewise. * guix/scripts/publish.scm: Likewise. * guix/scripts/pull.scm: Likewise. * guix/utils.scm: Remove unnecessary #:autoload clauses; replace one of them with #:use-module. Ludovic Courtès 2020-01-03bootloader: Mark "grub.cfg" and "extlinux.conf" as non-substitutable....Suggested by <pkill9@runbox.com>. * gnu/bootloader/grub.scm (grub-configuration-file): Pass #:options to 'computed-file'. * gnu/bootloader/extlinux.scm (extlinux-configuration-file): Likewise. Ludovic Courtès 2019-12-23bootloader: grub: Add firmware setup entry....* gnu/bootloader/grub.scm (grub-configuration-file): Add 'Firmware setup' entry for EFI platform. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> Brice Waegeneire 2019-05-09bootloader: grub: Remove unneeded 'terminal_output'....Fixes <https://bugs.gnu.org/35585>. Reported by Florian Pelz <pelzflorian@pelzflorian.de>. This statement was added in 8d058e7b1b1a409d3d9cc29c5650a98db4e78783 but turned out to be unnecessary. * gnu/bootloader/grub.scm (grub-configuration-file): Remove 'terminal_output' statement. Ludovic Courtès 2019-03-24bootloader: Add a 'keyboard-layout' field....* gnu/bootloader/grub.scm (keyboard-layout-file): New procedure. (grub-configuration-file)[keyboard-layout-file]: New variable. [builder]: Use it. * gnu/bootloader.scm (<bootloader-configuration>)[keyboard-layout]: New field. * doc/guix.texi (Bootloader Configuration): Document it. Co-authored-by: nee <nee-git@hidamari.blue> Ludovic Courtès 2019-03-16bootloader: Use 'invoke/quiet' when running 'grub-install' and co....This hides potentially confusing GRUB messages from the user, such as "Installing for i386-pc platform." * gnu/bootloader/extlinux.scm (install-extlinux): Use 'invoke/quiet' instead of 'system*' and 'error'. * gnu/bootloader/grub.scm (install-grub, install-grub-efi): Likewise. * guix/scripts/system.scm (bootloader-installer-script): Guard against 'message-condition?' and handle them properly. Ludovic Courtès 2019-03-13Remove traces of "GuixSD"....* gnu/bootloader/extlinux.scm (extlinux-configuration-file): Remove mentions of "GuixSD". * gnu/bootloader/grub.scm (install-grub-efi): Likewise. * gnu/build/vm.scm (make-iso9660-image): Change default #:volume-id to "Guix_image". (initialize-hard-disk): Search for the "Guix_image" label. * gnu/ci.scm (system-test-jobs, tarball-jobs): Remove "GuixSD". * gnu/installer/newt/welcome.scm (run-welcome-page): Likewise. * gnu/packages/audio.scm (supercollider)[description]: Likewise. * gnu/packages/curl.scm (curl): Likewise. * gnu/packages/emacs.scm (emacs): Likewise. * gnu/packages/gnome.scm (network-manager): Likewise. * gnu/packages/julia.scm (julia): Likewise. * gnu/packages/linux.scm (alsa-plugins): Likewise. (powertop, wireless-regdb): Likewise. * gnu/packages/package-management.scm (guix): Likewise. * gnu/packages/polkit.scm (polkit): Likewise. * gnu/packages/tex.scm (texlive-bin): Likewise. * gnu/services/base.scm (file-systems->fstab): Likewise. * gnu/services/cups.scm (%cups-activation): Likewise. * gnu/services/mail.scm (%dovecot-activation): Likewise. * gnu/services/messaging.scm (prosody-configuration)[log]: Likewise. * gnu/system/examples/vm-image.tmpl (vm-image-motd): Likewise. * gnu/system/install.scm (installation-os)[file-systems]: Change root file system label to "Guix_image". * gnu/system/mapped-devices.scm (check-device-initrd-modules): Remove "GuixSD". * gnu/system/vm.scm (system-docker-image): Likewise. (system-disk-image)[root-label]: Change to "Guix_image". * gnu/tests/install.scm (run-install): Remove "GuixSD". * guix/modules.scm (guix-module-name?): Likewise. * nix/libstore/optimise-store.cc: Likewise. Ludovic Courtès