aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2021, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
;;; Copyright © 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018, 2020, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Gábor Boskovits <boskovits@gmail.com>
;;; Copyright © 2018, 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2020 Alex ter Weele <alex.ter.weele@gmail.com>
;;; Copyright © 2020 Lars-Dominik Braun <ldb@leibniz-psychology.org>
;;; Copyright © 2021, 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2021 Stefan Reichör <stefan@xsteve.at>
;;; Copyright © 2021 Raphaël Mélotte <raphael.melotte@mind.be>
;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2022 ( <paren@disroot.org>
;;; Copyright © 2022 Mathieu Laparie <mlaparie@disr.it>
;;;
;;; 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 monitoring)
  #:use-module (guix gexp)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system pyproject)
  #:use-module (guix build-system python)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system go)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages django)
  #:use-module (gnu packages gd)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages gnome)               ;libnotify
  #:use-module (gnu packages golang)
  #:use-module (gnu packages image)
  #:use-module (gnu packages mail)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages networking)
  #:use-module (gnu packages libevent)
  #: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-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages rrdtool)
  #:use-module (gnu packages sphinx)
  #:use-module (gnu packages time)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages web))

(define-public nagios
  (package
    (name "nagios")
    (version "4.4.6")
    ;; XXX: Nagios 4.2.x and later bundle a copy of AngularJS.
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "mirror://sourceforge/nagios/nagios-4.x/nagios-"
                    version "/nagios-" version ".tar.gz"))
              (sha256
               (base32
                "1x5hb97zbvkm73q53ydp1gwj8nnznm72q9c4rm6ny7phr995l3db"))
              (modules '((guix build utils)))
              (snippet
               ;; Ensure reproducibility.
               '(begin
                  (substitute* (find-files "cgi" "\\.c$")
                    (("__DATE__") "\"1970-01-01\"")
                    (("__TIME__") "\"00:00:00\""))
                  #t))))
    (build-system gnu-build-system)
    (native-inputs
     (list unzip))
    (inputs
     `(("zlib" ,zlib)
       ("libpng-apng" ,libpng)
       ("gd" ,gd)
       ("perl" ,perl)
       ("mailutils" ,mailutils)))
    (arguments
     '(#:configure-flags (list "--sysconfdir=/etc"

                               ;; 'include/locations.h.in' defines file
                               ;; locations, and many things go directly under
                               ;; LOCALSTATEDIR, hence the extra '/nagios'.
                               "--localstatedir=/var/nagios"

                               (string-append
                                "--with-mail="
                                (assoc-ref %build-inputs "mailutils")
                                "/bin/mail"))
       #:make-flags '("all")
       #:phases (modify-phases %standard-phases
                  (add-before 'build 'do-not-chown-to-nagios
                    (lambda _
                      ;; Makefiles do 'install -o nagios -g nagios', which
                      ;; doesn't work for us.
                      (substitute* (find-files "." "^Makefile$")
                        (("-o nagios -g nagios")
                         ""))
                      #t))
                  (add-before 'build 'do-not-create-sysconfdir
                    (lambda _
                      ;; Don't try to create /var upon 'make install'.
                      (substitute* "Makefile"
                        (("\\$\\(INSTALL\\).*\\$\\(LOGDIR\\).*$" all)
                         (string-append "# " all))
                        (("\\$\\(INSTALL\\).*\\$\\(CHECKRESULTDIR\\).*$" all)
                         (string-append "# " all))
                        (("chmod g\\+s.*" all)
                         (string-append "# " all)))
                      #t))
                  (add-before 'build 'set-html/php-directory
                    (lambda _
                      ;; Install HTML and PHP files under 'share/nagios/html'
                      ;; instead of just 'share/'.
                      (substitute* '("html/Makefile" "Makefile")
                        (("HTMLDIR=.*$")
                         "HTMLDIR = $(datarootdir)/nagios/html\n"))
                      #t)))
       #:tests? #f))                             ;no 'check' target or similar
    (home-page "https://www.nagios.org/")
    (synopsis "Host, service, and network monitoring program")
    (description
     "Nagios is a host, service, and network monitoring program written in C.
CGI programs are included to allow you to view the current status, history,
etc. via a Web interface.  Features include:

@itemize
@item Monitoring of network services (via SMTP, POP3, HTTP, PING, etc).
@item Monitoring of host resources (processor load, disk usage, etc.).
@item A plugin interface to allow for user-developed service monitoring
  methods.
@item Ability to define network host hierarchy using \"parent\" hosts,
  allowing detection of and distinction between hosts that are down
  and those that are unreachable.
@item Notifications when problems occur and get resolved (via email,
  pager, or user-defined method).
@item Ability to define event handlers for proactive problem resolution.
@item Automatic log file rotation/archiving.
@item Optional web interface for viewing current network status,
  notification and problem history, log file, etc.
@end itemize\n")
    (license license:gpl2)))

(define-public zabbix-agentd
  (package
    (name "zabbix-agentd")
    (version "6.0.14")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://cdn.zabbix.com/zabbix/sources/stable/"
             (version-major+minor version) "/zabbix-" version ".tar.gz"))
       (sha256
        (base32 "0n6fqa9vbhh2syxii7ds2x6dnplrgrj98by1zl0ij1wfbnbxa6k3"))
       (modules '((guix build utils)))
       (snippet
        '(substitute* '("src/zabbix_proxy/proxy.c"
                        "src/zabbix_server/server.c")
           ;; 'fping' must be setuid, so look for it in the usual location.
           (("/usr/sbin/fping6?")
            "/run/privileged/bin/fping")))))
    (build-system gnu-build-system)
    (arguments
     (list #:configure-flags
           #~(list "--enable-agent"
                   "--enable-ipv6"
                   "--with-libpcre2"
                   "--with-gnutls"
                   (string-append "--with-gnutls="
                                  (assoc-ref %build-inputs "gnutls")))))
    (native-inputs
     (list pkg-config))
    (inputs
     (list gnutls pcre2))
    (home-page "https://www.zabbix.com/")
    (synopsis "Distributed monitoring solution (client-side agent)")
    (description "This package provides a distributed monitoring
solution (client-side agent)")
    (license license:gpl2+)
    (properties
     '((release-monitoring-url . "https://www.zabbix.com/download_sources")
       (upstream-name . "zabbix")))))

(define-public zabbix-agent2
  (package/inherit zabbix-agentd
    (name "zabbix-agent2")
    (arguments
     (list #:configure-flags
           #~(list "--disable-agent"
                   "--enable-agent2"
                   "--enable-ipv6"
                   "--with-libpcre2"
                   ;; agent2 only supports OpenSSL.
                   (string-append "--with-openssl="
                                  (dirname (dirname
                                            (search-input-file
                                             %build-inputs "lib/libssl.so")))))
           #:make-flags
           #~'("BUILD_TIME=00:00:01" "BUILD_DATE=Jan 1 1970")
           #:phases
           #~(modify-phases %standard-phases
               (add-before 'build 'set-HOME
                 (lambda _
                   (setenv "HOME" "/tmp"))))))
    (native-inputs
     (list go pkg-config))
    (inputs
     (list openssl pcre2 zlib))))

(define-public zabbix-server
  (package
    (inherit zabbix-agentd)
    (name "zabbix-server")
    (outputs '("out" "front-end" "schema"))
    (arguments
     (substitute-keyword-arguments (package-arguments zabbix-agentd)
       ((#:phases phases '%standard-phases)
        #~(modify-phases #$phases
            (add-after 'install 'install-front-end
               (lambda* (#:key outputs #:allow-other-keys)
                 (let* ((php (string-append (assoc-ref outputs "front-end")
                                            "/share/zabbix/php"))
                        (front-end-conf (string-append php "/conf"))
                        (etc (string-append php "/etc")))
                   (mkdir-p php)
                   (copy-recursively "ui" php)
                   ;; Make front-end read config from ‘/etc/zabbix’ directory.
                   (rename-file front-end-conf
                                (string-append front-end-conf "-example"))
                   (symlink "/etc/zabbix" front-end-conf))))
             (add-after 'install 'install-schema
               (lambda* (#:key outputs #:allow-other-keys)
                 (let ((database-directory
                        (string-append (assoc-ref outputs "schema")
                                       "/database")))
                   (for-each delete-file
                             (find-files "database" "Makefile\\.in|\\.am$"))
                   (mkdir-p database-directory)
                   (copy-recursively "database" database-directory))))))
       ((#:configure-flags flags ''())
        #~(append (list "--enable-server"
                        "--with-postgresql"
                        (string-append "--with-libevent="
                                       (assoc-ref %build-inputs "libevent"))
                        "--with-net-snmp"
                        "--with-libcurl"
                        (string-append "--with-zlib="
                                       (assoc-ref %build-inputs "zlib")))
                  (delete "--enable-agent" #$flags)))))
    (inputs
     (modify-inputs (package-inputs zabbix-agentd)
       (prepend curl
                libevent
                net-snmp
                postgresql
                zlib)))
    (synopsis "Distributed monitoring solution (server-side)")
    (description "This package provides a distributed monitoring
solution (server-side)")))

(define-public zabbix-cli
  (package
    (name "zabbix-cli")
    (version "2.3.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/unioslo/zabbix-cli")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1al3gwbnh0wbal5gq2apq27kh61q8dz355k4w8kx073b4y4nz1wb"))))
    (build-system pyproject-build-system)
    (arguments
     (list #:phases
           #~(modify-phases %standard-phases
               (add-after 'unpack 'use-absolute-ncurses
                 (lambda* (#:key inputs #:allow-other-keys)
                   (let ((clear (search-input-file inputs "bin/clear")))
                     (substitute* "bin/zabbix-cli"
                       (("'clear'")
                        (string-append "'" clear "'"))))))
               (add-after 'unpack 'patch-setup.py
                 (lambda _
                   ;; Install data_files to $out/share instead of /usr/share.
                   (substitute* "setup.py"
                     (("/usr/") ""))))
               (add-after 'build 'build-docs
                 (lambda _
                   (invoke "make" "-C" "docs" "manual")
                   (invoke "make" "-C" "docs" "singlehtml")))
               (add-after 'install 'install-docs
                 (lambda _
                   (install-file "docs/_build/man/zabbix-cli.1"
                                 (string-append #$output "/share/man/man1"))
                   (copy-recursively "docs/_build/singlehtml"
                                     (string-append #$output "/share/doc/"
                                                    #$name "/html")))))))
    (native-inputs
     (list python-pytest
           python-setuptools
           python-sphinx
           python-wheel))
    (inputs
     (list ncurses python-requests))
    (home-page "https://github.com/unioslo/zabbix-cli")
    (synopsis "Command-line interface to Zabbix")
    (description
     "@command{zabbix-cli} is a command-line client for the Zabbix
monitoring system.  It can configure and display various aspects of Zabbix
through a text-based interface.")
    (license license:gpl3+)))

(define-public python-pyzabbix
  (package
    (name "python-pyzabbix")
    (version "1.2.1")
    (home-page "https://github.com/lukecyca/pyzabbix")
    ;; No tests on PyPI, use the git checkout.
    (source
     (origin
       (method git-fetch)
       (uri (git-reference (url home-page) (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0ad5xac67brmwc3wd0f87pjplly3cqyrz1dp725lzz2hrjgiaqi8"))))
    (build-system python-build-system)
    (arguments
     '(#:phases (modify-phases %standard-phases
                  (replace 'check
                    (lambda* (#:key tests? #:allow-other-keys)
                      (if tests?
                          (invoke "pytest" "-vv" "tests")
                          (format #t "test suite not run~%")))))))
    (native-inputs
     ;; For tests.
     (list python-requests-mock python-pytest))
    (propagated-inputs
     (list python-packaging python-requests))
    (synopsis "Python interface to the Zabbix API")
    (description
     "@code{pyzabbix} is a Python module for working with the Zabbix API.")
    (license license:lgpl2.1+)))

(define-public darkstat
  (package
    (name "darkstat")
    (version "3.0.719")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://unix4lyfe.org/darkstat/darkstat-"
                                  version ".tar.bz2"))
              (sha256
               (base32
                "1mzddlim6dhd7jhr4smh0n2fa511nvyjhlx76b03vx7phnar1bxf"))))
    (build-system gnu-build-system)
    (arguments '(#:tests? #f))          ; no tests
    (inputs
     (list libpcap zlib))
    (home-page "https://unix4lyfe.org/darkstat/")
    (synopsis "Network statistics gatherer")
    (description
     "@command{darkstat} is a packet sniffer that runs as a background process,
gathers all sorts of statistics about network usage, and serves them over
HTTP.  Features:

@itemize
@item Traffic graphs, reports per host, shows ports for each host.
@item Embedded web-server with deflate compression.
@item Asynchronous reverse DNS resolution using a child process.
@item Small.  Portable.  Single-threaded.  Efficient.
@item Supports IPv6.
@end itemize")
    (license license:gpl2)))

(define-public python-whisper
  (package
    (name "python-whisper")
    (version "1.1.8")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "whisper" version))
       (sha256
        (base32
         "1bk29w09zcpsv8hp0g0al7nwrxa07z0ycls3mbh83wfavk83aprl"))))
    (build-system python-build-system)
    (native-inputs (list python-six))
    (home-page "https://graphiteapp.org/")
    (synopsis "Fixed size round-robin style database for Graphite")
    (description "Whisper is one of three components within the Graphite
project.  Whisper is a fixed-size database, similar in design and purpose to
RRD (round-robin-database).  It provides fast, reliable storage of numeric
data over time.  Whisper allows for higher resolution (seconds per point) of
recent data to degrade into lower resolutions for long-term retention of
historical data.")
    (license license:asl2.0)))

(define-public python-carbon
  (package
    (name "python-carbon")
    (version "1.1.8")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "carbon" version))
       (sha256
        (base32
         "1wb91fipk1niciffq5xwqbh8g7rl7ghdam4m97cjbig12i5qr4cm"))))
    (build-system python-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         ;; Don't install to /opt
         (add-after 'unpack 'do-not-install-to-/opt
           (lambda _ (setenv "GRAPHITE_NO_PREFIX" "1") #t)))))
    (propagated-inputs
     (list python-cachetools python-txamqp python-urllib3 python-whisper))
    (home-page "https://graphiteapp.org/")
    (synopsis "Backend data caching and persistence daemon for Graphite")
    (description "Carbon is a backend data caching and persistence daemon for
Graphite.  Carbon is responsible for receiving metrics over the network,
caching them in memory for \"hot queries\" from the Graphite-Web application,
and persisting them to disk using the Whisper time-series library.")
    (license license:asl2.0)))

(define-public graphite-web
  (package
    (name "graphite-web")
    (version "1.1.10")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "graphite-web" version))
       (sha256
        (base32
         "0nnk3kwn0b6bq9xnmv9bac6hpcbdgpgwf283c1ck5nm80panh61z"))))
    (build-system python-build-system)
    (arguments
     `(#:tests? #f               ;XXX: not in PyPI release & requires database
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'relax-requirements
           (lambda _
             (substitute* "setup.py"
               ;; Allow newer versions of django-tagging.
               (("django-tagging==") "django-tagging>=")
               ;; And Django.
               (("Django>=1\\.8,<3\\.1") "Django>=1.8,<4"))))
         ;; Don't install to /opt
         (add-after 'unpack 'do-not-install-to-/opt
           (lambda _ (setenv "GRAPHITE_NO_PREFIX" "1") #t)))))
    (propagated-inputs
     (list python-cairocffi
           python-django-3.2
           python-django-tagging
           python-pyparsing
           python-pytz
           python-six
           python-urllib3))
    (home-page "https://graphiteapp.org/")
    (synopsis "Scalable realtime graphing system")
    (description "Graphite is a scalable real-time graphing system that does
two things: store numeric time-series data, and render graphs of this data on
demand.")
    (license license:asl2.0)))

(define-public python-prometheus-client
  (package
    (name "python-prometheus-client")
    (version "0.20.0")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "prometheus_client" version))
       (sha256
        (base32 "12dvlh4k6in87q47f0zqh8nrnnfs0pwrs2xynbf34yhl1g82jxi8"))))
    (build-system python-build-system)
    (arguments
     '(;; No included tests.
       #:tests? #f))
    (home-page
     "https://github.com/prometheus/client_python")
    (synopsis "Python client for the Prometheus monitoring system")
    (description
     "The @code{prometheus_client} package supports exposing metrics from
software written in Python, so that they can be scraped by a Prometheus
service.

Metrics can be exposed through a standalone web server, or through Twisted,
WSGI and the node exporter textfile collector.")
    (license license:asl2.0)))

(define-public go-github-com-prometheus-node-exporter
  (package
    (name "go-github-com-prometheus-node-exporter")
    (version "0.18.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/prometheus/node_exporter")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0s3sp1gj86p7npxl38hkgs6ymd3wjjmc5hydyg1b5wh0x3yvpx07"))))
    (build-system go-build-system)
    (arguments
     '(#:import-path "github.com/prometheus/node_exporter"))
    (synopsis "Prometheus exporter for hardware and OS metrics")
    (description "Prometheus exporter for metrics exposed by *NIX kernels,
written in Go with pluggable metric collectors.")
    (home-page "https://github.com/prometheus/node_exporter")
    (license license:asl2.0)))

(define-public temper-exporter
  (let ((commit "a87bbab19c05609d62d9e4c7941178700c1ef84d")
        (revision "0"))
    (package
      (name "temper-exporter")
      (version (git-version "0" revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/yrro/temper-exporter")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "0jk3ydi8s14q5kyl9j3gm2zrnwlb1jwjqpg5vqrgkbm9jrldrabc"))))
      (build-system python-build-system)
      (arguments
       '(#:tests? #f                    ; One test failure:
                                        ; test/test_exporter.py:33:
                                        ; AssertionError
         #:phases
         (modify-phases %standard-phases
           (add-after 'unpack 'patch-setup.py
             (lambda _
               (substitute* "setup.py"
                 (("git_ref = .*\n") "git_ref = ''\n"))
               #t))
           (add-after 'install 'install-udev-rules
             (lambda* (#:key outputs #:allow-other-keys)
               (install-file "debian/prometheus-temper-exporter.udev"
                             (string-append (assoc-ref outputs "out")
                                            "/lib/udev/rules.d"))
               #t)))))
      (inputs
       (list python-prometheus-client python-pyudev))
      (native-inputs
       (list python-pytest python-pytest-mock python-pytest-runner))
      (home-page "https://github.com/yrro/temper-exporter")
      (synopsis "Prometheus exporter for PCSensor TEMPer sensor devices")
      (description
       "This package contains a Prometheus exporter for the TEMPer sensor
devices.")
      (license license:expat))))

(define-public fswatch
  (package
    (name "fswatch")
    (version "1.17.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                      (url "https://github.com/emcrisostomo/fswatch")
                      (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "15bk2adv1ycqn3rxvpvapwrlzsxw8fvcahqiglfkibwb9ss7s8dh"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf automake gettext-minimal libtool))
    (arguments
     (list #:configure-flags
           #~(list "--disable-static")))
    (synopsis "File system monitor")
    (description "This package provides a file system monitor.")
    (home-page "https://github.com/emcrisostomo/fswatch")
    (license license:gpl3+)))

(define-public collectd
  (package
    (name "collectd")
    (version "5.12.0")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://storage.googleapis.com/collectd-tarballs/collectd-"
                    version
                    ".tar.bz2"))
              (sha256
               (base32
                "1mh97afgq6qgmpvpr84zngh58m0sl1b4wimqgvvk376188q09bjv"))
              (patches (search-patches "collectd-5.11.0-noinstallvar.patch"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags (list "--localstatedir=/var" "--sysconfdir=/etc")
       #:phases (modify-phases %standard-phases
                  (add-before 'configure 'autoreconf
                    (lambda _
                      ;; Required because of patched sources.
                      (invoke "autoreconf" "-vfi"))))))
    (inputs
     (list rrdtool curl yajl))
    (native-inputs
     (list autoconf automake libtool pkg-config))
    (home-page "https://collectd.org/")
    (synopsis "Collect system and application performance metrics periodically")
    (description
     "collectd gathers metrics from various sources such as the operating system,
applications, log files and external devices, and stores this information or
makes it available over the network.  Those statistics can be used to monitor
systems, find performance bottlenecks (i.e., performance analysis) and predict
future system load (i.e., capacity planning).")
    ;; license:expat for the daemon in src/daemon/ and some plugins,
    ;; license:gpl2 for other plugins
    (license (list license:expat license:gpl2))))

(define-public hostscope
  (package
    (name "hostscope")
    (version "8.0")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "http://www.maier-komor.de/hostscope/hostscope-V"
                    version ".tgz"))
              (sha256
               (base32
                "0jw6yij8va0f292g4xkf9lp9sxkzfgv67ajw49g3vq42q47ld7cv"))))
    (build-system gnu-build-system)
    (inputs (list ncurses))
    (arguments '(#:tests? #f)) ;; No included tests.
    (home-page "https://www.maier-komor.de/hostscope.html")
    (properties `((release-monitoring-url . ,home-page)))
    (synopsis
     "System monitoring tool for multiple hosts")
    (description
     "HostScope displays key system metrics of Linux hosts, such as detailed
CPU load, speed and temperature, I/O rates of network interfaces, I/O rates of
disks, and user process summary information.  All metrics are multicast on the
LAN, if wanted, and clients can switch between multiple hosts on the network.
Hostscope features a bridge to Influx DB.  So Grafana can be used to visualize
the recorded data over time.")
    (license license:gpl3+)))

(define-public fatrace
  (package
    (name "fatrace")
    (version "0.17.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/martinpitt/fatrace")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "067pj0z4np4mmhlin9411zpwwbfmn38ykvmxw35fnidf3kxcq49i"))))
    (build-system gnu-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (delete 'configure)
         ;; tests need root to run as root,
         ;; and there is no make target for them:
         (delete 'check))
       #:make-flags
       (list (string-append "CC=" ,(cc-for-target))
             (string-append "PREFIX=" %output))))
    (synopsis "File access events monitor")
    (description "This package provides a utility to report system wide file
access events from all running processes.  Its main purpose is to find
processes which keep waking up the disk unnecessarily and thus prevent some
power saving.")
    (home-page "https://github.com/martinpitt/fatrace")
    (license license:gpl3+)))

(define-public pw
  (package
    (name "pw")
    (version "2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://www.kylheku.com/git/pw")
             (commit (string-append "pw-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1xn3qnzz48xan78cp83hfrcifrxx9lgnm14134qhyr5wvj7dk246"))))
    (build-system gnu-build-system)
    (arguments
     (list #:tests? #f                  ; There are no tests
           #:make-flags
           #~(list (string-append "CC=" #$(cc-for-target))
                   (string-append "DESTDIR=" #$output))
           #:phases
           #~(modify-phases %standard-phases
               (add-after 'unpack 'fix-makefile
                 (lambda _
                   (substitute* "Makefile"
                     (("/share/man/man1 \\\\") "/share/man/man1; \\"))))
               (delete 'configure)
               (add-before 'install 'make-install-dirs
                 (lambda _
                   (mkdir-p (string-append #$output "/bin"))
                   (mkdir-p (string-append #$output "/share/man/man1"))
                   (mkdir-p (string-append #$output "/share/man/man5")))))))
    (home-page "https://www.kylheku.com/cgit/pw/")
    (synopsis "Monitor recent lines of output from pipe")
    (description
     "@command{pw} is Pipe Watch, a utility that continuously reads lines of
text from a pipe or pipe-like source, passes them through a FIFO buffer, and
maintains a display based on the occasional sampling of the contents of the
FIFO buffer, with useful features such as triggering and filtering.

With @command{pw} you can:

@itemize
@item Interactively apply and remove filters on-the-fly, without interrupting
the source.

@item Make recurring patterns in the stream appear to ``freeze'' on the
screen, using triggers.

@item Prevent the overwhelming amount of output from a program from flooding
the terminal, while consuming all of that output so that the program isn't
blocked.  @command{pw} can pause its display updates entirely.

@item Juggle multiple shell background jobs that produce output, yet execute
indefinitely without blocking.  When @command{pw} runs as part of a shell
background job, it continues to consume input, process filters and take
snapshots, without displaying anything.  When put into the foreground again,
display resumes.
@end itemize")
    (license license:bsd-2)))

(define-public python-statsd
  (package
    (name "python-statsd")
    (version "3.3.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "statsd" version))
              (sha256
               (base32
                "07yxnlalvcglgwa9pjs1clwrmwx7a4575jai7q05jz3g4i6dprp3"))))
    (build-system python-build-system)
    (native-inputs (list python-mock python-nose))
    (home-page "https://github.com/jsocol/pystatsd")
    (synopsis "Simple StatsD client")
    (description "StatsD is a friendly front-end to Graphite.  This package
provides a simple Python client for the StatsD daemon.")
    (license license:expat)))

(define-public batsignal
  (package
    (name "batsignal")
    (version "1.8.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/electrickite/batsignal")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0l6j873l1l0al95zl9ihxzrmy9r11pfm269gydlx8pps4gdisy6a"))))
    (build-system gnu-build-system)
    (arguments
     (list #:make-flags
           #~(list (string-append "PREFIX=" #$output)
                   (string-append "CC=" #$(cc-for-target)))
           #:phases
           #~(modify-phases %standard-phases
               (add-after 'unpack 'fix-cross-compile
                 (lambda _
                   (substitute* "Makefile"
                     (("pkg-config")
                      #$(pkg-config-for-target)))))
               (delete 'configure)
               (replace 'check
                 (lambda* (#:key tests? #:allow-other-keys)
                   (when tests?
                     (invoke "./batsignal" "-v")))))))
    (inputs (list libnotify))
    (native-inputs (list pkg-config))
    (home-page "https://github.com/electrickite/batsignal")
    (synopsis "Power monitoring tool")
    (description
     "This package provides a daemon that monitors device power levels,
notifying the user and optionally running a command when it reaches
user-configured power thresholds.  This can be used to force powering off a
laptop when the battery gets below critical levels, instead of damaging the
battery.")
    (license license:isc)))
href='#n1073'>1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2018, 2020–2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2017 Gábor Boskovits <boskovits@gmail.com>
;;; Copyright © 2017, 2018, 2021, 2023 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Leo Famulari <leo@famulari.name>
;;; Copyright © 2019-2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org>
;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com>
;;; Copyright © 2021 Stefan Reichör <stefan@xsteve.at>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021, 2023 Kaelyn Takata <kaelyn.alexi@protonmail.com>
;;; Copyright © 2022 Brian Cully <bjc@spork.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 file-systems)
  #:use-module (guix gexp)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system go)
  #:use-module (guix build-system linux-module)
  #:use-module (guix build-system python)
  #:use-module (guix build-system trivial)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages acl)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages attr)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages backup)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages crypto)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages cyrus-sasl)
  #:use-module (gnu packages datastructures)
  #:use-module (gnu packages digest)
  #:use-module (gnu packages documentation)
  #:use-module (gnu packages docbook)
  #:use-module (gnu packages elf)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages gawk)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnupg)
  #:use-module (gnu packages golang)
  #:use-module (gnu packages guile)
  #:use-module (gnu packages jemalloc)
  #:use-module (gnu packages kerberos)
  #:use-module (gnu packages libevent)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages libunwind)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages man)
  #:use-module (gnu packages nfs)
  #:use-module (gnu packages onc-rpc)
  #:use-module (gnu packages openldap)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages photo)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages popt)
  #:use-module (gnu packages pretty-print)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-crypto)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages readline)
  #:use-module (gnu packages rsync)
  #:use-module (gnu packages sssd)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages textutils)
  #:use-module (gnu packages time)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages valgrind)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages xml))

(define-public autofs
  (package
    (name "autofs")
    (version "5.1.8")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "mirror://kernel.org/linux/daemons/autofs/"
                           "v" (version-major version) "/"
                           "autofs-" version ".tar.xz"))
       (sha256
        (base32 "1zf0fgf6kr9amxq5amlgsp1v13sizwl3wvx2xl7b4r2nhmci0gdk"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list "--enable-ignore-busy"     ; during shutdown
             "--enable-sloppy-mount"    ; support mount(8) -s
             "--with-libtirpc"
             (string-append "--with-openldap="
                            (assoc-ref %build-inputs "openldap"))
             (string-append "--with-sasl="
                            (assoc-ref %build-inputs "cyrus-sasl"))
             "HAVE_SSS_AUTOFS=1"        ; required to make sssldir click
             (string-append "sssldir="
                            (assoc-ref %build-inputs "sssd")
                            "/lib/sssd/modules"))
       #:tests? #f                      ; no test suite
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'fix-hard-coded-search-path
           (lambda _
             (substitute* "configure"
               (("^searchpath=\".*\"")
                "searchpath=\"$PATH\""))))
         (add-before 'configure 'fix-rpath
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (substitute* "Makefile.rules"
                 (("^AUTOFS_LIB_LINK.*=" match)
                  (string-append match " -Wl,-rpath=" out "/lib"))))))
         (add-before 'install 'omit-obsolete-lookup_nis.so-link
           ;; Building lookup_yp.so depends on $(YPCLNT) but this doesn't,
           ;; leading to a make error.  Since it's broken, comment it out.
           (lambda _
             (substitute* "modules/Makefile"
               (("ln -fs lookup_yp.so" match)
                (string-append "# " match))))))))
    (native-inputs
     (list bison flex pkg-config rpcsvc-proto))
    (inputs
     (list cyrus-sasl
           e2fsprogs ; for e[234]fsck
           libtirpc
           libxml2 ; needed for LDAP, SASL
           mit-krb5 ; needed for LDAP, SASL
           nfs-utils ; for mount.nfs
           openldap
           openssl ; needed for SASL
           sssd
           util-linux))     ; for mount, umount
    ;; XXX A directory index is the closest thing this has to a home page.
    (home-page "https://www.kernel.org/pub/linux/daemons/autofs/")
    (synopsis "Kernel-based automounter for Linux")
    (description
     "Autofs is a kernel-based automounter for use with the Linux autofs4
module.  It automatically mounts selected file systems when they are used and
unmounts them after a set period of inactivity.  This provides
centrally-managed, consistent file names for users and applications, even in a
large and/or frequently changing (network) environment.")
    ;; fedfs/ is GPL-2-only but not built.
    (license (list license:bsd-3        ; modules/cyrus-sasl.c
                   license:gpl2+))))    ; the rest

(define-public bindfs
  (package
    (name "bindfs")
    (version "1.17.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://bindfs.org/downloads/bindfs-"
                                  version ".tar.gz"))
              (sha256
               (base32
                "1k1xkyjk8ms11djbhlmykkzfbcids6ls5vpq7rhdnazcladszm3g"))))
    (build-system gnu-build-system)
    (arguments
     ;; XXX: The tests have no hope of passing until there is a "nogroup"
     ;; entry (or at least some group to which the guix builder does
     ;; not belong) in the /etc/group file of the build environment.
     ;; Currently we do not have such a group.  Disable tests for now.
     '(#:tests? #f))
    (native-inputs
       ;; Native inputs to run the tests
       ;; ("ruby" ,ruby)
       ;; ("valgrind" ,valgrind)
       ;; ("which" ,which)
     (list pkg-config))
    (inputs
     (list fuse-2))
    (home-page "https://bindfs.org")
    (synopsis "Bind mount a directory and alter permission bits")
    (description
     "@command{bindfs} is a FUSE file system for mounting a directory to
another location, similar to @command{mount --bind}.  It can be used for:
@itemize
@item Making a directory read-only.
@item Making all executables non-executable.
@item Sharing a directory with a list of users (or groups).
@item Modifying permission bits using rules with chmod-like syntax.
@item Changing the permissions with which files are created.
@end itemize")
    (license license:gpl2+)))

(define-public cachefilesd-inotify
  (package
    (name "cachefilesd-inotify")
    (version "0.11.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.com/tomalok/cachefilesd-inotify")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0qkrpz69ql6fb3fwh0l35hhf9znnqyxhgv5fzd1gl2a2kz13rq5a"))))
    (build-system gnu-build-system)
    (arguments
     `(#:make-flags
       (list (string-append "CC=" ,(cc-for-target))
             ;; The Makefile doesn't support prefix= or similar.
             (string-append "DESTDIR=" (assoc-ref %outputs "out"))
             "MANDIR=/share/man")
       #:tests? #f                      ; no test suite
       #:phases
       (modify-phases %standard-phases
         (delete 'configure))))         ; no configure script
    (home-page "https://gitlab.com/tomalok/cachefilesd-inotify")
    (synopsis
     "CacheFiles file system cache management daemon (using @code{inotify})")
    (description
     "This package provides the user space component of CacheFiles, a caching
back end that uses a directory on a locally mounted file system (such as ext4)
as a cache to speed up (by reducing) access to a slower file system and make it
appear more reliable.

The cached file system is often a network file system such as NFS or CIFS, but
can also be a local file system like ISO 9660 on a slow optical drive.

CacheFiles itself is part of the kernel but relies on this user space
@command{cachefilesd} daemon to perform maintenance tasks like culling and
reaping stale nodes.  Only one such daemon can be running at a time, and
communicates with the kernel through the @file{/dev/cachefiles} character
device.

This version modifies David Howells original cachefilesd---which appears
unmaintained---to use the @code{inotify} API instead of the deprecated
@code{dnotify} to monitor file changes.")
    (license license:gpl2+)))

(define-public avfs
  (package
    (name "avfs")
    (version "1.1.5")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://sourceforge/avf/avfs/" version
                                  "/avfs-" version ".tar.bz2"))
              (sha256
               (base32
                "1kvjaaj2dlps98alpc8rhnzhk4vriw46f3y7b2h0jq2d21j3p7xd"))))
    (build-system gnu-build-system)
    (arguments
     '(#:configure-flags '("--enable-library" "--enable-fuse")))
    (native-inputs (list pkg-config))
    (inputs (list xz fuse-2))
    (synopsis "Virtual file system that allows browsing of compressed files")
    (description
     "AVFS is a FUSE-based filesystem that allows browsing of compressed
files.  It provides the @command{mountavfs} command that starts a small
@command{avfsd} daemon.  When a specially formatted path under @file{~/.avfs}
is accessed, the daemon provides listings and content access on the fly.  The
canonical form of virtual file name is:

@example
[basepath]#handler[options][:parameters][/internalpath]
@end example

Example file names:
@itemize
@item @file{~/.avfs/home/user/archive.tar.gz#ugz#utar/path/file}
@item @file{~/.avfs/#http:localhost|some|path}
@end itemize

@code{emacs-dired-hacks} has @code{dired-avfs} module which enables seamless
integration with @code{avfs}.")
    (home-page "https://avf.sourceforge.net")
    (license license:gpl2+)))

(define-public davfs2
  (package
    (name "davfs2")
    (version "1.6.1")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://download.savannah.nongnu.org/releases/"
                           "davfs2/davfs2-" version ".tar.gz"))
       (sha256
        (base32 "1h65j2py59b97wbzzjhp4wbkk6351v3hrjscjcfab0p5xi4bjgnf"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list "--sysconfdir=/etc"        ; so man pages & binaries contain /etc
             (string-append "--docdir=" (assoc-ref %outputs "out")
                            "/share/doc/" ,name "-" ,version)
             (string-append "ssbindir=" (assoc-ref %outputs "out") "/sbin")
             ;; The default ‘davfs2’ user and group don't exist on most systems.
             "dav_user=nobody"
             "dav_group=nogroup")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'omit-redundancy
           ;; Don't install redundant copies of /etc examples into /share.
           (lambda _
             (substitute* "etc/Makefile.in"
               (("(dist_pkgdata_DATA =.*) davfs2.conf secrets(.*)"
                 _ prefix suffix)
                (string-append prefix suffix)))))
         (add-after 'unpack 'patch-file-names
           (lambda _
             ;; Don't auto-load the FUSE kernel module.  That's up to root.
             ;; XXX If/when we restore the previous behaviour, make sure not
             ;; to introduce a security hole when mount.davfs is setuid.
             (substitute* "src/kernel_interface.c"
               (("/sbin/modprobe") "/modprobe/disabled"))))
         (replace 'install
           (lambda* (#:key make-flags outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (apply invoke "make" "install"
                      (string-append "pkgsysconfdir=" out "/etc")
                      make-flags)))))))
    (inputs
     (list neon
           ;; Neon requires but doesn't propagate zlib, nor would we want that.
           ;; XZ as well, but that's already present in the build environment.
           zlib))
    (home-page "https://savannah.nongnu.org/projects/davfs2")
    (synopsis "Mount remote WebDAV resources in the local file system")
    (description
     "The @acronym{WebDAV, Web Distributed Authoring and Versioning} extension
to the HTTP protocol defines a standard way to author resources on a remote Web
server.  Davfs2 exposes such resources as a typical file system which can be
used by standard applications with no built-in support for WebDAV, such as the
GNU coreutils (@command{cp}, @command{mv}, etc.) or a graphical word processor.

Davfs2 works with most WebDAV servers with no or little configuration.  It
supports TLS (HTTPS), HTTP proxies, HTTP basic and digest authentication, and
client certificates.  It performs extensive caching to avoid unnecessary network
traffic, stay responsive even over slow or unreliable connections, and prevent
data loss.  It aims to make use by unprivileged users as easy and secure as
possible.

However, davfs2 is not a full-featured WebDAV client.  The file system interface
and the WebDAV protocol are quite different.  Translating between the two is not
always possible.")
    (license (list license:bsd-2        ; src/fuse_kernel.h
                   license:gpl3+))))    ; everything else

(define-public exfat-utils
  (package
    (name "exfat-utils")
    (version "1.4.0")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://github.com/relan/exfat/releases/download/v"
             version "/exfat-utils-" version ".tar.gz"))
       (sha256
        (base32 "0sdzflmwcxjjliq1yqhidy46kbkvj16kxrbrgsj0ci0hjgx7a594"))))
    (build-system gnu-build-system)
    (home-page "https://github.com/relan/exfat")
    (synopsis "Utilities to manipulate exFAT file systems")
    (description
     "This package provides an implementation of the exFAT file system,
including command-line tools to validate exFAT file systems and to create new
ones.")
    (license license:gpl2+)))

(define-public fsarchiver
  (package
    (name "fsarchiver")
    (version "0.8.7")
    (source
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://github.com/fdupoux/fsarchiver")
         (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1vy8ay0fn32i298bx9scqghi7xm9z2101zxk5xshbrkl00b2m4nm"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf automake pkg-config))
    (inputs
     (list bzip2
           e2fsprogs
           libgcrypt
           lz4
           lzo
           `(,util-linux "lib")
           xz
           zlib
           `(,zstd "lib")))
    (synopsis "File system back-up, deployment, and migration tool")
    (description
     "FSArchiver saves the contents of a file system to a compressed archive
file, and restores it to a different file system and/or partition.  This
partition can be of a different size than the original and FSArchiver will
create a new file system if none exists.

All standard file attributes supported by the kernel are preserved, including
file permissions, timestamps, symbolic and hard links, and extended attributes.

Each file in the archive is protected by a checksum.  If part of the archive
is corrupted you'll lose the affected file(s) but not the whole back-up.")
    (home-page "https://www.fsarchiver.org/")
    (license license:gpl2)))

(define-public fstransform
  (package
    (name "fstransform")
    (version "0.9.4")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/cosmos72/fstransform")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0vhypb6pbghja95av62ds4mhldbg0h8g4yg94k9r7lsxm7bgpfr3"))))
    (build-system gnu-build-system)
    (arguments
     (list #:phases
           #~(modify-phases %standard-phases
               (add-after 'install 'install-README
                 ;; There are no man pages.  Install a poor substitute.
                 (lambda* (#:key outputs #:allow-other-keys)
                   (let* ((out (assoc-ref outputs "out"))
                          (doc (string-append out "/share/doc/" #$name)))
                     (install-file "README" doc)))))))
    (inputs (list e2fsprogs))
    (home-page "https://github.com/cosmos72/fstransform")
    (synopsis "Convert file system types in place without copying all data")
    (description
     "This package provides several command-line tools to transform a supported
file system, such as XFS, into one of a different supported type, such as ext4.
All existing file contents, names, and directories are preserved.

The conversion happens @dfn{in place}, without the need to create a complete
copy of the original data.  This lets you transform almost full file systems on
systems where adding (sufficient) additional storage space is not an option.

Do @emph{not} use this package when you could simply create an empty file system
from scratch and restore from a back-up.  Transformation is limited, slow, and
significantly increases the risk of irreversible data loss!")
    ;; Please follow <https://github.com/cosmos72/fstransform/issues/46>.
    (license (list license:gpl2         ; fsattr/src/e4attr.* → sbin/fsattr
                   license:gpl3+))))    ; the rest

(define-public gocryptfs
  (package
    (name "gocryptfs")
    (version "2.4.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/rfjakob/gocryptfs")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "08pdfx6bs1dc2k7xv54x7i1qbych4a7dlf31qwcm9wlz7lr5lawm"))))
    (build-system go-build-system)
    (arguments
     (list
      #:import-path "github.com/rfjakob/gocryptfs"
      #:build-flags
      #~(list
         "-ldflags" (string-append
                     "-X main.GitVersion=" #$version
                     " -X main.GitVersionFuse=" #$(package-version
                                                   go-github-com-hanwen-go-fuse-v2)
                     " -X main.BuildDate=" "[reproducible]"))
      #:phases
      #~(modify-phases %standard-phases
          ;; after 'check phase, should maybe unmount leftover mounts as in
          ;; https://github.com/rfjakob/gocryptfs/blob/a55b3cc15a6d9bce116a90f33df4bc99d9dd6a10/test.bash#L28
          (replace 'build
            (lambda arguments
              (for-each
               (lambda (directory)
                 (apply (assoc-ref %standard-phases 'build)
                        (append arguments (list #:import-path directory))))
               (list
                "github.com/rfjakob/gocryptfs"
                "github.com/rfjakob/gocryptfs/gocryptfs-xray"
                "github.com/rfjakob/gocryptfs/contrib/statfs"
                "github.com/rfjakob/gocryptfs/contrib/findholes"
                "github.com/rfjakob/gocryptfs/contrib/atomicrename")))))))
    (native-inputs (list
                    go-github-com-hanwen-go-fuse-v2
                    go-github-com-aperturerobotics-jacobsa-crypto
                    go-github-com-jacobsa-oglematchers
                    go-github-com-jacobsa-oglemock
                    go-github-com-jacobsa-ogletest
                    go-github-com-jacobsa-reqtrace
                    go-github-com-pkg-xattr
                    go-github-com-rfjakob-eme
                    go-github-com-sabhiram-go-gitignore
                    go-github-com-spf13-pflag
                    go-golang-org-x-crypto
                    go-golang-org-x-net
                    go-golang-org-x-sys
                    go-golang-org-x-term
                    openssl
                    pkg-config))
    (home-page "https://github.com/rfjakob/gocryptfs")
    (synopsis "Encrypted overlay filesystem")
    (description
     "Gocryptfs is an encrypted overlay filesystem written in Go.  It
features a file-based encryption that is implemented as a mountable
FUSE filesystem.

Gocryptfs was inspired by EncFS and strives to fix its security issues
while providing good performance.  Gocryptfs is as fast as EncFS in the
default mode and significantly faster than paranoia mode in EncFS,
which provides a security level comparable to Gocryptfs.

On CPUs without AES-NI, gocryptfs uses OpenSSL through a thin wrapper
called stupidgcm.  This provides a 4x speedup compared to Go's builtin
AES-GCM implementation.")
    (license license:expat)))

(define-public gphotofs
  (package
    (name "gphotofs")
    (version "0.5.0")
    (source
     (origin
       (method url-fetch)
       (uri
        (string-append "mirror://sourceforge/gphoto/gphotofs/" version
                       "/gphotofs-0.5.tar.gz"))
       (sha256
        (base32
         "04slwhr6ap9xcc27wphk22ad8yn79ngyy5z10lxams3k5liahvc2"))))
    (build-system gnu-build-system)
    (native-inputs
     (list pkg-config))
    (inputs
     (list fuse-2 glib libgphoto2))
    (synopsis "Virtual file system for libgphoto2 using FUSE")
    (description "GPhotoFS is a FUSE file system module to mount your camera as
a file system on Linux.  This allow using your camera with any tool able to read
from a mounted file system.")
    (home-page "http://www.gphoto.org/proj/gphotofs/")
    (license license:gpl2+)))

(define-public bcachefs-tools
  (package
    (name "bcachefs-tools")
    (version "1.2")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://evilpiepirate.org/git/bcachefs-tools.git")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0wgqclkkdkqis3aq6wp0kcn1bsynybm3dnpcf7vlcvx85kdmcxg8"))))
    (build-system gnu-build-system)
    (arguments
     (list #:make-flags #~(list (string-append "VERSION="
                                               #$version) ;‘v…-nogit’ otherwise
                           (string-append "PREFIX="
                                          #$output)
                           "INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools"
                           (string-append "CC="
                                          #$(cc-for-target))
                           (string-append "PKG_CONFIG="
                                          #$(pkg-config-for-target))
                           ;; ‘This will be less of an option in the future, as more
                           ;; code gets rewritten in Rust.’
                           "NO_RUST=better")
           #:phases #~(modify-phases %standard-phases
                        (delete 'configure) ;no configure script
                        (replace 'check
                          ;; The test suite is moribund upstream (‘never been
                          ;; useful’), but let's keep running it as a sanity
                          ;; check until then.
                          (lambda* (#:key tests? make-flags #:allow-other-keys)
                            (when tests?
                              ;; We must manually build the test_helper first.
                              (apply invoke "make" "tests" make-flags)
                              (invoke (string-append #$(this-package-native-input
                                                        "python-pytest")
                                                     "/bin/pytest") "-k"
                                      ;; These fail (‘invalid argument’) on kernels
                                      ;; with a previous bcachefs version.
                                      (string-append "not test_format and "
                                       "not test_fsck and "
                                       "not test_list and "
                                       "not test_list_inodes and "
                                       "not test_list_dirent")))))
                        (add-after 'install 'patch-shell-wrappers
                          ;; These are overcomplicated wrappers that invoke readlink(1)
                          ;; to exec the appropriate bcachefs(8) subcommand.  We can
                          ;; simply patch in the latter file name directly, and do.
                          (lambda _
                            (let ((sbin/ (string-append #$output "/sbin/")))
                              (substitute* (find-files sbin/
                                                       (lambda (file stat)
                                                         (not (elf-file? file))))
                                (("SDIR=.*")
                                 "")
                                (("\\$\\{SDIR.*}/")
                                 sbin/))))))))
    (native-inputs (cons* pkg-config
                          ;; For generating documentation with rst2man.
                          python
                          python-docutils
                          ;; For tests.
                          python-pytest
                          (if (member (%current-system)
                                      (package-supported-systems valgrind))
                              (list valgrind)
                              '())))
    (inputs (list eudev
                  keyutils
                  libaio
                  libscrypt
                  libsodium
                  liburcu
                  `(,util-linux "lib")
                  lz4
                  zlib
                  `(,zstd "lib")))
    (home-page "https://bcachefs.org/")
    (synopsis "Tools to create and manage bcachefs file systems")
    (description
     "The bcachefs-tools are command-line utilities for creating, checking,
and otherwise managing bcachefs file systems.

Bcachefs is a @acronym{CoW, copy-on-write} file system supporting native
encryption, compression, snapshots, and (meta)data checksums.  It can use
multiple block devices for replication and/or performance, similar to RAID.

In addition, bcachefs provides all the functionality of bcache, a block-layer
caching system, and lets you assign different roles to each device based on its
performance and other characteristics.")
    (license license:gpl2+)))

(define-public bcachefs-tools/static
  (package
    (inherit bcachefs-tools)
    (name "bcachefs-tools-static")
    (arguments
     (substitute-keyword-arguments (package-arguments bcachefs-tools)
       ((#:make-flags make-flags)
        #~(append #$make-flags
                  (list "LDFLAGS=-static")))))
    (inputs (modify-inputs (package-inputs bcachefs-tools)
              (prepend `(,eudev "static")
                       `(,keyutils "static")
                       `(,libscrypt "static")
                       `(,lz4 "static")
                       `(,util-linux "static")
                       `(,zlib "static")
                       `(,zstd "static"))))))

(define-public bcachefs/static
  (package
    (name "bcachefs-static")
    (version (package-version bcachefs-tools))
    (source #f)
    (build-system trivial-build-system)
    (arguments
     (list #:modules '((guix build utils))
           #:builder
           #~(begin
               (use-modules (guix build utils)
                            (ice-9 ftw)
                            (srfi srfi-26))
               (mkdir-p #$output)
               (with-directory-excursion #$output
                 (install-file (string-append #$(this-package-input
                                                 "bcachefs-tools-static")
                                              "/sbin/bcachefs")
                               "sbin")
                 (remove-store-references "sbin/bcachefs")
                 (invoke "sbin/bcachefs" "version"))))) ; test suite
    (inputs
     (list bcachefs-tools/static))
    (home-page (package-home-page bcachefs-tools))
    (synopsis "Statically-linked bcachefs command from bcachefs-tools")
    (description "This package provides the statically-linked @command{bcachefs}
from the bcachefs-tools package.  It is meant to be used in initrds.")
    (license (package-license bcachefs-tools))))

(define-public exfatprogs
  (package
    (name "exfatprogs")
    (version "1.2.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/exfatprogs/exfatprogs")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1g5aqhjz0l58kvmis1j5b5qkn58hjs582f36ygiqkgxvp4njkny4"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list "--disable-static")))
    (native-inputs
     (list autoconf automake libtool pkg-config))
    (home-page "https://github.com/exfatprogs/exfatprogs")
    (synopsis "Tools to create, check, and repair exFAT file systems")
    (description
     "These are command-line user space tools for the @acronym{exFAT,
Extensible File Allocation Table} file systems.  Included are
@command{mkfs.exfat} to create (format) new exFAT file systems, and
@command{fsck.exfat} to check their consistency and repair them.")
    (license license:gpl2+)))

(define-public httpfs2
  (package
    (name "httpfs2")
    (version "0.1.5")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "mirror://sourceforge/httpfs/httpfs2/"
                           "httpfs2-" version ".tar.gz"))
       (sha256
        (base32
         "1h8ggvhw30n2r6w11n1s458ypggdqx6ldwd61ma4yd7binrlpjq1"))))
    (build-system gnu-build-system)
    (native-inputs
     (list asciidoc docbook-xml libxml2 libxslt pkg-config))
    (inputs
     (list fuse-2 gnutls))
    (arguments
     (list #:phases
           #~(modify-phases %standard-phases
               (delete 'configure)      ; no configure script
               (replace 'install
                 ;; There's no ‘install’ target. Install all variants manually.
                 (lambda _
                   (let* ((bin (string-append #$output "/bin"))
                          (man1 (string-append #$output "/share/man/man1")))
                     (mkdir-p bin)
                     (mkdir-p man1)
                     (for-each
                      (lambda (variant)
                        (let ((man1-page (string-append variant ".1")))
                          (install-file variant bin)
                          (install-file man1-page man1)))
                      (list "httpfs2"
                            "httpfs2-mt"
                            "httpfs2-ssl"
                            "httpfs2-ssl-mt"))))))
           #:make-flags
           #~(list (string-append "CC=" #$(cc-for-target)))
           #:parallel-build? #f         ; can result in missing man pages
           #:tests? #f))                ; no tests
    (home-page "https://sourceforge.net/projects/httpfs/")
    (synopsis "Mount remote files over HTTP")
    (description "httpfs2 is a @code{fuse} file system for mounting any
@dfn{HyperText} (HTTP or HTTPS) URL.  It uses HTTP/1.1 byte ranges to request
arbitrary bytes from the web server, without needing to download the entire
file.  This is particularly useful with large archives such as ZIP files and
ISO images when you only need to inspect their contents or extract specific
files.  Since the HTTP protocol itself has no notion of directories, only a
single file can be mounted.")
    (license license:gpl2+)))

(define-public jfsutils
  (package
    (name "jfsutils")
    (version "1.1.15")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "http://jfs.sourceforge.net/project/pub/jfsutils-"
                           version ".tar.gz"))
       (sha256
        (base32 "0kbsy2sk1jv4m82rxyl25gwrlkzvl3hzdga9gshkxkhm83v1aji4"))
       (patches (search-patches "jfsutils-add-sysmacros.patch"
                                "jfsutils-gcc-compat.patch"
                                "jfsutils-include-systypes.patch"))))
    (build-system gnu-build-system)
    (inputs
     (list `(,util-linux "lib")))
    (home-page "https://jfs.sourceforge.net/home.html")
    (synopsis "Utilities for managing JFS file systems")
    (description
     "The JFSutils are a collection of utilities for managing the @acronym{JFS,
Journaled File System}, a 64-bit journaling file system created by IBM and later
ported to the kernel Linux.  The following commands are available:
@enumerate
@item @command{fsck.jfs}: check and repair a JFS file system or replay its
transaction log.
@item @command{logdump}: dump the JFS journal log.
@item @command{logredo}: replay the JFS journal log.
@item @command{mkfs.jfs}: create a new JFS file system.
@item @command{xchklog}: save a JFS fsck log to a file.
@item @command{xchkdmp}: dump the contents of such a log file.
@item @command{xpeek}: a JFS file system editor with a shell-like interface.
@end enumerate\n")
    (license license:gpl3+)))          ; no explicit version given

(define-public jfsutils/static
  (static-package
   (package
     (inherit jfsutils)
     (name "jfsutils-static")
     (inputs
      `(("util-linux:static" ,util-linux "static")
        ,@(package-inputs jfsutils))))))

(define-public jfs_fsck/static
  (package
    (name "jfs_fsck-static")
    (version (package-version jfsutils))
    (source #f)
    (build-system trivial-build-system)
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils)
                      (ice-9 ftw)
                      (srfi srfi-26))
         (let* ((jfsutils (assoc-ref %build-inputs "jfsutils"))
                (fsck     "jfs_fsck")
                (out      (assoc-ref %outputs "out"))
                (sbin     (string-append out "/sbin")))
           (mkdir-p sbin)
           (with-directory-excursion sbin
             (install-file (string-append jfsutils "/sbin/" fsck)
                           ".")
             (remove-store-references fsck)
             (chmod fsck #o555))
           #t))))
    (inputs
     `(("jfsutils" ,jfsutils/static)))
    (home-page (package-home-page jfsutils))
    (synopsis "Statically-linked jfs_fsck command from jfsutils")
    (description "This package provides statically-linked jfs_fsck command taken
from the jfsutils package.  It is meant to be used in initrds.")
    (license (package-license jfsutils))))

(define-public nilfs-utils
  (package
    (name "nilfs-utils")
    (version "2.2.9")
    (source
      (origin
        (method url-fetch)
        (uri (string-append "https://nilfs.sourceforge.io/download"
                            "/nilfs-utils-" version ".tar.bz2"))
        (sha256
         (base32 "15vsayvzr8nc29n939sz9ddq46vpn53rp8h8qv484h88qac3kxjx"))))
    (build-system gnu-build-system)
    (arguments
     (list
       #:configure-flags
       #~(list "--enable-static=no")
       #:phases
       #~(modify-phases %standard-phases
           (add-before 'bootstrap 'force-bootstrap
             (lambda _
               (delete-file "configure")
               (substitute* "configure.ac"
                 (("\\[/etc\\]") "[${prefix}/etc]")
                 (("\\[/sbin\\]") "[${prefix}/sbin]")))))))
    (inputs
     (list (list util-linux "lib")))
    (native-inputs (list autoconf automake libtool))
    (home-page "https://nilfs.sourceforge.io/")
    (synopsis "Continuous Snapshotting Filesystem")
    (description
     "NILFS is a log-structured file system supporting versioning of the entire
file system and continuous snapshotting, which allows users to even restore
files mistakenly overwritten or destroyed just a few seconds ago.")
    (license license:gpl3+)))

(define-public disorderfs
  (package
    (name "disorderfs")
    (version "0.5.11")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://salsa.debian.org/reproducible-builds/disorderfs.git")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1pnrj0h8sgqwgsc18vz3fkqsp6vhigdbi75vdj0si1r6wgslnr7z"))))
    (build-system gnu-build-system)
    (native-inputs
     (list pkg-config))
    (inputs
     (list fuse-2 attr))
    (arguments
     `(#:phases (modify-phases %standard-phases
                  (delete 'configure))  ; no configure script
       #:make-flags (let ((out (assoc-ref %outputs "out")))
                      (list (string-append "PREFIX=" out)))
       #:test-target "test"
       ;; FIXME: Tests require 'run-parts' which is not in Guix yet.
       #:tests? #f))
    (home-page "https://salsa.debian.org/reproducible-builds/disorderfs")
    (synopsis "FUSE file system that introduces non-determinism")
    (description
     "An overlay FUSE file system that introduces non-determinism
into file system metadata.  For example, it can randomize the order
in which directory entries are read.  This is useful for detecting
non-determinism in the build process.")
    (license license:gpl3+)))

(define-public glusterfs
  (package
    (name "glusterfs")
    (version "7.0")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://download.gluster.org/pub/gluster/glusterfs/"
                           (version-major version) "/"
                           (version-major+minor version) "/"
                           "glusterfs-" version ".tar.gz"))
       (sha256
        (base32
         "0yzhx710ypj0j3m5dcgmmgvkp7p0rmmp2p7ld0axrm4vpwc2b1wa"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (let ((out (assoc-ref %outputs "out"))
             (p2 (assoc-ref %build-inputs "python-2")))
         (list (string-append "PYTHON=" p2 "/bin/python")
               (string-append "--with-initdir=" out "/etc/init.d")
               (string-append "--with-mountutildir=" out "/sbin")
               "--enable-cmocka"  ; unit tests
               ;; "--enable-debug"  ; debug build options
               ;; "--enable-asan"  ; Address Sanitizer
               ;; "--enable-tsan"  ; ThreadSanitizer
               ))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'autogen
           (lambda _ (invoke "./autogen.sh"))))))
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("libtirpc" ,libtirpc)
       ("rpcsvc-proto" ,rpcsvc-proto)
       ("python-2" ,python-2) ; must be version 2
       ("flex" ,flex)
       ("bison" ,bison)
       ("libtool" ,libtool)
       ("autoconf" ,autoconf)
       ("automake" ,automake)
       ("cmocka" ,cmocka)))
    (inputs
     `(("acl" ,acl)
       ("fuse" ,fuse-2)
       ("openssl" ,openssl)
       ("liburcu" ,liburcu)
       ("libuuid" ,util-linux "lib")
       ("libxml2" ,libxml2)
       ("readline" ,readline)
       ("zlib" ,zlib)
       ("libaio" ,libaio)
       ("rdma-core" ,rdma-core)))
    (home-page "https://www.gluster.org")
    (synopsis "Distributed file system")
    (description "GlusterFS is a distributed scalable network file system
suitable for data-intensive tasks such as cloud storage and media streaming.
It allows rapid provisioning of additional storage based on your storage
consumption needs.  It incorporates automatic failover as a primary feature.
All of this is accomplished without a centralized metadata server.")
    ;; The user may choose either LGPLv3+ or GPLv2 only.
    (license (list license:lgpl3+ license:gpl2+))))

(define-public curlftpfs
  (package
    (name "curlftpfs")
    (version "0.9.2")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "mirror://sourceforge/curlftpfs/curlftpfs/" version
                           "/curlftpfs-" version ".tar.gz"))
       (sha256
        (base32 "0n397hmv21jsr1j7zx3m21i7ryscdhkdsyqpvvns12q7qwwlgd2f"))
       (patches
        (search-patches "curlftpfs-fix-error-closing-file.patch"
                        "curlftpfs-fix-file-names.patch"
                        "curlftpfs-fix-memory-leak.patch"
                        "curlftpfs-fix-no_verify_hostname.patch"))))
    (build-system gnu-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'fix-test
           (lambda _
             ;; One of the 512-Byte block counts is definitely wrong.
             ;; See <https://sourceforge.net/p/curlftpfs/bugs/73/>.
             (substitute* "tests/ftpfs-ls_unittest.c"
              (("4426192") "12814800"))
             #t)))))
    (inputs
     (list curl glib fuse-2))
    (native-inputs
     (list pkg-config))
    (home-page "https://curlftpfs.sourceforge.net/")
    (synopsis "Mount remote file systems over FTP")
    (description
     "This is a file system client based on the FTP File Transfer Protocol.")
    (license license:gpl2+)))

(define-public libeatmydata
  (package
    (name "libeatmydata")
    (version "131")        ; also update the "debian-files" input if available
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://www.flamingspork.com/projects/libeatmydata/"
                           "libeatmydata-" version ".tar.gz"))
       (sha256
        (base32 "1i5bp9a2vmljci3ihzlxf8482106di2ayy1lpr0qb8rq472sh66g"))))
    (build-system gnu-build-system)
    (arguments
     ;; All tests pass---but only if the host kernel allows PTRACE_TRACEME.
     `(#:tests? #f
       #:configure-flags
       (list "--disable-static")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-file-names
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* (list "eatmydata.in" "eatmydata.sh.in")
               (("basename|readlink|uname" command)
                (search-input-file inputs
                                   (string-append "bin/" command))))))
         (add-before 'patch-file-names 'tighten-symlink-mode
           ;; When the ‘eatmydata’ helper detects that it's a symlink, it will
           ;; transparently invoke the command of the same name.  However, it's
           ;; *always* a link in Guix profiles and doesn't handle that well.
           ;; Patch it to treat its own $name specially.
           (lambda _
             (substitute* "eatmydata.in"
               (("-L \"\\$0\"" match)
                (string-append match " ] && [ "
                               "\"x$(basename \"$0\")\" != \"x$name\"")))))
         (add-after 'install 'install-debian-files
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((debian (assoc-ref inputs "debian-files"))
                    (out    (assoc-ref outputs "out"))
                    (share  (string-append out "/share")))
               (invoke "tar" "xvf" debian)
               (with-directory-excursion "debian"
                 (install-file "eatmydata.1" (string-append share "/man/man1"))
                 (install-file "eatmydata.bash-completion"
                               (string-append share "/bash-completion"
                                              "/completions")))))))))
    (native-inputs
     `(("debian-files"                  ; for the man page
        ,(origin
           ;; Debian being what it is, its version can lag behind a bit.  This
           ;; is tolerable as the man page is general and the command stable.
           (method url-fetch)
           (uri (string-append "https://deb.debian.org/debian/pool/main/"
                               "libe/libeatmydata/libeatmydata_130-2"
                               ".debian.tar.xz"))
           (sha256
            (base32 "1sg9g1nv3wl9ymzz33ig4ns563npkbxj67a64m7p34cc813jl95w"))))
       ;; For the test suite.
       ("strace" ,strace)
       ("which" ,which)))
    (inputs
     (list coreutils))
    (home-page "https://www.flamingspork.com/projects/libeatmydata/")
    (synopsis "Transparently ignore calls to synchronize data safely to disk")
    (description
     "Libeatmydata transparently disables most ways a program might force data
to be written to the file system, such as @code{fsync()} or @code{open(O_SYNC)}.

Such synchronisation calls provide important data integrity guarantees but are
expensive to perform and can significantly slow down software that (over)uses
them.

This price is worth paying if you care about the files being modified---which is
typically the case---or when manipulating important components of your system.
Please, @emph{do not} use something called ``eat my data'' in such cases!

However, it does not make sense to accept this performance hit if the data is
unimportant and you can afford to lose all of it in the event of a crash, for
example when running a software test suite.  Adding @file{libeatmydata.so} to
the @env{LD_PRELOAD} environment of such tasks will override all C library data
synchronisation functions with custom @i{no-op} ones that do nothing and
immediately return success.

A simple @command{eatmydata} script is included that does this for you.")
    (license license:gpl3+)))

(define-public libnfs
  (package
    (name "libnfs")
    (version "4.0.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/sahlberg/libnfs")
                    (commit (string-append "libnfs-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0i27wd4zvhjz7620q043p4d4mkx8zv2yz9adm1byin47dynahyda"))))
    (build-system gnu-build-system)
    (home-page "https://github.com/sahlberg/libnfs")
    (native-inputs
     (list autoconf automake libtool pkg-config))
    (synopsis "Client library for accessing NFS shares")
    (description "LIBNFS is a client library for accessing NFS shares over a
network.  LIBNFS offers three different APIs, for different use :

@enumerate
@item RAW, a fully asynchronous low level RPC library for NFS protocols.  This
  API provides very flexible and precise control of the RPC issued.
@item NFS ASYNC, a fully asynchronous library for high level vfs functions
@item NFS SYNC, a synchronous library for high level vfs functions.
@end enumerate\n")
    (license (list license:lgpl2.1+ ; library
                   license:gpl3+    ; tests
                   license:bsd-3    ; copied nsf4 files
                   ))))

(define-public apfs-fuse
  (let ((commit "66b86bd525e8cb90f9012543be89b1f092b75cf3")
        (revision "2"))
    (package
      (name "apfs-fuse")
      (version (git-version "0.0.0" revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                       (url "https://github.com/sgan81/apfs-fuse")
                       (recursive? #t) ; for lzfse
                       (commit commit)))
         (sha256
          (base32 "0f63slyzv8fbgshpzrx2g01x9h73g5yvh5kis4yazl19fjm2b05r"))
         (file-name (git-file-name name version))))
      (build-system cmake-build-system)
      (arguments
       `(#:tests? #f ; No test suite
         #:phases
         (modify-phases %standard-phases
           ;; No 'install' target in CMakeLists.txt
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (bin (string-append out "/bin"))
                      (lib (string-append out "/lib"))
                      (doc (string-append out "/share/doc/"
                                          (string-append ,name "-" ,version))))
                 (install-file "apfs-dump" bin)
                 (install-file "apfs-dump-quick" bin)
                 (install-file "apfs-fuse" bin)
                 (install-file "../source/README.md" doc)))))))
      (inputs
       (list bzip2 fuse zlib))
      (synopsis "Read-only FUSE driver for the APFS file system")
      (description "APFS-FUSE is a read-only FUSE driver for the @dfn{Apple File
System} (APFS).  It is currently in an experimental state — it may not be able
to read all files, and it does not support all the compression methods in
APFS.")
      (home-page "https://github.com/sgan81/apfs-fuse")
      (license license:gpl2+))))

(define-public xfstests
  ;; The last release (1.1.0) is from 2011.
  (let ((revision "3")
        (commit "8de535c53887bb49adae74a1b2e83e77d7e8457d"))
    (package
      (name "xfstests")
      (version (git-version "1.1.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "1sbkryl04xflrk6jb4fsl3h2whilj5m3vpdkpwwb26idp7ckjjv6"))))
      (build-system gnu-build-system)
      (arguments
       (list
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'unpack 'patch-tool-locations
              (lambda* (#:key inputs #:allow-other-keys)
                (substitute* "common/config"
                  ;; Make absolute file names relative.
                  (("(MKFS_PROG=\").*(\")" _ pre post)
                   (string-append pre "mkfs" post)))
                (for-each (lambda (file)
                            (substitute* file
                              (("( -s|#.|[= ])(/bin/sh|/bin/bash)" _ pre match)
                               (string-append pre
                                              (search-input-file inputs match)))
                              (("/bin/(rm|true)" match)
                               (search-input-file inputs match))
                              (("/usr(/bin/time)" _ match)
                               (search-input-file inputs match))))
                          (append (find-files "common" ".*")
                                  (find-files "tests" ".*")
                                  (find-files "tools" ".*")
                                  (find-files "src" "\\.(c|sh)$")))))
            (replace 'bootstrap
              (lambda* (#:key make-flags #:allow-other-keys)
                (substitute* "Makefile"
                  ;; Avoid a mysterious (to me) ‘permission denied’ error.
                  (("cp ") "cp -f "))
                (substitute* "m4/package_utilies.m4"
                  ;; Fix the bogus hard-coded paths for every single binary.
                  (("(AC_PATH_PROG\\(.*, ).*(\\))" _ pre post)
                   (string-append pre (getenv "PATH") post)))
                (apply invoke "make" "configure" make-flags)))
            (add-after 'install 'wrap-xfstests/check
              ;; Keep wrapping distinct from 'create-helper-script below: users
              ;; must be able to invoke xfstests/check directly if they prefer.
              (lambda* (#:key inputs #:allow-other-keys)
                (wrap-program (string-append #$output "/xfstests/check")
                  ;; Prefix the user's PATH with the minimum required tools.
                  ;; The suite has many other optional dependencies and will
                  ;; automatically select tests based on the original PATH.
                  `("PATH" ":" prefix
                    ,(map (lambda (file)
                            (dirname (search-input-file inputs file)))
                          (list "bin/setfacl"         ; acl
                                "bin/attr"            ; attr
                                "bin/bc"              ; bc
                                "bin/df"              ; coreutils
                                "bin/hostname"        ; inetutils
                                "bin/perl"            ; perl
                                "sbin/mkfs.xfs")))))) ; xfsprogs
            (add-after 'install 'create-helper
              ;; Upstream installs only a ‘check’ script that's not in $PATH and
              ;; would try to write to the store without explaining how to change
              ;; that.  Install a simple helper script to make it discoverable.
              (lambda* (#:key inputs #:allow-other-keys)
                (let* ((check  (string-append #$output "/xfstests/check"))
                       (bin    (string-append #$output "/bin"))
                       (helper (string-append bin "/xfstests-check")))
                  (mkdir-p bin)
                  (with-output-to-file helper
                    (lambda _
                      (format #t "#!~a --no-auto-compile\n!#\n"
                              (search-input-file inputs "/bin/guile"))
                      (write
                       `(begin
                          (define (try proc dir)
                            "Try to PROC DIR.  Return DIR on success, else #f."
                            (with-exception-handler (const #f)
                              (lambda _ (proc dir) dir)
                              #:unwind? #t))

                          (define args
                            (cdr (command-line)))

                          (when (or (member "--help" args)
                                    (member "-h" args))
                            (format #t "Usage: ~a [OPTION]...
This Guix helper sets up a new writable RESULT_BASE if it's unset, then executes
xfstest's \"~a\" command (with any OPTIONs) as documented below.\n\n"
                                    ,(basename helper)
                                    ,(basename check)))

                          (let* ((gotenv-base (getenv "RESULT_BASE"))
                                 (base (or gotenv-base
                                           (let loop ((count 0))
                                             (or (try mkdir
                                                      (format #f "xfstests.~a"
                                                              count))
                                                 (loop (+ 1 count))))))
                                 (result-base (if (string-prefix? "/" base)
                                                  base
                                                  (string-append (getcwd) "/"
                                                                 base))))
                            (setenv "RESULT_BASE" result-base)
                            ;; CHECK must run in its own directory or will fail.
                            (chdir ,(dirname check))
                            (let ((status
                                   (status:exit-val (apply system* ,check args))))
                              (unless gotenv-base
                                (try rmdir result-base))
                              status))))))
                  (chmod helper #o755)))))))
      (native-inputs
       (list autoconf automake libtool))
      (inputs
       (list acl
             attr
             bc
             guile-3.0                  ; for our xfstests-check helper script
             inetutils
             `(,util-linux "lib")
             perl
             time
             xfsprogs))
      (home-page "https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git")
      (synopsis "File system @acronym{QA, Quality Assurance} test suite")
      (description
       "The @acronym{FSQA, File System Quality Assurance} regression test suite,
more commonly known as xfstests, comprises over 1,500 tests that exercise
(@dfn{torture}) both the user- and kernel-space parts of many different file
systems.

As the package's name subtly implies, it was originally developed to test the
XFS file system.  Today, xfstests is the primary test suite for all major file
systems supported by the kernel Linux including XFS, ext4, and Btrfs, but also
virtual and network file systems such as NFS, 9P, and the overlay file system.

The packaged @command{check} script is not in @env{PATH} but can be invoked
with the included @command{xfstests-check} helper.")
      (license license:gpl2))))

(define-public zfs
  (package
    (name "zfs")
    (version "2.1.12")
    (outputs '("out" "module" "src"))
    (source
      (origin
        (method url-fetch)
          (uri (string-append "https://github.com/openzfs/zfs/releases"
                              "/download/zfs-" version
                              "/zfs-" version ".tar.gz"))
          (sha256
           (base32 "0vbf9kfryprb2mbb65jllf6xpsy44xskshglyqqwj4iyxmma5nk4"))))
    (build-system linux-module-build-system)
    (arguments
     (list
      ;; The ZFS kernel module should not be downloaded since the license
      ;; terms don't allow for distributing it, only building it locally.
      #:substitutable? #f
      ;; Tests cannot run in an unprivileged build environment.
      #:tests? #f
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'configure 'really-configure
            (lambda* (#:key inputs #:allow-other-keys)
              (substitute* "configure"
                (("-/bin/sh") (string-append "-" (which "sh"))))
              (invoke "./configure"
                      "--with-config=all"
                      (string-append "--prefix=" #$output)
                      (string-append "--with-dracutdir=" #$output
                                     "/lib/dracut")
                      (string-append "--with-udevdir=" #$output
                                     "/lib/udev")
                      (string-append "--with-mounthelperdir=" #$output
                                     "/sbin")
                      (string-append "--with-linux="
                                     (search-input-directory
                                      inputs
                                      "lib/modules/build")))))
          (add-after 'unpack 'patch-source
            (lambda* (#:key inputs #:allow-other-keys)
              ;; New feature "compatibility=" in 2.1.0.
              ;; This feature looks up in two locations:
              ;;   /etc/zfs/compatibility.d/
              ;;   /usr/share/zfs/compatibility.d/
              ;; The first is intended for system-specific compatibility
              ;; sets, while the second is what is installed with the
              ;; OpenZFS package, so use the absolute path for the first
              ;; (which requires patching in the file) and the store path
              ;; for the second (which it gets by default).
              (substitute* "include/sys/fs/zfs.h"
                (("#define\tZPOOL_SYSCONF_COMPAT_D.*$")
                 ;; Use absolute path.
                 "#define\tZPOOL_SYSCONF_COMPAT_D\t\"/etc/zfs/compatibility.d\"\n"))
              ;; Also update the manual, which uses absolute paths, so that
              ;; /usr/share/zfs/compatibility.d/ is referred via the store.
              (substitute* '("man/man7/zpoolprops.7"
                             "man/man7/zpool-features.7")
                (("/usr/share/zfs/compatibility.d")
                 (string-append #$output "/share/zfs/compatibility.d")))
              (substitute* "etc/Makefile.in"
                ;; This just contains an example configuration file for
                ;; configuring ZFS on traditional init systems, skip it
                ;; since we cannot use it anyway; the install target becomes
                ;; misdirected.
                (("= default ") "= "))
              (substitute* "lib/libzfs/os/linux/libzfs_util_os.c"
                ;; Use path to /gnu/store/*-kmod in actual path that is
                ;; exec'ed.
                (("\"/sbin/modprobe\"")
                 (string-append "\""
                                (search-input-file inputs "/bin/modprobe")
                                "\""))
                ;; Just use 'modprobe' in message to user, since Guix
                ;; does not have a traditional /sbin/
                (("'/sbin/modprobe ") "'modprobe "))
              (substitute* "contrib/Makefile.in"
                ;; This is not configurable nor is its hard-coded /usr prefix.
                ((" initramfs") ""))
              (substitute* "module/os/linux/zfs/zfs_ctldir.c"
                (("/usr/bin/env\", \"umount")
                 (string-append (search-input-file inputs "/bin/umount")
                                "\", \"-n"))
                (("/usr/bin/env\", \"mount")
                 (string-append (search-input-file inputs "/bin/mount")
                                "\", \"-n")))
              (substitute* "lib/libzfs/os/linux/libzfs_mount_os.c"
                (("/bin/mount") (search-input-file inputs "/bin/mount"))
                (("/bin/umount") (search-input-file inputs "/bin/umount")))
              (substitute* "lib/libshare/os/linux/nfs.c"
                (("/usr/sbin/exportfs")
                 (search-input-file inputs "/sbin/exportfs")))
              (substitute* "config/zfs-build.m4"
                (("\\$sysconfdir/init.d")
                 (string-append #$output "/etc/init.d")))
              (substitute* '("etc/zfs/Makefile.am"
                             "cmd/zed/Makefile.am")
                (("\\$\\(sysconfdir)") (string-append #$output "/etc")))
              (substitute* "cmd/vdev_id/vdev_id"
                (("PATH=/bin:/sbin:/usr/bin:/usr/sbin")
                 (string-append "PATH="
                                (dirname (which "chmod")) ":"
                                (dirname (which "grep")) ":"
                                (dirname (which "sed")) ":"
                                (dirname (which "gawk")))))
              (substitute* "contrib/pyzfs/Makefile.in"
                ((".*install-lib.*") ""))
              (substitute* '("Makefile.am" "Makefile.in")
                (("\\$\\(prefix)/src") (string-append #$output:src "/src")))
              (substitute* (find-files "udev/rules.d/" ".rules.in$")
                (("/sbin/modprobe")
                 (search-input-file inputs "/bin/modprobe")))))
          (replace 'build
            (lambda _ (invoke "make")))
          (replace 'install
            (lambda* (#:key inputs native-inputs #:allow-other-keys)
              (let* ((kmod (assoc-ref (or native-inputs inputs) "kmod")))
                (invoke "make" "install"
                        (string-append "DEFAULT_INITCONF_DIR="
                                       #$output "/etc/default")
                        (string-append "DEPMOD="
                                       (search-input-file
                                        (or native-inputs inputs)
                                        "/bin/depmod"))
                        (string-append "INSTALL_PATH=" #$output)
                        (string-append "INSTALL_MOD_PATH=" #$output:module)
                        "INSTALL_MOD_STRIP=1")
                (install-file
                 "contrib/bash_completion.d/zfs"
                 (string-append #$output
                                "/share/bash-completion/completions"))))))))
    (native-inputs
     (list attr kmod pkg-config))
    (inputs (list eudev
                  kmod
                  libaio
                  libtirpc
                  nfs-utils
                  openssl
                  python
                  python-cffi
                  util-linux
                  `(,util-linux "lib")
                  zlib))
    (home-page "https://zfsonlinux.org/")
    (synopsis "OpenZFS on Linux")
    (description
     "OpenZFS is an advanced file system and volume manager which was
originally developed for Solaris and is now maintained by the OpenZFS
community.")
    (license license:cddl1.0)))

(define-public zfs-auto-snapshot
  (package
    (name "zfs-auto-snapshot")
    (version "1.2.4")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url
              (string-append "https://github.com/zfsonlinux/" name))
             (commit
              (string-append "upstream/" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0m4xw7h5qlbn5zdf9wb137pcr5l7hyrr7w2dgr16dfm5ay64vvfq"))))
    (build-system gnu-build-system)
    (inputs
     ;; Note: if you are inheriting from the above zfs package in order
     ;; to provide a specific stable kernel version, you should also
     ;; inherit this package and replace the sole input below.
     (list zfs))
    (arguments
     `(#:tests? #f ; No tests
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         ;; Guix System may not have a traditional cron system, but
         ;; the cron scripts installed by this package are convenient
         ;; to use as targets for an mcron job specification, so make
         ;; sure they can be run in-store.
         (add-before 'install 'fix-scripts
           (lambda* (#:key outputs inputs #:allow-other-keys)
             (let* ((out                (assoc-ref outputs "out"))
                    (zfs-auto-snapshot  (string-append
                                         out
                                         "/sbin/zfs-auto-snapshot"))
                    (zfs-package        (assoc-ref inputs "zfs"))
                    (zpool              (string-append
                                         zfs-package
                                         "/sbin/zpool"))
                    (zfs                (string-append
                                         zfs-package
                                         "/sbin/zfs")))
               (substitute* '("etc/zfs-auto-snapshot.cron.daily"
                              "etc/zfs-auto-snapshot.cron.frequent"
                              "etc/zfs-auto-snapshot.cron.hourly"
                              "etc/zfs-auto-snapshot.cron.monthly"
                              "etc/zfs-auto-snapshot.cron.weekly")
                 (("zfs-auto-snapshot")
                  zfs-auto-snapshot))
               (substitute* "src/zfs-auto-snapshot.sh"
                 (("LC_ALL=C zfs list")
                  (string-append "LC_ALL=C " zfs " list"))
                 (("LC_ALL=C zpool status")
                  (string-append "LC_ALL=C " zpool " status"))
                 (("zfs snapshot")
                  (string-append zfs " snapshot"))
                 (("zfs destroy")
                  (string-append zfs " destroy"))))))
         ;; Provide DESTDIR and PREFIX on make command.
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (invoke "make" "install"
                       "PREFIX="
                       (string-append "DESTDIR=" out)))
             #t)))))
    (home-page "https://github.com/zfsonlinux/zfs-auto-snapshot")
    (synopsis "Automatically create, rotate and destroy ZFS snapshots")
    (description "An alternative implementation of the zfs-auto-snapshot
service for Linux that is compatible with zfs-linux (now OpenZFS) and
zfs-fuse.

On Guix System, you will need to invoke the included shell scripts as
@code{job} definitions in your @code{operating-system} declaration.")
    (license license:gpl2+)))

(define-public mergerfs
  (package
    (name "mergerfs")
    (version "2.33.5")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/trapexit/mergerfs/"
                           "releases/download/" version "/"
                           "mergerfs-" version ".tar.gz"))
       (sha256
        (base32 "0m0fg191ax855yb20vqpvn6v2gc3i5xdizx09pgpymj1ybxc7yyw"))))
    (build-system gnu-build-system)
    (arguments
     `(#:make-flags
       (list (string-append "CC=" ,(cc-for-target))
             (string-append "CXX=" ,(cxx-for-target))
             (string-append "PREFIX=" (assoc-ref %outputs "out")))
       #:tests? #f                     ; all require a kernel with FUSE loaded
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)            ; no configure script
         (add-after 'unpack 'set-file-names
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (substitute* "libfuse/Makefile"
               (("/sbin") "$(EXEC_PREFIX)/sbin")
               (("chown") "true")  ; disallowed in the build environment
               (("strip") "true")) ; breaks cross-compilation
             ;; These were copied from the fuse-2 package.
             (substitute* '("libfuse/lib/mount_util.c"
                            "libfuse/util/mount_util.c")
               (("/bin/(u?)mount" _ maybe-u)
                (search-input-file inputs
                                   (string-append "bin/" maybe-u
                                                  "mount"))))
             (substitute* '("libfuse/util/mount.mergerfs.c")
               (("/bin/sh" command)
                (string-append (assoc-ref inputs "bash-minimal") command))
               ;; mount.mergerfs tries to execute `mergerfs`, which cannot be found
               ;; without an absolute path. Hard-coding the path is fine, since we don’t
               ;; link mount.mergerfs to mount.fuse anyway.
               (("add_arg\\(&command, type\\);")
                (string-append "add_arg(&command, \"" (assoc-ref outputs "out")
                               "/bin/mergerfs\");"))))))))
    ;; Mergerfs bundles a heavily modified copy of fuse.
    (inputs
     (list bash-minimal util-linux))
    (home-page "https://github.com/trapexit/mergerfs")
    (synopsis "Featureful union file system")
    (description "mergerfs is a union file system geared towards simplifying
storage and management of files across numerous commodity storage devices.  It
is similar to mhddfs, unionfs, and aufs.")
    (license (list
              license:isc                   ; mergerfs
              license:gpl2 license:lgpl2.0  ; Imported libfuse code.
              ))))

(define-public mergerfs-tools
  (let ((commit "3b6fe008517aeda715c306eaf4914f6f537da88d")
        (revision "3"))
    (package
      (name "mergerfs-tools")
      ;; No released version exists.
      (version (git-version "0.0.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/trapexit/mergerfs-tools")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "15pgym6c4viy57ccgp28dnqwh12f3gr02axg86y578aqa2yaa0ad"))))
      (build-system copy-build-system)
      (inputs
       (list python python-xattr rsync))
      (arguments
       '(#:install-plan
         '(("src/" "bin/"))
         #:phases
         (modify-phases %standard-phases
           (add-after 'unpack 'patch-paths
             (lambda* (#:key inputs #:allow-other-keys)
               (substitute* (find-files "src" "^mergerfs\\.")
                 (("'rsync'")
                  (string-append "'" (assoc-ref inputs "rsync") "/bin/rsync'"))
                 (("'rm'")
                  (string-append "'" (assoc-ref inputs "coreutils") "/bin/rm'")))
               (substitute* "src/mergerfs.mktrash"
                 (("xattr")
                  (search-input-file inputs "/bin/xattr"))
                 (("mkdir")
                  (search-input-file inputs "/bin/mkdir"))))))))
      (synopsis "Tools to help manage data in a mergerfs pool")
      (description "mergerfs-tools is a suite of programs that can audit
permissions and ownership of files and directories on a mergerfs volume,
duplicates files and directories across branches in its pool, find and remove
duplicate files, balance pool drives, consolidate files in a single mergerfs
directory onto a single drive and create FreeDesktop.org Trash specification
compatible directories.")
      (home-page "https://github.com/trapexit/mergerfs-tools")
      (license license:isc))))

(define-public python-dropbox
  (package
    (name "python-dropbox")
    (version "11.36.2")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "dropbox" version))
        (sha256
         (base32 "00650gk8557x3f38nd8a1mdby7v1l8l4l72aq48qpiw6shb3v3fl"))
        (snippet
         '(begin
            (use-modules (guix build utils))
            (substitute* "setup.py"
              (("pytest-runner == 5\\.2\\.0") "pytest-runner"))))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))  ; Tests require a network connection.
    (native-inputs
     (list python-pytest python-pytest-runner))
    (propagated-inputs
     (list python-requests python-six python-stone))
    (home-page "https://www.dropbox.com/developers")
    (synopsis "Official Dropbox API Client")
    (description "This package provides a Python SDK for integrating with the
Dropbox API v2.")
    (license license:expat)))

(define-public dbxfs
  (package
    (name "dbxfs")
    (version "1.0.63")
    (source
      (origin
        ;; Release tarball contains files not in git repository.
        (method git-fetch)
        (uri (git-reference
               (url "https://thelig.ht/code/dbxfs")
               (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
         (base32
          "1vzfhw3z2r0rb6s0qdzirh3pl7rv1z8xmxa0z5h7h1wqhpl05ai7"))
        (patches (search-patches "dbxfs-remove-sentry-sdk.patch"))
        (snippet
         #~(begin (use-modules (guix build utils))
                  ;; Don't check for package updates.
                  (substitute* "dbxfs/main.py"
                    (("if version") "if False"))))))
    (build-system python-build-system)
    (arguments
     '(#:tests? #f)) ; tests requires safefs
    (propagated-inputs
     (list python-appdirs
           python-block-tracing
           python-dropbox
           python-keyring
           python-keyrings.alt
           python-privy
           python-userspacefs))
  (home-page "https://thelig.ht/code/dbxfs/")
  (synopsis "User-space file system for Dropbox")
  (description
   "@code{dbxfs} allows you to mount your Dropbox folder as if it were a
local file system using FUSE.")
  (license license:gpl3+)))

(define-public go-github-com-hanwen-fuse
  (package
    (name "go-github-com-hanwen-fuse")
    (version "2.0.3")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/hanwen/go-fuse")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1y44d08fxyis99s6jxdr6dbbw5kv3wb8lkhq3xmr886i4w41lz03"))))
    (build-system go-build-system)
    (arguments
     `(#:import-path "github.com/hanwen/go-fuse"))
    (propagated-inputs
     (list go-golang-org-x-sys))
    (home-page "https://github.com/hanwen/go-fuse")
    (synopsis "FUSE bindings for Go")
    (description
     "This package provides Go native bindings for the FUSE kernel module.")
    (license license:bsd-3)))

(define-public rewritefs
  (let ((revision "1")
        (commit "3a56de8b5a2d44968b8bc3885c7d661d46367306"))
    (package
      (name "rewritefs")
      (version (git-version "0.0.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/sloonz/rewritefs")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "1w2rik0lhqm3wr68x51zs45gqfx79l7fi4p0sqznlfq7sz5s8xxn"))))
      (build-system gnu-build-system)
      (arguments
       (list
        #:modules
        '((guix build gnu-build-system)
          (guix build utils)
          (srfi srfi-26))
        #:make-flags
        #~(list (string-append "PREFIX=" #$output))
        #:test-target "test"
        #:tests? #f                    ; all require a kernel with FUSE loaded
        #:phases
        #~(modify-phases %standard-phases
            (delete 'configure)         ; no configure script
            (add-after 'install 'install-examples
              (lambda _
                (let ((doc (string-append #$output "/share/doc/"
                                          #$name "-" #$version)))
                  (for-each (cut install-file <> (string-append doc "/examples"))
                            (find-files "." "^config\\."))))))))
      (native-inputs
       (list pkg-config))
      (inputs
       (list fuse pcre))
      (home-page "https://github.com/sloonz/rewritefs")
      (synopsis "FUSE file system that changes particular file names")
      (description
       "RewriteFS is a @acronym{FUSE, File system in USEr space} to change the
name of accessed files on the fly based on any number of regular expressions.
It's like the @code{rewrite} action of many Web servers, but for your file
system.  For example, it can help keep your home directory tidy by transparently
rewriting the location of configuration files of software that doesn't follow
the XDG directory specification from @file{~/.@var{name}} to
@file{~/.config/@var{name}}.")
      (license license:gpl2+))))

(define-public squashfuse
  (package
    (name "squashfuse")
    (version "0.1.105")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/vasi/squashfuse")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "03aw8pw8694jyrzpnbry05rk9718sqw66kiyq878bbb679gl7224"))))
    (build-system gnu-build-system)
    (native-inputs (list autoconf automake libtool pkg-config))
    (inputs (list attr fuse-2 xz zlib `(,zstd "lib")))
    (home-page "https://github.com/vasi/squashfuse")
    (synopsis "Fuse filesystem to mount squashfs archives")
    (description
     "Squashfuse lets you mount SquashFS archives in user-space.  It supports
almost all features of the SquashFS format, yet is still fast and
memory-efficient.")
    (license license:bsd-2)))

(define-public tmsu
  (package
    (name "tmsu")
    (version "0.7.5")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/oniony/TMSU")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0834hah7p6ad81w60ifnxyh9zn09ddfgrll04kwjxwp7ypbv38wq"))))
    (build-system go-build-system)
    (arguments
     `(#:import-path "github.com/oniony/TMSU"
       #:unpack-path ".."
       #:install-source? #f
       #:phases
       (modify-phases %standard-phases
         (add-after 'install 'post-install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               ;; The go build system produces /bin/TMSU -> install as /bin/tmsu
               (rename-file (string-append out "/bin/TMSU")
                            (string-append out "/bin/tmsu"))))))))
    (inputs
     (list go-github-com-mattn-go-sqlite3 go-github-com-hanwen-fuse))
    (home-page "https://github.com/oniony/TMSU")
    (synopsis "Tag files and access them through a virtual file system")
    (description
     "TMSU is a tool for tagging your files.  It provides a simple
command-line utility for applying tags and a virtual file system to give you a
tag-based view of your files from any other program.  TMSU does not alter your
files in any way: they remain unchanged on disk, or on the network, wherever
your put them.  TMSU maintains its own database and you simply gain an
additional view, which you can mount where you like, based upon the tags you
set up.")
    (license license:gpl3+)))

(define-public udftools
  (package
    (name "udftools")
    (version "2.3")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/pali/udftools")
                    (commit version)))
              (sha256
               (base32
                "1nl2s61znyzaap23zhbdg3znj6l6akr313fchn5wwvjzj8k70is9"))
              (file-name (git-file-name name version))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list (string-append "--docdir=" (assoc-ref %outputs "out")
                            "/share/doc/" ,name "-" ,version))))
    (native-inputs
     (list automake autoconf libtool pkg-config))
    (home-page "https://github.com/pali/udftools")
    (synopsis "Tools to manage UDF file systems and DVD/CD-R(W) drives")
    (description "@code{udftools} is a set of programs for reading
and modifying @acronym{UDF, Universal Disk Format} file systems.
@acronym{UDF, Universal Disk Format} is a file system mostly used for DVDs
and other optical media.  It supports read-only media (DVD/CD-R)
and rewritable media that wears out (DVD/CD-RW).")
    (license license:gpl2+)))

(define-public fuse-overlayfs
  (package
    (name "fuse-overlayfs")
    (version "1.13")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/containers/fuse-overlayfs")
                    (commit (string-append "v" version))))
              (sha256
               (base32
                "03gqb4czswqhx6zrv9jj88mf3mczk4m7azcjgr785c2lmga442ly"))
              (file-name (git-file-name name version))))
    (build-system gnu-build-system)
    (native-inputs
     (list automake autoconf libtool pkg-config))
    (inputs
     (list fuse))
    (home-page "https://github.com/containers/fuse-overlayfs")
    (synopsis "FUSE implementation of overlayfs")
    (description "This package provides an implementation of overlay+shiftfs
in FUSE for rootless containers.")
    (license license:gpl3)))

(define-public bees
  (package
    (name "bees")
    (version "0.10")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/Zygo/bees")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (modules '((guix build utils)))
              (snippet
               ;; Unbundle cityhash.
               #~(begin
                   (for-each delete-file
                             '("lib/city.cc" "include/crucible/city.h"))
                   (substitute* "lib/Makefile"
                     (("city.o.*") ""))
                   (substitute* "src/bees-hash.cc"
                     (("#include .crucible/city.h.") "#include <city.h>"))))
              (sha256
               (base32
                "1j1v9bxijs8gvrb7rg0q1158xjvmfc8dlzwx768fxf3w8w2gfwvz"))))
    (build-system gnu-build-system)
    (arguments
     (list #:test-target "test"
           #:make-flags
           #~(list (string-append "CC=" #$(cc-for-target))
                   (string-append "DESTDIR=" #$output)
                   (string-append "BEES_VERSION=" #$version)
                   "PREFIX=''")
           #:phases
           #~(modify-phases %standard-phases
               (delete 'configure)
               (add-after 'unpack 'fixpath
                 (lambda* (#:key inputs #:allow-other-keys)
                   (substitute* "scripts/beesd.in"
                     (((string-append "\\<(" (string-join (list "realpath"
                                                                "uuidparse"
                                                                "grep"
                                                                "false"
                                                                "sed"
                                                                "true"
                                                                "head"
                                                                "mkdir"
                                                                "mount"
                                                                "touch"
                                                                "du"
                                                                "cut"
                                                                "rm"
                                                                "truncate"
                                                                "chmod")
                                                          "|") ")\\>") command)
                      (search-input-file inputs (string-append "/bin/" command)))

                     (("btrfs sub")
                      (string-append (search-input-file inputs "/bin/btrfs")
                                     " sub"))))))))
    (inputs (list btrfs-progs cityhash util-linux))
    (home-page "https://github.com/Zygo/bees")
    (synopsis "Deduplication agent for btrfs file systems")
    (description
     "@acronym{BEES, Best-Effort Extent-Same} is a block-oriented, user-space
deduplication agent designed for large btrfs file systems.  It combines off-line
data deduplication with incremental scanning to minimize the time your data
spend on disk between being written and being deduplicated.")
    (license (list license:gpl3+     ; the combined work
                   license:zlib      ; lib/crc64.cc
                   license:gpl2))))  ; include/crucible/btrfs.h

(define-public dwarfs
  (package
    (name "dwarfs")
    (version "0.6.2")
    (source (origin
              (method url-fetch)
              ;; The release archive is needed so that version.h is included.
              (uri (string-append "https://github.com/mhx/dwarfs/releases/download/v"
                                  version "/dwarfs-" version ".tar.xz"))
              (sha256
               (base32
                "1kncxf85gsj3anck8ccjmxn2azp5ifqbgkiky2kharmvphkbmfcv"))
              (snippet
               #~(begin
                   (use-modules (guix build utils))
                   ;; Prefer system libraries instead of submodules.
                   ;; TODO: Package fbthrift.
                   ;; TODO: Can we use Guix own folly?  There is no CMake option for it.
                   ;; TODO: Package parallel-hashmap.
                   (for-each delete-file-recursively
                             '(;; "fbthrift"
                               ;; "folly"
                               ;; "parallel-hashmap"
                               "xxHash"
                               "zstd"))))))
    (build-system cmake-build-system)
    (arguments
     '(#:tests? #f ; TODO: 1 test fails because 'modprobe fuse' needs privileged access.
       #:configure-flags
       (list "-DPREFER_SYSTEM_ZSTD=ON"
             "-DPREFER_SYSTEM_XXHASH=ON"
             "-DPREFER_SYSTEM_GTEST=ON"
             "-DWITH_TESTS=ON"
             ;; Disable man pages since ronn fails to run without hpricot.
             "-DWITH_MAN_PAGES=OFF")))
    (native-inputs
     (list
      ;; FIXME: Building with ronn fails because hpricot is missing from Guix.
      folly googletest libdwarf libevent pkg-config))
    (inputs
     (list
      boost
      double-conversion
      fmt
      fuse
      gflags
      jemalloc
      libarchive
      libunwind
      lz4
      openssl
      xxhash
      xz
      `(,zstd "lib")))
    (home-page "https://github.com/mhx/dwarfs")
    (synopsis "Fast high compression read-only file system")
    (description "DwarFS is a read-only file system with a focus on achieving
very high compression ratios in particular for very redundant data.

DwarFS also doesn't compromise on speed and for some cases it is on par with
or performs better than SquashFS.  For the primary use case, DwarFS
compression is an order of magnitude better than SquashFS compression, it's 6
times faster to build the file system, it's typically faster to access files
on DwarFS and it uses less CPU resources.

Distinct features of DwarFS are:

@itemize

@item Clustering of files by similarity using a similarity hash function.  This
makes it easier to exploit the redundancy across file boundaries.

@item Segmentation analysis across file system blocks in order to reduce the
size of the uncompressed file system.  This saves memory when using the
compressed file system and thus potentially allows for higher cache hit rates
as more data can be kept in the cache.

@item Highly multi-threaded implementation.  Both the file system creation tool
as well as the FUSE driver are able to make good use of the many cores of your
system.

@item Optional experimental Python scripting support to provide custom
filtering and ordering functionality.

@end itemize\n")
    (license license:gpl3)))