aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.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 compression)
  #:use-module (guix gexp)
  #:use-module (guix ui)
  #:use-module ((gnu packages compression) #:hide (zip))
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-9)
  #:use-module (ice-9 match)
  #:export (compressor
            compressor?
            compressor-name
            compressor-extension
            compressor-command
            %compressors
            lookup-compressor))

;; Type of a compression tool.
(define-record-type <compressor>
  (compressor name extension command)
  compressor?
  (name       compressor-name)      ;string (e.g., "gzip")
  (extension  compressor-extension) ;string (e.g., ".lz")
  (command    compressor-command))  ;gexp (e.g., #~(list "/gnu/store/…/gzip"
                                    ;                    "-9n" ))

(define %compressors
  ;; Available compression tools.
  (list (compressor "gzip"  ".gz"
                    #~(list #+(file-append gzip "/bin/gzip") "-9n"))
        (compressor "lzip"  ".lz"
                    #~(list #+(file-append lzip "/bin/lzip") "-9"))
        (compressor "xz"    ".xz"
                    #~(append (list #+(file-append xz "/bin/xz")
                                    "-e")
                              (%xz-parallel-args)))
        (compressor "bzip2" ".bz2"
                    #~(list #+(file-append bzip2 "/bin/bzip2") "-9"))
        (compressor "zstd" ".zst"
                    ;; The default level 3 compresses better than gzip in a
                    ;; fraction of the time, while the highest level 19
                    ;; (de)compresses more slowly and worse than xz.
                    #~(list #+(file-append zstd "/bin/zstd") "-3"
                            (format #f "--threads=~a" (parallel-job-count))))
        (compressor "none" "" #f)))

(define (lookup-compressor name)
  "Return the compressor object called NAME.  Error out if it could not be
found."
  (or (find (match-lambda
              (($ <compressor> name*)
               (string=? name* name)))
            %compressors)
      (leave (G_ "~a: compressor not found~%") name)))
gnu: node-serialport-*: Move packages in alphabetical order....Nicolas Graves 2024-02-18gnu: node-path-key: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-semver: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: packages: node-xyz: Add alphatical order header....Nicolas Graves 2024-02-18gnu: node-debug: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-ms: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-segfault-handler: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-file-uri-to-path: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-sqlite3: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-addon-api: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-nan: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-irc and node-irc-colors: Move in alphabetical order....Nicolas Graves 2024-02-18gnu: node-readable-stream: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-string-decoder: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-safe-buffer: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-inherits: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-ieee754: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-once: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-util-deprecate: Move package in alphabetical order....Nicolas Graves 2024-02-18gnu: node-bindings: Move package in alphabetical order....Nicolas Graves 2024-02-03gnu: Add node-path-key....Rikard Nordgren 2023-12-22gnu: Add node-safe-stable-stringify....Rikard Nordgren 2023-12-22gnu: Add node-normalize-path....Rikard Nordgren 2023-05-29gnu: Add node-global-gradle-clean....Dhruvin Gandhi 2023-05-06gnu: node-serialport: Avoid gyp rebuilds....Jelle Licht 2023-05-06gnu: node-yazl: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-ieee754: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-resolve-protobuf-schema: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-protocol-buffers-schema: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-pbf: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-minimist: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-crx3: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-buffer-crc32: Ignore development dependencies....Jelle Licht 2023-05-06gnu: node-acorn: Fix broken transpilation....Jelle Licht 2023-05-06gnu: node-acorn: Remove lifecycle script....Jelle Licht 2023-05-06gnu: node-acorn: Disable tests....Jelle Licht