;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012-2016, 2018-2022 Ludovic Courtès ;;; ;;; 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 . (define-module (test-records) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (guix records)) (define (test-module) ;; A module in which to evaluate things that are known to fail. (let ((module (make-fresh-user-module))) (module-use! module (resolve-interface '(guix records))) module)) (define (location-alist loc) ;; Return a location alist. In Guile < 3.0.6, LOC is always an alist, but ;; starting with 3.0.6, LOC is a vector (at least when it comes from ;; 'syntax-error' exceptions), hence this conversion. (match loc (#(file line column) `((line . ,line) (column . ,column) (filename . ,file))) (_ loc))) (test-begin "records") (test-assert "define-record-type*" (begin (define-record-type* foo make-foo foo? (bar foo-bar) (baz foo-baz (default (+ 40 2)))) (and (match (foo (bar 1) (baz 2)) (($ 1 2) #t)) (match (foo (baz 2) (bar 1)) (($ 1 2) #t)) (match (foo (bar 1)) (($ 1 42) #t))))) (test-assert "define-record-typ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2014, 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2014 Kevin Lemonnier <lemonnierk@ulrar.net> ;;; Copyright © 2015 Jeff Mickey <j@codemac.net> ;;; Copyright © 2016–2021 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2016 Stefan Reichör <stefan@xsteve.at> ;;; Copyright © 2017, 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2017, 2018 Nikita <nikita@n0.is> ;;; Copyright © 2017, 2018 Leo Famulari <leo@famulari.name> ;;; Copyright © 2017, 2021 Arun Isaac <arunisaac@systemreboot.net> ;;; Copyright © 2019 Meiyo Peng <meiyo.peng@gmail.com> ;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com> ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2019, 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020 Ryan Prior <rprior@protonmail.com> ;;; Copyright © 2020, 2022, 2024 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org> ;;; Copyright © 2021, 2022 Nicolas Goaziou <mail@nicolasgoaziou.fr> ;;; Copyright © 2021, 2022 Felix Gruber <felgru@posteo.net> ;;; Copyright © 2022 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2023 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2023 David Pflug <david@pflug.io> ;;; Copyright © 2023 Jaeme Sifat <jaeme@runbox.com> ;;; Copyright © 2024 Tanguy Le Carrour <tanguy@bioneland.org> ;;; Copyright © 2024 Vinicius Monego <monego@posteo.net> ;;; Copyright © 2024 Luís Henriques <henrix@camandro.org> ;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org> ;;; ;;; 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 (gnu packages shells) #:use-module (gnu packages) #:use-module (gnu packages autotools) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages bison) #:use-module (gnu packages check) #:use-module (gnu packages compression) #:use-module (gnu packages crypto) #:use-module (gnu packages curl) #:use-module (gnu packages documentation) #:use-module (gnu packages groff) #:use-module (gnu packages guile) #:use-module (gnu packages libbsd) #:use-module (gnu packages libedit) #:use-module (gnu packages linux) #:use-module (gnu packages ncurses) #:use-module (gnu packages pcre) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-build) #:use-module (gnu packages python-check) #:use-module (gnu packages python-web) #:use-module (gnu packages python-xyz) #:use-module (gnu packages readline) #:use-module (gnu packages scheme) #:use-module (gnu packages terminals) #:use-module (gnu packages version-control) #:use-module (gnu packages xdisorg) #:use-module (gnu packages xorg) #:use-module (gnu packages texinfo) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) #:use-module (guix build-system meson) #:use-module (guix build-system pyproject) #:use-module (guix build-system python) #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix gexp) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix utils)) (define-public dash (package (name "dash") (version "0.5.12") (source (origin (method url-fetch) (uri (string-append "http://gondor.apana.org.au/~herbert/dash/files/" "dash-" version ".tar.gz")) (sha256 (base32 "12pjm2j0q0q88nvqbcyqjwr8s1c29ilxyq2cdj8k42wbdv24liva")) (modules '((guix build utils))) (snippet '(begin ;; The man page hails from BSD, where (d)ash is the default shell. ;; This isn't the case on Guix or indeed most other GNU systems. (substitute* "src/dash.1" (("the standard command interpreter for the system") "a command interpreter based on the original Bourne shell")))))) (build-system gnu-build-system) (inputs (list libedit)) (arguments '(#:configure-flags '("--with-libedit"))) (home-page "http://gondor.apana.org.au/~herbert/dash") (synopsis "POSIX-compliant shell optimised for size") (description "Dash is a POSIX-compliant @command{/bin/sh} implementation that aims to be as small as possible, often without sacrificing speed. It is faster than the GNU Bourne-Again Shell (@command{bash}) at most scripted tasks. Dash is a direct descendant of NetBSD's Almquist Shell (@command{ash}).") (license (list license:bsd-3 license:gpl2+)))) ; mksignames.c (define-public fish (package (name "fish") (version "3.7.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/fish-shell/fish-shell/" "releases/download/" version "/" "fish-" version ".tar.xz")) (sha256 (base32 "0l5jlg0vplqln7ijqwirp1xl4j9npimzm58k77grj1yd8db9yk31")))) (build-system cmake-build-system) (inputs (list fish-foreign-env ncurses pcre2 python)) ; for fish_config and manpage completions (native-inputs (list doxygen groff ; for 'fish --help' procps)) ; for the test suite (arguments '(#:phases (modify-phases %standard-phases (add-after 'unpack 'set-env (lambda _ ;; some tests write to $HOME (setenv "HOME" (getcwd)) #t)) (add-after 'unpack 'patch-tests (lambda* (#:key inputs #:allow-other-keys) (let ((coreutils (assoc-ref inputs "coreutils")) (bash (assoc-ref inputs "bash"))) ;; This test sporadically fails in the build container ;; because of leftover zombie processes, which are not ;; reaped automatically: ;; "Found existing zombie processes. Clean up zombies before running this test." ;; Disabling parallel tests does not reliably prevent it. (delete-file "tests/checks/jobs.fish") ;; This test fails. (delete-file "tests/checks/pipeline-pgroup.fish") ;; This one tries to open a terminal & can't simply be deleted. (substitute* "cmake/Tests.cmake" ((".* interactive\\.fish.*") "")) ;; This one needs to chdir successfully. (substitute* "tests/checks/vars_as_commands.fish" (("/usr/bin") "/tmp")) ;; These contain absolute path references. (substitute* "src/fish_tests.cpp" (("/bin/echo" echo) (string-append coreutils echo)) (("/bin/ca" ca) (string-append coreutils ca)) (("\"(/bin/c)\"" _ c) (string-append "\"" coreutils c "\"")) (("/bin/ls_not_a_path" ls-not-a-path) (string-append coreutils ls-not-a-path)) (("/bin/ls" ls) (string-append coreutils ls)) (("(/bin/)\"" _ bin) (string-append coreutils bin "\"")) (("/bin -" bin) (string-append coreutils bin)) (((string-append "do_test\\(is_potential_path\\(" "L\"/usr\", wds, vars, PATH_REQUIRE_DIR\\)\\);")) "") ;; Not all mentions of /usr... need to exist, but these do. (("\"/usr(|/lib)\"" _ subdirectory) (string-append "\"/tmp" subdirectory "\""))) (substitute* (append (find-files "tests" ".*\\.(in|out|err)$") (find-files "tests/checks" ".*\\.fish")) (("/bin/pwd" pwd) (string-append coreutils pwd)) (("/bin/echo" echo) (string-append coreutils echo)) (("/bin/sh" sh) (string-append bash sh)) (("/bin/ls" ls) (string-append coreutils ls))) (substitute* (find-files "tests" ".*\\.(in|out|err)$") (("/usr/bin") (string-append coreutils "/bin"))) #t))) ;; Source /etc/fish/config.fish from $__fish_sysconf_dir/config.fish. (add-after 'patch-tests 'patch-fish-config (lambda _ (let ((port (open-file "etc/config.fish" "a"))) (display (string-append "\n\n" "# Patched by Guix.\n" "# Source /etc/fish/config.fish.\n" "if test -f /etc/fish/config.fish\n" " source /etc/fish/config.fish\n" "end\n") port) (close-port port)) #t)) ;; Embed absolute paths. (add-before 'install 'embed-absolute-paths (lambda _ (substitute* "share/functions/__fish_print_help.fish" (("nroff") (which "nroff"))) #t)) ;; Enable completions, functions and configurations in user's and ;; system's guix profiles by adding them to __extra_* variables. (add-before 'install 'patch-fish-extra-paths (lambda _ (let ((port (open-file "share/__fish_build_paths.fish" "a"))) (display (string-append "\n\n" "# Patched by Guix.\n" "# Enable completions, functions and configurations in user's" " and system's guix profiles by adding them to __extra_*" " variables.\n" "set -l __guix_profile_paths ~/.guix-profile" " /run/current-system/profile\n" "set __extra_completionsdir" " $__guix_profile_paths\"/etc/fish/completions\"" " $__guix_profile_paths\"/share/fish/vendor_completions.d\"" " $__extra_completionsdir\n" "set __extra_functionsdir" " $__guix_profile_paths\"/etc/fish/functions\"" " $__guix_profile_paths\"/share/fish/vendor_functions.d\"" " $__extra_functionsdir\n" "set __extra_confdir" " $__guix_profile_paths\"/etc/fish/conf.d\"" " $__guix_profile_paths\"/share/fish/vendor_conf.d\"" " $__extra_confdir\n") port) (close-port port)) #t)) ;; Use fish-foreign-env to source /etc/profile. (add-before 'install 'source-etc-profile (lambda* (#:key inputs #:allow-other-keys) (let ((port (open-file "share/__fish_build_paths.fish" "a"))) (display (string-append "\n\n" "# Patched by Guix.\n" "# Use fish-foreign-env to source /etc/profile.\n" "if status is-login\n" " set fish_function_path " (assoc-ref inputs "fish-foreign-env") "/share/fish/functions" " $__fish_datadir/functions\n" " fenv source /etc/profile\n" " set -e fish_function_path\n" "end\n") port) (close-port port)) #t))))) (synopsis "The friendly interactive shell") (description "Fish (friendly interactive shell) is a shell focused on interactive use, discoverability, and friendliness. Fish has very user-friendly and powerful tab-completion, including descriptions of every completion, completion of strings with wildcards, and many completions for specific commands. It also has extensive and discoverable help. A special @command{help} command gives access to all the fish documentation in your web browser. Other features include smart terminal handling based on terminfo, an easy to search history, and syntax highlighting.") (home-page "https://fishshell.com/") (license license:gpl2))) (define-public fish-foreign-env (package (name "fish-foreign-env") (version "0.20230823") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/oh-my-fish/plugin-foreign-env") (commit "7f0cf099ae1e1e4ab38f46350ed6757d54471de7"))) (file-name (git-file-name name version)) (sha256 (base32 "0d16mdgjdwln41zk44qa5vcilmlia4w15r8z2rc3p49i5ankksg3")))) (build-system trivial-build-system) (arguments '(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let* ((source (assoc-ref %build-inputs "source")) (out (assoc-ref %outputs "out")) (func-path (string-append out "/share/fish/functions"))) (mkdir-p func-path) (copy-recursively (string-append source "/functions") func-path) ;; Embed absolute paths. (substitute* `(,(string-append func-path "/fenv.fish") ,(string-append func-path "/fenv.main.fish")) (("bash") (search-input-file %build-inputs "/bin/bash")) (("sed") (search-input-file %build-inputs "/bin/sed")) ((" tr ") (string-append " " (search-input-file %build-inputs "/bin/tr") " "))))))) (inputs (list bash coreutils sed)) (home-page "https://github.com/oh-my-fish/plugin-foreign-env") (synopsis "Foreign environment interface for fish shell") (description "@code{fish-foreign-env} wraps bash script execution in a way that environment variables that are exported or modified get imported back into fish.") (license license:expat))) (define-public rc (package (name "rc") (version "1.7.4") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/rakitzis/rc") (commit (string-append "v" version)))) (sha256 (base32 "0vj1h4pcg13vxsiydmmk87dr2sra9h4gwx0c4q6fjsiw4in78rrd")) (file-name (git-file-name name version)))) (build-system gnu-build-system) (arguments `(#:configure-flags '("--with-edit=gnu") #:phases (modify-phases %standard-phases (add-before 'bootstrap 'patch-trip.rc (lambda _ (substitute* "trip.rc" (("/bin/pwd") (which "pwd")) (("/bin/sh") (which "sh")) (("/bin/rm") (which "rm")) (("/bin\\)") (string-append (dirname (which "rm")) ")"))) #t))))) (inputs (list readlin