aboutsummaryrefslogtreecommitdiff
path: root/gnu/system/linux-container.scm
blob: 2ab679ff3f1ae571be10647de865a142aeb0c4bd (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; 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 system linux-container)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)
  #:use-module (guix config)
  #:use-module (guix store)
  #:use-module (guix gexp)
  #:use-module (guix derivations)
  #:use-module (guix monads)
  #:use-module (guix modules)
  #:use-module (gnu build linux-container)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services networking)
  #:use-module (gnu services shepherd)
  #:use-module (gnu system)
  #:use-module (gnu system file-systems)
  #:export (system-container
            containerized-operating-system
            container-script
            eval/container))

(define* (container-essential-services os #:key shared-network?)
  "Return a list of essential services corresponding to OS, a
non-containerized OS.  This procedure essentially strips essential services
from OS that are needed on the bare metal and not in a container."
  (define base
    (remove (lambda (service)
              (memq (service-kind service)
                    (list (service-kind %linux-bare-metal-service)
                          firmware-service-type
                          system-service-type)))
            (operating-system-default-essential-services os)))

  (cons (service system-service-type
                 (let ((locale (operating-system-locale-directory os)))
                   (with-monad %store-monad
                     (return `(("locale" ,locale))))))
        ;; If network is to be shared with the host, remove network
        ;; configuration files from etc-service.
        (if shared-network?
            (modify-services base
              (etc-service-type
               files => (remove
                         (match-lambda
                           ((filename _)
                            (member filename
                                    (map basename %network-configuration-files))))
                         files)))
            base)))

(define dummy-networking-service-type
  (shepherd-service-type
   'dummy-networking
   (const (shepherd-service
           (documentation "Provide loopback and networking without actually
doing anything.")
           (provision '(loopback networking))
           (start #~(const #t))))
   #f))

(define* (containerized-operating-system os mappings
                                         #:key
                                         shared-network?
                                         (extra-file-systems '()))
  "Return an operating system based on OS for use in a Linux container
environment.  MAPPINGS is a list of <file-system-mapping> to realize in the
containerized OS.  EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
  (define user-file-systems
    (remove (lambda (fs)
              (let ((target (file-system-mount-point fs))
                    (source (file-system-device fs)))
                (or (string=? target (%store-prefix))
                    (string=? target "/")
                    (and (string? source)
                         (string-prefix? "/dev/" source))
                    (string-prefix? "/dev/" target)
                    (string-prefix? "/sys/" target))))
            (operating-system-file-systems os)))

  (define (mapping->fs fs)
    (file-system (inherit (file-system-mapping->bind-mount fs))
      (needed-for-boot? #t)))

  (define useless-services
    ;; Services that make no sense in a container.  Those that attempt to
    ;; access /dev/tty[0-9] in particular cannot work in a container.
    (append (list console-font-service-type
                  mingetty-service-type
                  agetty-service-type)
            ;; Remove nscd service if network is shared with the host.
            (if shared-network?
                (list nscd-service-type
                      static-networking-service-type
                      dhcp-client-service-type
                      network-manager-service-type
                      connman-service-type
                      wicd-service-type)
                (list))))

  (operating-system
    (inherit os)
    (swap-devices '()) ; disable swap
    (essential-services (container-essential-services
                         this-operating-system
                         #:shared-network? shared-network?))
    (services (append (remove (lambda (service)
                                (memq (service-kind service)
                                      useless-services))
                              (operating-system-user-services os))
                      ;; Many Guix services depend on a 'networking' shepherd
                      ;; service, so make sure to provide a dummy 'networking'
                      ;; service when we are sure that networking is already set up
                      ;; in the host and can be used.  That prevents double setup.
                      (if shared-network?
                          (list (service dummy-networking-service-type))
                          '())))
    (file-systems (append (map mapping->fs
                               (if shared-network?
                                   (append %network-file-mappings mappings)
                                   mappings))
                          extra-file-systems
                          user-file-systems

                          ;; Provide a dummy root file system so we can create
                          ;; a 'boot-parameters' file.
                          (list (file-system
                                  (mount-point "/")
                                  (device "nothing")
                                  (type "dummy")))))))

(define* (container-script os #:key (mappings '()) shared-network?)
  "Return a derivation of a script that runs OS as a Linux container.
MAPPINGS is a list of <file-system> objects that specify the files/directories
that will be shared with the host system."
  (define (mountable-file-system? file-system)
    ;; Return #t if FILE-SYSTEM should be mounted in the container.
    (and (not (string=? "/" (file-system-mount-point file-system)))
         (file-system-needed-for-boot? file-system)))

  (define (os-file-system-specs os)
    (map file-system->spec
         (filter mountable-file-system?
                 (operating-system-file-systems os))))

  (let* ((os (containerized-operating-system
              os (cons %store-mapping mappings)
              #:shared-network? shared-network?
              #:extra-file-systems %container-file-systems))
         (specs (os-file-system-specs os)))

    (define script
      (with-imported-modules (source-module-closure
                              '((guix build utils)
                                (gnu build linux-container)
                                (guix i18n)
                                (guix diagnostics)))
        #~(begin
            (use-modules (gnu build linux-container)
                         (gnu system file-systems) ;spec->file-system
                         (guix build utils)
                         (guix i18n)
                         (guix diagnostics)
                         (srfi srfi-1))

            (define file-systems
              (filter-map (lambda (spec)
                            (let* ((fs    (spec->file-system spec))
                                   (flags (file-system-flags fs)))
                              (and (or (not (memq 'bind-mount flags))
                                       (file-exists? (file-system-device fs)))
                                   fs)))
                          '#$specs))

            (define (explain pid)
              ;; XXX: We can't quite call 'bindtextdomain' so there's actually
              ;; no i18n.
              (info (G_ "system container is running as PID ~a~%") pid)
              ;; XXX: Should we recommend 'guix container exec'?  It's more
              ;; verbose and doesn't bring much.
              (info (G_ "Run 'sudo nsenter -a -t ~a' to get a shell into it.~%")
                    pid)
              (newline (guix-warning-port)))

            (call-with-container file-systems
              (lambda ()
                (setenv "HOME" "/root")
                (setenv "TMPDIR" "/tmp")
                (setenv "GUIX_NEW_SYSTEM" #$os)
                (for-each mkdir-p '("/run" "/bin" "/etc" "/home" "/var"))
                (primitive-load (string-append #$os "/boot")))
              ;; A range of 65536 uid/gids is used to cover 16 bits worth of
              ;; users and groups, which is sufficient for most cases.
              ;;
              ;; See: http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html#--private-users=
              #:host-uids 65536
              #:namespaces (if #$shared-network?
                               (delq 'net %namespaces)
                               %namespaces)
              #:process-spawned-hook explain))))

    (gexp->script "run-container" script)))

(define* (eval/container exp
                         #:key
                         (mappings '())
                         (namespaces %namespaces))
  "Evaluate EXP, a gexp, in a new process executing in separate namespaces as
listed in NAMESPACES.  Add MAPPINGS, a list of <file-system-mapping>, to the
set of directories visible in the process's mount namespace.  Return the
process' exit status as a monadic value.

This is useful to implement processes that, unlike derivations, are not
entirely pure and need to access the outside world or to perform side
effects."
  (mlet %store-monad ((lowered (lower-gexp exp)))
    (define inputs
      (cons (lowered-gexp-guile lowered)
            (lowered-gexp-inputs lowered)))

    (define items
      (append (append-map derivation-input-output-paths inputs)
              (lowered-gexp-sources lowered)))

    (mbegin %store-monad
      (built-derivations inputs)
      (mlet %store-monad ((closure ((store-lift requisites) items)))
        (return (call-with-container (map file-system-mapping->bind-mount
                                          (append (map (lambda (item)
                                                         (file-system-mapping
                                                          (source item)
                                                          (target source)))
                                                       closure)
                                                  mappings))
                  (lambda ()
                    (apply execl
                           (string-append (derivation-input-output-path
                                           (lowered-gexp-guile lowered))
                                          "/bin/guile")
                           "guile"
                           (append (append-map (lambda (directory)
                                                 `("-L" ,directory))
                                               (lowered-gexp-load-path lowered))
                                   (append-map (lambda (directory)
                                                 `("-C" ,directory))
                                               (lowered-gexp-load-compiled-path
                                                lowered))
                                   (list "-c"
                                         (object->string
                                          (lowered-gexp-sexp lowered))))))))))))
hare "/zsh/site-functions/")) (fish-completion-dir (string-append share "/fish/vendor_completions.d/")) (elvish-completion-dir (string-append share "/elvish/lib"))) ;; Make the directories (mkdir-p bash-completion-dir) (mkdir-p zsh-completion-dir) (mkdir-p fish-completion-dir) (mkdir-p elvish-completion-dir) ;; Use the built starship to generate the completions. (with-output-to-file (string-append bash-completion-dir "/starship") (lambda _ (invoke starship-bin "completions" "bash"))) (with-output-to-file (string-append zsh-completion-dir "/_starship") (lambda _(invoke starship-bin "completions" "zsh"))) (with-output-to-file (string-append fish-completion-dir "/starship.fish") (lambda _ (invoke starship-bin "completions" "fish"))) (with-output-to-file (string-append elvish-completion-dir "/starship") (lambda _ (invoke starship-bin "completions" "elvish")))))) ;; Some tests require a writable home directory (add-after 'unpack 'patch-test-shell (lambda* (#:key inputs #:allow-other-keys) ;; search through the rust files and then replace `/bin/sh' ;; with the path to the `/bin/sh' in the drv inputs (let ((rust-files (find-files "." "\\.rs$"))) (for-each (lambda (file) (substitute* file (("/bin/sh") (search-input-file inputs "/bin/sh")))) rust-files)))) ;; Set "HOME" to be located inside the cwd so it is writable ;; for tests checking for user-configs (add-before 'check 'set-test-env-vars (lambda _ (setenv "HOME" (string-append (getcwd) "/.test-home"))))) #:cargo-inputs `(("rust-chrono" ,rust-chrono-0.4) ("rust-clap" ,rust-clap-4) ("rust-clap-complete" ,rust-clap-complete-4) ("rust-deelevate" ,rust-deelevate-0.2) ("rust-dirs" ,rust-dirs-5) ("rust-dunce" ,rust-dunce-1) ("rust-gix" ,rust-gix-0.66) ("rust-gix-features" ,rust-gix-features-0.38) ("rust-guess-host-triple" ,rust-guess-host-triple-0.1) ("rust-home" ,rust-home-0.5) ("rust-indexmap" ,rust-indexmap-2) ("rust-log" ,rust-log-0.4) ("rust-nix" ,rust-nix-0.29) ("rust-notify-rust" ,rust-notify-rust-4) ("rust-nu-ansi-term" ,rust-nu-ansi-term-0.50) ("rust-open" ,rust-open-5) ("rust-os-info" ,rust-os-info-3) ("rust-path-slash" ,rust-path-slash-0.2) ("rust-pest" ,rust-pest-2) ("rust-pest-derive" ,rust-pest-derive-2) ("rust-process-control" ,rust-process-control-5) ("rust-quick-xml" ,rust-quick-xml-0.36) ("rust-rand" ,rust-rand-0.8) ("rust-rayon" ,rust-rayon-1) ("rust-regex" ,rust-regex-1) ("rust-rust-ini" ,rust-rust-ini-0.21) ("rust-schemars" ,rust-schemars-0.8) ("rust-semver" ,rust-semver-1) ("rust-serde" ,rust-serde-1) ("rust-serde-json" ,rust-serde-json-1) ("rust-sha1" ,rust-sha1-0.10) ("rust-shadow-rs" ,rust-shadow-rs-0.35) ("rust-shell-words" ,rust-shell-words-1) ("rust-starship-battery" ,rust-starship-battery-0.10) ("rust-strsim" ,rust-strsim-0.11) ("rust-systemstat" ,rust-systemstat-0.2) ("rust-terminal-size" ,rust-terminal-size-0.4) ("rust-toml" ,rust-toml-0.8) ("rust-toml-edit" ,rust-toml-edit-0.22) ("rust-unicode-segmentation" ,rust-unicode-segmentation-1) ("rust-unicode-width" ,rust-unicode-width-0.2) ("rust-urlencoding" ,rust-urlencoding-2) ("rust-versions" ,rust-versions-6) ("rust-which" ,rust-which-6) ("rust-whoami" ,rust-whoami-1) ("rust-windows" ,rust-windows-0.58) ("rust-winres" ,rust-winres-0.1) ("rust-yaml-rust2" ,rust-yaml-rust2-0.9)) #:cargo-development-inputs `(("rust-mockall" ,rust-mockall-0.13) ("rust-tempfile" ,rust-tempfile-3)))) (inputs (list cmake-minimal)) (native-inputs (append (if (%current-target-system) (list this-package) '()) (list git-minimal))) (home-page "https://starship.rs") (synopsis "The minimal, blazing-fast, and infinitely customizable prompt for any shell!") (description "This package provides The minimal, blazing-fast, and infinitely customizable prompt for any shell! @itemize @item Fast: it's fast - *really really* fast :rocket: @item Customizable: configure every aspect of your prompt @item Universal: works on any shell, on any operating system @item Intelligent: shows relevant information at a glance @item Feature rich: support for all your favorite tools @item Easy: quick to install - start using it in minutes @end itemize Note: users must have a nerd font installed and enabled in their terminal") (license license:isc))) (define-public envstore (package (name "envstore") (version "2.1") (source (origin (method url-fetch) (uri (string-append "https://finalrewind.org/projects/" name "/" name "-" version ".tar.bz2")) (sha256 (base32 "1x97lxad80m5blhdfanl5v2qzjwcgbij2i23701bn8mpyxsrqszi")))) (build-system gnu-build-system) (arguments `(#:test-target "test" #:make-flags (list "CC=gcc" (string-append "PREFIX=" (assoc-ref %outputs "out"))) #:phases (modify-phases %standard-phases (delete 'configure)))) (home-page "https://finalrewind.org/projects/envstore/") (synopsis "Save and restore environment variables") (description "Envstore is a program for sharing environment variables between various shells or commands.") (license license:wtfpl2))) (define-public trash-cli (package (name "trash-cli") (version "0.22.10.20") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/andreafrancia/trash-cli") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0hkn0hmwrag56g447ddqapib0s399a6b4a9wlliif6zmirxlww9n")))) (build-system python-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (add-before 'build 'patch-path-constants (lambda* (#:key inputs #:allow-other-keys) (let ((libc (search-input-file inputs "lib/libc.so.6")) (df #$(file-append coreutils "/bin/df"))) (substitute* "trashcli/list_mount_points.py" (("\"/lib/libc.so.6\".*") (string-append "\"" libc "\"\n")) (("\"df\"") (string-append "\"" df "\"")))))) (add-before 'build 'fix-setup.py (lambda* (#:key outputs #:allow-other-keys) (let ((bin (string-append #$output "/bin"))) (mkdir-p bin) (substitute* "setup.py" (("add_script\\('") (string-append "add_script('" bin "/" )))))) ;; Whenever setup.py is invoked, scripts in out/bin/ are ;; replaced. Thus we cannot invoke setup.py for testing. ;; Upstream also uses pytest. (replace 'check (lambda* (#:key tests? #:allow-other-keys) (when tests? (invoke "pytest"))))))) (native-inputs (list python-pytest python-parameterized python-flexmock python-mock python-six)) (inputs (list coreutils)) (propagated-inputs (list python-psutil)) (home-page "https://github.com/andreafrancia/trash-cli") (synopsis "Trash can management tool") (description "trash-cli is a command line utility for interacting with the FreeDesktop.org trash can used by GNOME, KDE, XFCE, and other common desktop environments. It can move files to the trash, and remove or list files that are already there.") (license license:gpl2+))) (define-public tran ;; There is no new release yet, but there are some changes in master brunch, ;; see <https://github.com/kilobyte/tran/issues/4>. (let ((commit "039df9529d5dfb8283edfb3c8b3cc16c01f0bfce") (revision "0")) (package (name "tran") ;; The latest upstream version seems to be "v5". (version (git-version "5.0.0" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/kilobyte/tran") (commit commit))) (file-name (string-append name "-" version "-checkout")) (sha256 (base32 "1kzr3lfhi5f8wpwjzrzlwkxjv9rasdr9ndjdns9kd16vsh0gl2rd")))) (build-system gnu-build-system) (arguments (list #:tests? #f ;no tests #:phases #~(modify-phases %standard-phases (delete 'configure) ;no configure provided (add-after 'unpack 'patch (lambda _ (substitute* "tran" (("my \\$DATA=\"data\"") (format #f "my $DATA=\"~a/share/tran/data\"" #$output))))) (replace 'build (lambda _ (invoke "make"))) (delete 'strip) (replace 'install (lambda _ (install-file "tran" (string-append #$output "/bin/")) (install-file "tran.1" (string-append #$output "/share/man/man1/")) (copy-recursively "data" (string-append #$output "/share/tran/data/"))))))) (inputs (list perl)) (home-page "https://github.com/kilobyte/tran") (synopsis "Transcription between character scripts") (description "This tool can transliterate/transcribe text both ways between the Latin script and other languages.") (license license:expat)))) (define-public direnv (package (name "direnv") (version "2.35.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/direnv/direnv") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0l9pziv5nxlq6dxbsqrfl6z4ibq171wfx6wmjs392cdn5w2n908b")))) (build-system go-build-system) (arguments '(#:import-path "github.com/direnv/direnv" #:phases (modify-phases %standard-phases (add-after 'install 'install-manpages (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (man (string-append out "/share/man/man1"))) (mkdir-p man) (with-directory-excursion "src/github.com/direnv/direnv" (install-file "man/direnv.1" man) (install-file "man/direnv-stdlib.1" man) (install-file "man/direnv.toml.1" man))))) (replace 'check (lambda* (#:key tests? #:allow-other-keys) (when tests? (setenv "HOME" "/tmp") (with-directory-excursion "src/github.com/direnv/direnv" ;; The following file needs to be writable so it can be ;; modified by the testsuite. (make-file-writable "test/scenarios/base/.envrc") ;; We need to manually run test because make test ;; tries to use go modules (invoke "go" "test" "./...") ;; Clean up from the tests, especially so that the extra ;; direnv executable that's generated is removed. (invoke "make" "clean")))))))) (native-inputs (list go-github-com-burntsushi-toml go-github-com-mattn-go-isatty go-golang-org-x-mod which)) (home-page "https://direnv.net/") (synopsis "Environment switcher for the shell") (description "direnv can hook into the bash, zsh, tcsh, and fish shells to load or unload environment variables depending on the current directory. This allows project-specific environment variables without using @file{~/.profile}. Before each prompt, direnv checks for the existence of a @file{.envrc} file in the current and parent directories. This file is then used to alter the environment variables of the current shell.") (license license:expat))) (define-public fzy (package (name "fzy") (version "1.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/jhawthorn/fzy") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1gkzdvj73f71388jvym47075l9zw61v6l8wdv2lnc0mns6dxig0k")))) (build-system gnu-build-system) (arguments (list #:make-flags #~(list (string-append "CC=" #$(cc-for-target)) (string-append "PREFIX=" #$output)) #:phases #~(modify-phases %standard-phases (delete 'configure)))) (home-page "https://github.com/jhawthorn/fzy") (synopsis "Fast fuzzy text selector for the terminal with an advanced scoring algorithm") (description "Most other fuzzy matchers sort based on the length of a match. fzy tries to find the result the user intended. It does this by favouring matches on consecutive letters and starts of words. This allows matching using acronyms or different parts of the path. fzy is designed to be used both as an editor plugin and on the command line. Rather than clearing the screen, fzy displays its interface directly below the current cursor position, scrolling the screen if necessary.") (license license:expat))) (define-public hstr (package (name "hstr") (version "3.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/dvorka/hstr") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1w1xr0ddf34i46b8wwz2snf7ap6m0mv53zid3d1l5hc4m3az5qis")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-before 'build 'adjust-ncurses-includes (lambda* (#:key make-flags outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (substitute* "src/include/hstr_curses.h" (("ncursesw\\/curses.h") "ncurses.h")) (substitute* "src/include/hstr.h" (("ncursesw\\/curses.h") "ncurses.h"))) #t))))) (native-inputs (list autoconf automake pkg-config)) (inputs (list ncurses readline)) (synopsis "Navigate and search command history with shell history suggest box") (description "HSTR (HiSToRy) is a command-line utility that brings improved Bash and Zsh command completion from the history. It aims to make completion easier and more efficient than with @kbd{Ctrl-R}. It allows you to easily view, navigate, and search your command history with suggestion boxes. HSTR can also manage your command history (for instance you can remove commands that are obsolete or contain a piece of sensitive information) or bookmark your favourite commands.") (home-page "https://me.mindforger.com/projects/hh.html") (license license:asl2.0))) (define-public shell-functools (package (name "shell-functools") (version "0.3.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/sharkdp/shell-functools") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0d6zzg7cxfrzwzh1wmpj7q85kz33sak6ac59ncsm6dlbin12h0hi")))) (build-system python-build-system) (home-page "https://github.com/sharkdp/shell-functools/") (synopsis "Functional programming tools for the shell") (description "This package provides higher order functions like map, filter, foldl, sort_by and take_while as simple command-line tools. Following the UNIX philosophy, these commands are designed to be composed via pipes. A large collection of functions such as basename, replace, contains or is_dir are provided as arguments to these commands.") (license license:expat))) (define-public rig (package (name "rig") (version "1.11") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/rig/rig/" version "/rig-" version ".tar.gz")) (sha256 (base32 "1f3snysjqqlpk2kgvm5p2icrj4lsdymccmn3igkc2f60smqckgq0")))) (build-system gnu-build-system) (arguments `(#:make-flags (list (string-append "CXX=" ,(cxx-for-target)) (string-append "PREFIX=" %output)) #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'fix-build (lambda _ (substitute* "rig.cc" (("^#include <string>") "#include <cstring>")) (substitute* "Makefile" (("g\\+\\+") "${CXX} -O2") (("install -g 0 -m 755 -o 0 -s rig \\$\\(BINDIR\\)") "install -m 755 -d $(DESTDIR)$(BINDIR)\n\t\ install -m 755 rig $(DESTDIR)$(BINDIR)/rig") (("install -g 0 -m 644 -o 0 rig.6 \\$\\(MANDIR\\)/man6/rig.6") "install -m 755 -d $(DESTDIR)$(MANDIR)/man6/\n\t\ install -m 644 rig.6 $(DESTDIR)$(MANDIR)/man6/rig.6") (("install -g 0 -m 755 -o 0 -d \\$\\(DATADIR\\)") "install -m 755 -d $(DESTDIR)$(DATADIR)") (("install -g 0 -m 644 -o 0 data/\\*.idx \\$\\(DATADIR\\)") "install -m 644 data/*.idx $(DESTDIR)$(DATADIR)"))))) #:tests? #f)) (home-page "https://rig.sourceforge.net") (synopsis "Random identity generator") (description "RIG (Random Identity Generator) generates random, yet real-looking, personal data. It is useful if you need to feed a name to a Web site, BBS, or real person, and are too lazy to think of one yourself. Also, if the Web site/BBS/person you are giving the information to tries to cross-check the city, state, zip, or area code, it will check out.") (license license:gpl2+))) (define-public conflict (package (name "conflict") (version "20221002") (source (origin (method url-fetch) (uri (string-append "https://invisible-mirror.net/archives/conflict/conflict-" version ".tgz")) (sha256 (base32 "1z6z61yiss9m45m3agqs92l569r55w9nsqaap56kh568mcy3y64c")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-after 'unpack 'fix-paths (lambda _ (substitute* "run_test.sh" (("PATH=\".:\\$BIN:/bin\"") "PATH=\".:$BIN:$PATH\""))))))) (home-page "https://invisible-island.net/conflict/conflict.html") (synopsis "Displays conflicting filenames in your execution path") (description "@code{conflict} examines the user-specifiable list of programs, looking for instances in the user's path which conflict (i.e., the name appears in more than one point in the path).") (license (license:x11-style "file://COPYING")))) (define-public renameutils (package (name "renameutils") (version "0.12.0") (source (origin (method url-fetch) (uri (string-append "mirror://savannah/renameutils/" "renameutils-" version ".tar.gz")) (sha256 (base32 "18xlkr56jdyajjihcmfqlyyanzyiqqlzbhrm6695mkvw081g1lnb")) (modules '((guix build utils))) (snippet '(begin (substitute* "src/Makefile.in" (("\\(\\$bindir\\)") "$(bindir)")) #t)))) (build-system gnu-build-system) (inputs (list readline)) (home-page "https://www.nongnu.org/renameutils/") (synopsis "File renaming utilities") (description "The file renaming utilities (renameutils for short) are a set of programs designed to make renaming of files faster and less cumbersome. The file renaming utilities consists of five programs: @command{qmv}, @command{qcp}, @command{imv}, @command{icp}, and @command{deurlname}.") (license license:gpl3+))) (define-public grc (package (name "grc") (version "1.13") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/garabik/grc") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1h0h88h484a9796hai0wasi1xmjxxhpyxgixn6fgdyc5h69gv8nl")))) (build-system gnu-build-system) (inputs (list python)) (arguments (list #:phases #~(modify-phases %standard-phases (delete 'configure) (replace 'build (lambda _ (substitute* "grc" (("conffilenames = \\[.*\\]") (string-append "conffilenames = [" "os.environ.get('GUIX_ENVIRONMENT', '" #$output "') " "+ '/etc/grc.conf']"))) (substitute* "grcat" (("conffilepath \\+= \\['/usr/.*\\]") (string-append "conffilepath += [" "os.environ.get('GUIX_ENVIRONMENT', '" #$output "') " "+ '/share/grc/']"))))) ;; trailing slash! (delete 'check) (replace 'install (lambda _ (invoke "sh" "install.sh" #$output #$output)))))) (home-page "http://kassiopeia.juls.savba.sk/~garabik/software/grc.html") (synopsis "Generic colouriser for everything") (description "@code{grc} can be used to colourise logfiles, output of shell commands, arbitrary text, etc. Many shell commands are supported out of the box. You might want to add these lines you your @code{~/.bashrc}: @example GRC_ALIASES=true source ${GUIX_ENVIRONMENT:-$HOME/.guix-profile}/etc/profile.d/grc.sh @end example ") (license license:gpl2))) (define-public liquidprompt (package (name "liquidprompt") (version "2.1.2") (home-page "https://github.com/liquidprompt/liquidprompt") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/liquidprompt/liquidprompt") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0ljlq97mh84d6g6r3abb254vrwrdan5v74b69fpd62d7p9ffnsgf")))) (build-system copy-build-system) (arguments (list #:install-plan #~'(("liquidpromptrc-dist" "etc/liquidpromptrc") ("example.bashrc" "share/liquidprompt/examples/") ("liquid.ps1" "share/liquidprompt/examples/") ("liquidprompt" "share/liquidprompt/") ("contrib" "share/liquidprompt/") ("themes" "share/liquidprompt/") ("liquidprompt.plugin.zsh" "share/zsh/plugins/liquidprompt/") ("docs" #$(string-append "share/doc/" name "-" version "/"))) #:phases #~(modify-phases %standard-phases (add-after 'unpack 'fix-plugin (lambda _ (substitute* "liquidprompt.plugin.zsh" (("source(.*)$") (string-append "source " #$output "/share/liquidprompt/liquidprompt"))))) (add-after 'fix-plugin 'fix-utils-path (lambda* (#:key inputs #:allow-other-keys) (substitute* "liquidprompt" (("([ (])\\\\?(tput|hostname|cksum|uname|tty|grep)([) ])" all beginning command ending) (string-append beginning (search-input-file inputs (string-append "bin/" command)) ending)))))))) (inputs (list ncurses coreutils inetutils)) (synopsis "Full-featured prompt for Bash & Zsh") (description "Liquidprompt is an adaptive prompt for Bash and Zsh that gives you a nicely displayed prompt with useful information when you need it. It does this with a powerful theming engine and a large array of data sources. In order to use liquidprompt with Zsh, you should use the following snippet with Guix Home: @example (service home-zsh-service-type (home-zsh-configuration (zshrc (list ;;... ;; This loads liquidprompt (mixed-text-file \"liquidprompt\" \"[[ $- = *i* ]] && source \" liquidprompt \"/share/liquidprompt/liquidprompt\") ;; This loads the powerline theme available in liquidprompt (mixed-text-file \"powerline-theme\" \"source \" liquidprompt \"/share/liquidprompt/themes/powerline/powerline.theme\")))))) @end example\n") (license license:agpl3+))) (define-public fzf-tab (package (name "fzf-tab") (version "1.1.2") (home-page "https://github.com/Aloxaf/fzf-tab") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/Aloxaf/fzf-tab") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "061jjpgghn8d5q2m2cd2qdjwbz38qrcarldj16xvxbid4c137zs2")))) (build-system copy-build-system) (arguments '(#:install-plan '(("lib" "/share/zsh/plugins/fzf-tab/") ("modules" "/share/zsh/plugins/fzf-tab/") ("fzf-tab.plugin.zsh" "/share/zsh/plugins/fzf-tab/") ("fzf-tab.zsh" "/share/zsh/plugins/fzf-tab/") ("README.md" "/share/doc/fzf-tab/")))) (synopsis "Replace the zsh default completion menu with fzf") (description "The fzf-tab package replaces the default completion menu of the zsh shell with fzf, enabling fuzzy finding and multi-selection.") (license license:expat)))