You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

7270 lines
298 KiB

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
;;; Copyright © 2015, 2016, 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2016, 2017 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016 Raymond Nicholson <rain1@openmailbox.org>
;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2016, 2018, 2019, 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2016, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016 David Craven <david@craven.ch>
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2016, 2018 Rene Saavedra <pacoon@protonmail.com>
;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
;;; Copyright © 2017, 2018 Leo Famulari <leo@famulari.name>
;;; Copyright © 2017 José Miguel Sánchez García <jmi2k@openmailbox.com>
;;; Copyright © 2017 Gábor Boskovits <boskovits@gmail.com>
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2017 nee <nee-git@hidamari.blue>
;;; Copyright © 2017 Dave Love <fx@gnu.org>
;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
;;; Copyright © 2018, 2020 Brendan Tildesley <mail@brendan.scot>
;;; Copyright © 2018 Manuel Graf <graf@init.at>
;;; Copyright © 2018 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2018 Vasile Dumitrascu <va511e@yahoo.com>
;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
;;; Copyright © 2019, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2019 Stefan Stefanović <stefanx2ovic@gmail.com>
;;; Copyright © 2019 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2019, 2020 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2019 Kei Kebreau <kkebreau@posteo.net>
;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright © 2020 John Soo <jsoo1@asu.edu>
;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
;;;
;;; 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 linux)
#:use-module (gnu packages)
#:use-module (gnu packages acl)
#:use-module (gnu packages admin)
#:use-module (gnu packages algebra)
#:use-module (gnu packages audio)
#: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 calendar)
#:use-module (gnu packages check)
#:use-module (gnu packages cpio)
#:use-module (gnu packages crypto)
#:use-module (gnu packages cryptsetup)
#:use-module (gnu packages compression)
#:use-module (gnu packages dbm)
#:use-module (gnu packages datastructures)
#:use-module (gnu packages docbook)
#:use-module (gnu packages documentation)
#:use-module (gnu packages elf)
#:use-module (gnu packages flex)
#:use-module (gnu packages file)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages golang)
#:use-module (gnu packages gperf)
#:use-module (gnu packages gstreamer)
#:use-module (gnu packages gtk)
#:use-module (gnu packages haskell-apps)
#:use-module (gnu packages haskell-xyz)
#:use-module (gnu packages libunwind)
#:use-module (gnu packages libusb)
#:use-module (gnu packages man)
#:use-module (gnu packages maths)
#:use-module (gnu packages multiprecision)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages netpbm)
#:use-module (gnu packages networking)
#:use-module (gnu packages ninja)
#:use-module (gnu packages nss)
#:use-module (gnu packages perl)
#:use-module (gnu packages pciutils)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages popt)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages readline)
#:use-module (gnu packages rrdtool)
#:use-module (gnu packages samba)
#:use-module (gnu packages sdl)
#:use-module (gnu packages serialization)
#:use-module (gnu packages slang)
#:use-module (gnu packages texinfo)
#:use-module (gnu packages tls)
#:use-module (gnu packages valgrind)
#:use-module (gnu packages video)
#:use-module (gnu packages web)
#:use-module (gnu packages xiph)
#:use-module (gnu packages xml)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages xorg)
#:use-module (gnu packages groff)
#:use-module (gnu packages rsync)
#:use-module (gnu packages selinux)
#:use-module (gnu packages swig)
#:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
#:use-module (guix build-system go)
#:use-module (guix build-system meson)
#:use-module (guix build-system python)
#:use-module (guix build-system trivial)
#:use-module (guix build-system linux-module)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (guix monads)
#:use-module (guix utils)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-2)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match))
(define-public (system->linux-architecture arch)
"Return the Linux architecture name for ARCH, a Guix system name such as
\"x86_64-linux\" or a target triplet such as \"arm-linux-gnueabihf\"."
(let ((arch (car (string-split arch #\-))))
(cond ((string=? arch "i686") "i386")
((string-prefix? "mips" arch) "mips")
((string-prefix? "arm" arch) "arm")
((string-prefix? "aarch64" arch) "arm64")
((string-prefix? "alpha" arch) "alpha")
((string-prefix? "powerpc" arch) "powerpc") ;including "powerpc64le"
((string-prefix? "s390" arch) "s390")
((string-prefix? "riscv" arch) "riscv")
(else arch))))
(define-public (system->defconfig system)
"Some systems (notably powerpc-linux) require a special target for kernel
defconfig. Return the appropriate make target if applicable, otherwise return
\"defconfig\"."
(cond ((string-prefix? "powerpc-" system) "pmac32_defconfig")
((string-prefix? "powerpc64le-" system) "ppc64_defconfig")
(else "defconfig")))
;;;
;;; Kernel source code deblobbing.
;;;
(define (linux-libre-deblob-scripts version
deblob-hash
deblob-check-hash)
(list (version-major+minor version)
(origin
(method url-fetch)
(uri (string-append "https://linux-libre.fsfla.org"
"/pub/linux-libre/releases/" version "-gnu/"
"deblob-" (version-major+minor version)))
(sha256 deblob-hash))
(origin
(method url-fetch)
(uri (string-append "https://linux-libre.fsfla.org"
"/pub/linux-libre/releases/" version "-gnu/"
"deblob-check"))
(sha256 deblob-check-hash))))
(define deblob-scripts-5.7
(linux-libre-deblob-scripts
"5.7.10"
(base32 "1gharhw104wxp9dxjkzzvsqc2xn44mc9yvacc3v7jh7b6bb0a64a")
(base32 "1n198gx18rxc7xflgiwya43inkwayc91pgb129kngfza8sm6v8ks")))
(define deblob-scripts-5.4
(linux-libre-deblob-scripts
"5.4.53"
(base32 "0ckxn7k5zgcqk30dq943bnamr6a6zjbw2aqjl3x30f4kvh5f6k25")
(base32 "10qb890is4z58vr8czh3xx69q62l3b3j38y410kgiw8nii3zx5lr")))
(define deblob-scripts-4.19
(linux-libre-deblob-scripts
"4.19.134"
(base32 "02zs405awaxydbapka4nz8h6lmnc0dahgczqsrs5s2bmzjyyqkcy")
(base32 "1w2wgxblpq09i33qmqgw5v3r5rm9vkkygr6m0sgv4zgczk9s29wr")))
(define deblob-scripts-4.14
(linux-libre-deblob-scripts
"4.14.189"
(base32 "091jk9jkn9jf39bxpc7395bhcb7p96nkg3a8047380ki06lnfxh6")
(base32 "1qij18inijj6c3ma8hv98yjagnzxdxyn134da9fd23ky8q6hbvky")))
(define deblob-scripts-4.9
(linux-libre-deblob-scripts
"4.9.231"
(base32 "1wvldzlv7q2xdbadas87dh593nxr4a8p5n0f8zpm72lja6w18hmg")
(base32 "0fxajshb75siq39lj5h8xvhdj8lcmddkslwlyj65rhlwk6g2r4b2")))
(define deblob-scripts-4.4
(linux-libre-deblob-scripts
"4.4.231"
(base32 "0x2j1i88am54ih2mk7gyl79g25l9zz4r08xhl482l3fvjj2irwbw")
(base32 "0hhin1jpfkd6nwrb6xqxjzl3hdxy4pn8a15hy2d3d83yw6pflbsf")))
(define* (computed-origin-method gexp-promise hash-algo hash
#:optional (name "source")
#:key (system (%current-system))
(guile (default-guile)))
"Return a derivation that executes the G-expression that results
from forcing GEXP-PROMISE."
(mlet %store-monad ((guile (package->derivation guile system)))
(gexp->derivation (or name "computed-origin")
(force gexp-promise)
#:graft? #f ;nothing to graft
#:system system
#:guile-for-build guile)))
(define (make-linux-libre-source version
upstream-source
deblob-scripts)
"Return a 'computed' origin that generates a Linux-libre tarball from the
corresponding UPSTREAM-SOURCE (an origin), using the given DEBLOB-SCRIPTS."
(match deblob-scripts
((deblob-version (? origin? deblob) (? origin? deblob-check))
(unless (string=? deblob-version (version-major+minor version))
;; The deblob script cannot be expected to work properly on a
;; different version (major+minor) of Linux, even if no errors
;; are signaled during execution.
(error "deblob major+minor version mismatch"))
(origin
(method computed-origin-method)
(file-name (string-append "linux-libre-" version "-guix.tar.xz"))
(sha256 #f)
(uri
(delay
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils)
(srfi srfi-1)
(ice-9 match)
(ice-9 ftw))
(let ((dir (string-append "linux-" #$version)))
(mkdir "/tmp/bin")
(set-path-environment-variable
"PATH" '("bin")
(list "/tmp"
#+(canonical-package bash)
#+(canonical-package coreutils)
#+(canonical-package diffutils)
#+(canonical-package findutils)
#+(canonical-package patch)
#+(canonical-package xz)
#+(canonical-package sed)
#+(canonical-package grep)
#+(canonical-package bzip2)
#+(canonical-package gzip)
#+(canonical-package tar)
;; The comments in the 'deblob-check' script
;; claim that it supports Python 2 and 3, but
;; in fact it fails when run in Python 3 as
;; of version 5.1.3.
#+python-2))
(with-directory-excursion "/tmp/bin"
(copy-file #+deblob "deblob")
(chmod "deblob" #o755)
(substitute* "deblob"
(("/bin/sh") (which "sh")))
(copy-file #+deblob-check "deblob-check")
(chmod "deblob-check" #o755)
(substitute* "deblob-check"
(("/bin/sh") (which "sh"))
(("/bin/sed") (which "sed"))
(("/usr/bin/python") (which "python"))))
(if (file-is-directory? #+upstream-source)
(begin
(format #t "Copying upstream linux source...~%")
(force-output)
(invoke "cp" "--archive" #+upstream-source dir)
(invoke "chmod" "--recursive" "u+w" dir))
(begin
(format #t "Unpacking upstream linux tarball...~%")
(force-output)
(invoke "tar" "xf" #$upstream-source)
(match (scandir "."
(lambda (name)
(and (not (member name '("." "..")))
(file-is-directory? name))))
((unpacked-dir)
(unless (string=? dir unpacked-dir)
(rename-file unpacked-dir dir)))
(dirs
(error "multiple directories found" dirs)))))
(with-directory-excursion dir
(setenv "PYTHON" (which "python"))
(format #t "Running deblob script...~%")
(force-output)
(invoke "/tmp/bin/deblob"))
(format #t "~%Packing new Linux-libre tarball...~%")
(force-output)
(invoke "tar" "cvfa" #$output
;; Avoid non-determinism in the archive.
"--mtime=@0"
"--owner=root:0"
"--group=root:0"
"--sort=name"
"--hard-dereference"
dir))))))))))
;;;
;;; Kernel sources.
;;;
(define (linux-libre-urls version)
"Return a list of URLs for Linux-Libre VERSION."
(list (string-append
"https://linux-libre.fsfla.org/pub/linux-libre/releases/"
version "-gnu/linux-libre-" version "-gnu.tar.xz")
;; XXX: Work around <http://bugs.gnu.org/14851>.
(string-append
"ftp://alpha.gnu.org/gnu/guix/mirror/linux-libre-"
version "-gnu.tar.xz")
;; Maybe this URL will become valid eventually.
(string-append
"mirror://gnu/linux-libre/" version "-gnu/linux-libre-"
version "-gnu.tar.xz")))
(define (%upstream-linux-source version hash)
(origin
(method url-fetch)
(uri (string-append "mirror://kernel.org"
"/linux/kernel/v" (version-major version) ".x/"
"linux-" version ".tar.xz"))
(sha256 hash)))
(define-public linux-libre-5.7-version "5.7.10")
(define-public linux-libre-5.7-pristine-source
(let ((version linux-libre-5.7-version)
(hash (base32 "0i1x347q1rs9r11f7qic62d5465dzngxs0n44ryknmxpcl6469a7")))
(make-linux-libre-source version
(%upstream-linux-source version hash)
deblob-scripts-5.7)))
(define-public linux-libre-5.4-version "5.4.53")
(define-public linux-libre-5.4-pristine-source
(let ((version linux-libre-5.4-version)
(hash (base32 "08bd7lgj2c26h3rm8lm7w6dvi8zhjiilmrxf1rpp5m90jbwvd9zs")))
(make-linux-libre-source version
(%upstream-linux-source version hash)
deblob-scripts-5.4)))
(define-public linux-libre-4.19-version "4.19.134")
(define-public linux-libre-4.19-pristine-source
(let ((version linux-libre-4.19-version)
(hash (base32 "0vrsiqqsiv0z4jhafqch2g27ig28nmw69hw32a8lc5fkcm7shzbx")))
(make-linux-libre-source version
(%upstream-linux-source version hash)
deblob-scripts-4.19)))
(define-public linux-libre-4.14-version "4.14.189")
(define-public linux-libre-4.14-pristine-source
(let ((version linux-libre-4.14-version)
(hash (base32 "1qgr6hb714xi7rav4za4vk4l7c0ma3ndf0f2ca3q8ly5gd2j3rd7")))
(make-linux-libre-source version
(%upstream-linux-source version hash)
deblob-scripts-4.14)))
(define-public linux-libre-4.9-version "4.9.231")
(define-public linux-libre-4.9-pristine-source
(let ((version linux-libre-4.9-version)
(hash (base32 "1sz8xk767yy4lxqvy4229yrgkwnm43hdrbr54aa1flns5yh3p12g")))
(make-linux-libre-source version
(%upstream-linux-source version hash)
deblob-scripts-4.9)))
(define-public linux-libre-4.4-version "4.4.231")
(define-public linux-libre-4.4-pristine-source
(let ((version linux-libre-4.4-version)
(hash (base32 "1c6p5hv18isa328pvpa3qmmsg4qsssf2mwsx3hzn489rb8ycdxp7")))
(make-linux-libre-source version
(%upstream-linux-source version hash)
deblob-scripts-4.4)))
(define %boot-logo-patch
;; Linux-Libre boot logo featuring Freedo and a gnu.
(origin
(method url-fetch)
(uri (string-append "http://www.fsfla.org/svn/fsfla/software/linux-libre/"
"lemote/gnewsense/branches/3.16/100gnu+freedo.patch"))
(sha256
(base32
"1hk9swxxc80bmn2zd2qr5ccrjrk28xkypwhl4z0qx4hbivj7qm06"))))
(define %linux-libre-arm-export-__sync_icache_dcache-patch
(origin
(method url-fetch)
(uri (string-append
"https://salsa.debian.org/kernel-team/linux"
"/raw/34a7d9011fcfcfa38b68282fd2b1a8797e6834f0"
"/debian/patches/bugfix/arm/"
"arm-mm-export-__sync_icache_dcache-for-xen-privcmd.patch"))
(file-name "linux-libre-arm-export-__sync_icache_dcache.patch")
(sha256
(base32 "1ifnfhpakzffn4b8n7x7w5cps9mzjxlkcfz9zqak2vaw8nzvl39f"))))
(define (source-with-patches source patches)
(origin
(inherit source)
(patches (append (origin-patches source)
patches))))
(define-public linux-libre-5.7-source
(source-with-patches linux-libre-5.7-pristine-source
(list %boot-logo-patch
%linux-libre-arm-export-__sync_icache_dcache-patch)))
(define-public linux-libre-5.4-source
(source-with-patches linux-libre-5.4-pristine-source
(list %boot-logo-patch
%linux-libre-arm-export-__sync_icache_dcache-patch
;; Pinebook Pro patch from linux-next,
;; can be dropped for linux-libre 5.7
(search-patch
"linux-libre-support-for-Pinebook-Pro.patch"))))
(define-public linux-libre-4.19-source
(source-with-patches linux-libre-4.19-pristine-source
(list %boot-logo-patch
%linux-libre-arm-export-__sync_icache_dcache-patch)))
(define-public linux-libre-4.14-source
(source-with-patches linux-libre-4.14-pristine-source
(list %boot-logo-patch)))
(define-public linux-libre-4.9-source
(source-with-patches linux-libre-4.9-pristine-source
(list %boot-logo-patch)))
(define-public linux-libre-4.4-source
(source-with-patches linux-libre-4.4-pristine-source
(list %boot-logo-patch)))
;;;
;;; Kernel headers.
;;;
(define (make-linux-libre-headers version hash-string)
(make-linux-libre-headers* version
(origin
(method url-fetch)
(uri (linux-libre-urls version))
(sha256 (base32 hash-string)))))
(define (make-linux-libre-headers* version source)
(package
(name "linux-libre-headers")
(version version)
(source source)
(build-system gnu-build-system)
(native-inputs `(("perl" ,perl)
,@(if (version>=? version "4.16")
`(("flex" ,flex)
("bison" ,bison))
'())
,@(if (version>=? version "5.3")
`(("rsync" ,rsync))
'())))
(arguments
`(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-1))
#:phases
(modify-phases %standard-phases
(delete 'configure)
(replace 'build
(lambda _
(let ((arch ,(system->linux-architecture
(or (%current-target-system)
(%current-system))))
(defconfig ,(system->defconfig
(or (%current-target-system)
(%current-system)))))
(setenv "ARCH" arch)
(format #t "`ARCH' set to `~a'~%" (getenv "ARCH"))
(invoke "make" defconfig)
(invoke "make" "mrproper" "headers_check"))))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(invoke "make"
(string-append "INSTALL_HDR_PATH=" out)
"headers_install")
(mkdir (string-append out "/include/config"))
(call-with-output-file
(string-append out
"/include/config/kernel.release")
(lambda (p)
(format p "~a-default~%" ,version)))
;; Remove the '.install' and '..install.cmd' files; the
;; latter contains store paths, which pulls in bootstrap
;; binaries in the build environment, and prevents bit
;; reproducibility for the bootstrap binaries.
(for-each delete-file (find-files out "\\.install"))
#t))))
#:allowed-references ()
#:tests? #f))
(home-page "https://www.gnu.org/software/linux-libre/")
(synopsis "GNU Linux-Libre kernel headers")
(description "Headers of the Linux-Libre kernel.")
(license license:gpl2)))
(define-public linux-libre-headers-5.7
(make-linux-libre-headers* linux-libre-5.7-version
linux-libre-5.7-source))
(define-public linux-libre-headers-5.4
(make-linux-libre-headers* linux-libre-5.4-version
linux-libre-5.4-source))
(define-public linux-libre-headers-4.19
(make-linux-libre-headers* linux-libre-4.19-version
linux-libre-4.19-source))
(define-public linux-libre-headers-4.14
(make-linux-libre-headers* linux-libre-4.14-version
linux-libre-4.14-source))
(define-public linux-libre-headers-4.9
(make-linux-libre-headers* linux-libre-4.9-version
linux-libre-4.9-source))
(define-public linux-libre-headers-4.4
(make-linux-libre-headers* linux-libre-4.4-version
linux-libre-4.4-source))
;; The following package is used in the early bootstrap, and thus must be kept
;; stable and with minimal build requirements.
(define-public linux-libre-headers-5.4.20
(make-linux-libre-headers "5.4.20"
"1qxhf6dmcwjblzx8fgn6vr10p38xw10iwh6d1y1v1mxb25y30b47"))
(define-public linux-libre-headers linux-libre-headers-5.4.20)
;;;
;;; Kernel configurations.
;;;
(define* (kernel-config arch #:key variant)
"Return the absolute file name of the Linux-Libre build configuration file
for ARCH and optionally VARIANT, or #f if there is no such configuration."
(let* ((name (string-append (if variant (string-append variant "-") "")
(if (string=? "i386" arch) "i686" arch) ".conf"))
(file (string-append "linux-libre/" name)))
(search-auxiliary-file file)))
(define %default-extra-linux-options
`(;; Some very mild hardening.
("CONFIG_SECURITY_DMESG_RESTRICT" . #t)
;; All kernels should have NAMESPACES options enabled
("CONFIG_NAMESPACES" . #t)
("CONFIG_UTS_NS" . #t)
("CONFIG_IPC_NS" . #t)
("CONFIG_USER_NS" . #t)
("CONFIG_PID_NS" . #t)
("CONFIG_NET_NS" . #t)
;; Modules required for initrd:
("CONFIG_NET_9P" . m)
("CONFIG_NET_9P_VIRTIO" . m)
("CONFIG_VIRTIO_BLK" . m)
("CONFIG_VIRTIO_NET" . m)
("CONFIG_VIRTIO_PCI" . m)
("CONFIG_VIRTIO_BALLOON" . m)
("CONFIG_VIRTIO_MMIO" . m)
("CONFIG_FUSE_FS" . m)
("CONFIG_CIFS" . m)
("CONFIG_9P_FS" . m)))
;; See https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration
(define %bpf-extra-linux-options
`(;; Needed for probes
("CONFIG_UPROBE_EVENTS" . #t)
("CONFIG_KPROBE_EVENTS" . #t)
;; kheaders module also helpful for tracing
("CONFIG_IKHEADERS" . #t)
("CONFIG_BPF" . #t)
("CONFIG_BPF_SYSCALL" . #t)
("CONFIG_BPF_JIT_ALWAYS_ON" . #t)
;; optional, for tc filters
("CONFIG_NET_CLS_BPF" . m)
;; optional, for tc actions
("CONFIG_NET_ACT_BPF" . m)
("CONFIG_BPF_JIT" . #t)
;; for Linux kernel versions 4.1 through 4.6
;; ("CONFIG_HAVE_BPF_JIT" . y)
;; for Linux kernel versions 4.7 and later
("CONFIG_HAVE_EBPF_JIT" . #t)
;; optional, for kprobes
("CONFIG_BPF_EVENTS" . #t)
;; kheaders module
("CONFIG_IKHEADERS" . #t)))
(define (config->string options)
(string-join (map (match-lambda
((option . 'm)
(string-append option "=m"))
((option . #t)
(string-append option "=y"))
((option . #f)
(string-append option "=n")))
options)
"\n"))
;;;
;;; Kernel package utilities.
;;;
(define* (make-linux-libre version hash-string supported-systems
#:key
;; A function that takes an arch and a variant.
;; See kernel-config for an example.
(extra-version #f)
(configuration-file #f)
(defconfig "defconfig")
(extra-options %default-extra-linux-options)
(patches (list %boot-logo-patch)))
(make-linux-libre* version
(origin
(method url-fetch)
(uri (linux-libre-urls version))
(sha256 (base32 hash-string))
(patches patches))
supported-systems
#:extra-version extra-version
#:configuration-file configuration-file
#:defconfig defconfig
#:extra-options extra-options))
(define* (make-linux-libre* version source supported-systems
#:key
;; A function that takes an arch and a variant.
;; See kernel-config for an example.
(extra-version #f)
(configuration-file #f)
(defconfig "defconfig")
(extra-options %default-extra-linux-options))
(package
(name (if extra-version
(string-append "linux-libre-" extra-version)
"linux-libre"))
(version version)
(source source)
(supported-systems supported-systems)
(build-system gnu-build-system)
(native-inputs
`(("perl" ,perl)
("bc" ,bc)
("openssl" ,openssl)
("elfutils" ,elfutils) ; Needed to enable CONFIG_STACK_VALIDATION
("flex" ,flex)
("bison" ,bison)
;; These are needed to compile the GCC plugins.
("gmp" ,gmp)
("mpfr" ,mpfr)
("mpc" ,mpc)
,@(match (and configuration-file
(configuration-file
(system->linux-architecture
(or (%current-target-system) (%current-system)))
#:variant (version-major+minor version)))
(#f ;no config for this platform
'())
((? string? config)
`(("kconfig" ,config))))))
(arguments
`(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-1)
(srfi srfi-26)
(ice-9 ftw)
(ice-9 match))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'patch-/bin/pwd
(lambda _
(substitute* (find-files "." "^Makefile(\\.include)?$")
(("/bin/pwd") "pwd"))
#t))
(replace 'configure
(lambda* (#:key inputs native-inputs target #:allow-other-keys)
;; Avoid introducing timestamps
(setenv "KCONFIG_NOTIMESTAMP" "1")
(setenv "KBUILD_BUILD_TIMESTAMP" (getenv "SOURCE_DATE_EPOCH"))
;; Set ARCH and CROSS_COMPILE
(let ((arch ,(system->linux-architecture
(or (%current-target-system)
(%current-system)))))
(setenv "ARCH" arch)
(format #t "`ARCH' set to `~a'~%" (getenv "ARCH"))
(when target
(setenv "CROSS_COMPILE" (string-append target "-"))
(format #t "`CROSS_COMPILE' set to `~a'~%"
(getenv "CROSS_COMPILE"))))
(setenv "EXTRA_VERSION" ,extra-version)
(let ((build (assoc-ref %standard-phases 'build))
(config (assoc-ref (or native-inputs inputs) "kconfig")))
;; Use a custom kernel configuration file or a default
;; configuration file.
(if config
(begin
(copy-file config ".config")
(chmod ".config" #o666))
(invoke "make" ,defconfig))
;; Appending works even when the option wasn't in the
;; file. The last one prevails if duplicated.
(let ((port (open-file ".config" "a"))
(extra-configuration ,(config->string extra-options)))
(display extra-configuration port)
(close-port port))
(invoke "make" "oldconfig"))))
(replace 'install
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(moddir (string-append out "/lib/modules"))
(dtbdir (string-append out "/lib/dtbs")))
;; Install kernel image, kernel configuration and link map.
(for-each (lambda (file) (install-file file out))
(find-files "." "^(\\.config|bzImage|zImage|Image|vmlinuz|System\\.map|Module\\.symvers)$"))
;; Install device tree files
(unless (null? (find-files "." "\\.dtb$"))
(mkdir-p dtbdir)
(invoke "make" (string-append "INSTALL_DTBS_PATH=" dtbdir)
"dtbs_install"))
;; Install kernel modules
(mkdir-p moddir)
(invoke "make"
;; Disable depmod because the Guix system's module directory
;; is an union of potentially multiple packages. It is not
;; possible to use depmod to usefully calculate a dependency
;; graph while building only one of those packages.
"DEPMOD=true"
(string-append "MODULE_DIR=" moddir)
(string-append "INSTALL_PATH=" out)
(string-append "INSTALL_MOD_PATH=" out)
"INSTALL_MOD_STRIP=1"
"modules_install")
(let* ((versions (filter (lambda (name)
(not (string-prefix? "." name)))
(scandir moddir)))
(version (match versions
((x) x))))
;; There are symlinks to the build and source directory,
;; both of which will point to target /tmp/guix-build*
;; and thus not be useful in a profile. Delete the symlinks.
(false-if-file-not-found
(delete-file (string-append moddir "/" version "/build")))
(false-if-file-not-found
(delete-file (string-append moddir "/" version "/source"))))
#t))))
#:tests? #f))
(home-page "https://www.gnu.org/software/linux-libre/")
(synopsis "100% free redistribution of a cleaned Linux kernel")
(description
"GNU Linux-Libre is a free (as in freedom) variant of the Linux kernel.
It has been modified to remove all non-free binary blobs.")
(license license:gpl2)))
;;;
;;; Generic kernel packages.
;;;
(define-public linux-libre-5.4
(make-linux-libre* linux-libre-5.4-version
linux-libre-5.4-source
'("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux")
#:configuration-file kernel-config))
(define-public linux-libre-version linux-libre-5.4-version)
(define-public linux-libre-pristine-source linux-libre-5.4-pristine-source)
(define-public linux-libre-source linux-libre-5.4-source)
(define-public linux-libre linux-libre-5.4)
(define-public linux-libre-4.19
(make-linux-libre* linux-libre-4.19-version
linux-libre-4.19-source
'("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
#:configuration-file kernel-config))
(define-public linux-libre-4.14
(make-linux-libre* linux-libre-4.14-version
linux-libre-4.14-source
'("x86_64-linux" "i686-linux" "armhf-linux")
#:configuration-file kernel-config))
(define-public linux-libre-4.9
(make-linux-libre* linux-libre-4.9-version
linux-libre-4.9-source
'("x86_64-linux" "i686-linux")
#:configuration-file kernel-config))
(define-public linux-libre-4.4
(make-linux-libre* linux-libre-4.4-version
linux-libre-4.4-source
'("x86_64-linux" "i686-linux")
#:configuration-file kernel-config
#:extra-options
(append
`(;; https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00039.html
;; This option was removed upstream in version 4.7.
("CONFIG_DEVPTS_MULTIPLE_INSTANCES" . #t))
%default-extra-linux-options)))
;;;
;;; Specialized kernel variants.
;;;
(define-public linux-libre-arm-generic
(make-linux-libre* linux-libre-version
linux-libre-source
'("armhf-linux")
#:defconfig "multi_v7_defconfig"
#:extra-version "arm-generic"
#:extra-options
(append
`(;; needed to fix the RTC on rockchip platforms
("CONFIG_RTC_DRV_RK808" . #t))
%default-extra-linux-options)))
(define-public linux-libre-arm-generic-5.7
(make-linux-libre* linux-libre-5.7-version
linux-libre-5.7-source
'("armhf-linux")
#:defconfig "multi_v7_defconfig"
#:extra-version "arm-generic"
#:extra-options
(append
`(;; needed to fix the RTC on rockchip platforms
("CONFIG_RTC_DRV_RK808" . #t))
%default-extra-linux-options)))
(define-public linux-libre-arm-veyron
(deprecated-package "linux-libre-arm-veyron" linux-libre-arm-generic))
(define-public linux-libre-arm-generic-4.19
(make-linux-libre* linux-libre-4.19-version
linux-libre-4.19-source
'("armhf-linux")
#:defconfig "multi_v7_defconfig"
#:extra-version "arm-generic"))
(define-public linux-libre-arm-generic-4.14
(make-linux-libre* linux-libre-4.14-version
linux-libre-4.14-source
'("armhf-linux")
#:defconfig "multi_v7_defconfig"
#:extra-version "arm-generic"))
(define-public linux-libre-arm-omap2plus
(make-linux-libre* linux-libre-version
linux-libre-source
'("armhf-linux")
#:defconfig "omap2plus_defconfig"
#:extra-version "arm-omap2plus"))
(define-public linux-libre-arm-omap2plus-4.19
(make-linux-libre* linux-libre-4.19-version
linux-libre-4.19-source
'("armhf-linux")
#:defconfig "omap2plus_defconfig"
#:extra-version "arm-omap2plus"))
(define-public linux-libre-arm-omap2plus-4.14
(make-linux-libre* linux-libre-4.14-version
linux-libre-4.14-source
'("armhf-linux")
#:defconfig "omap2plus_defconfig"
#:extra-version "arm-omap2plus"))
(define-public linux-libre-arm64-generic
(make-linux-libre* linux-libre-version
linux-libre-source
'("aarch64-linux")
#:defconfig "defconfig"
#:extra-version "arm64-generic"
#:extra-options
(append
`(;; needed to fix the RTC on rockchip platforms
("CONFIG_RTC_DRV_RK808" . #t))
%default-extra-linux-options)))
(define-public linux-libre-arm64-generic-5.7
(make-linux-libre* linux-libre-5.7-version
linux-libre-5.7-source
'("aarch64-linux")
#:defconfig "defconfig"
#:extra-version "arm64-generic"
#:extra-options
(append
`(;; needed to fix the RTC on rockchip platforms
("CONFIG_RTC_DRV_RK808" . #t))
%default-extra-linux-options)))
(define-public linux-libre-riscv64-generic
(make-linux-libre* linux-libre-version
linux-libre-source
'("riscv64-linux")
#:extra-version "riscv64-generic"))
(define-public linux-libre-with-bpf
(let ((base-linux-libre
(make-linux-libre*
linux-libre-5.4-version
linux-libre-5.4-source
'("x86_64-linux" "i686-linux" "armhf-linux"
"aarch64-linux" "riscv64-linux")
#:extra-version "bpf"
#:configuration-file kernel-config
#:extra-options
(append %bpf-extra-linux-options
%default-extra-linux-options))))
(package
(inherit base-linux-libre)
(inputs `(("cpio" ,cpio) ,@(package-inputs base-linux-libre))))))
;;;
;;; Linux kernel modules.
;;;
(define-public acpi-call-linux-module
(let ((commit "70b9c80bd700e6a4d10797eaac9fd34b7e8cbd4a")
(revision "0"))
(package
(name "acpi-call-linux-module")
(version (git-version "3.17" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/teleshoes/acpi_call")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32 "09c1vw6vcrkqxbwhpgfgpj4d1grzn4qq6ka8pwwzm7cvm405xj7x"))))
(build-system linux-module-build-system)
(arguments
`(#:tests? #f ; no tests
#:phases
(modify-phases %standard-phases
(add-after 'install 'install-documentation
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(doc (string-append out "/share/doc/" ,name "-" ,version)))
(for-each (lambda (file)
(let ((target (string-append doc "/" file)))
(mkdir-p (dirname target))
(copy-recursively file target)))
(list "README.md" "examples"))
#t))))))
(home-page "https://github.com/teleshoes/acpi_call")
(synopsis "Linux kernel module to perform ACPI method calls")
(description
"This simple Linux kernel module allows calls from user space to any
@acronym{ACPI, Advanced Configuration and Power Interface} method provided by
your computer's firmware, by writing to @file{/proc/acpi/call}. You can pass
any number of parameters of types @code{ACPI_INTEGER}, @code{ACPI_STRING},
and @code{ACPI_BUFFER}.
It grants direct and undocumented access to your hardware that may cause damage
and should be used with caution, especially on untested models.")
(license license:gpl3+)))) ; see README.md (no licence headers)
(define-public rtl8812au-aircrack-ng-linux-module
(let ((commit "df2b8dfd8cb7d9f6cfeb55abaeab8a5372011fc9")
(revision "1"))
(package
(name "rtl8812au-aircrack-ng-linux-module")
(version (git-version "5.6.4.2" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/aircrack-ng/rtl8812au")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32 "1qcr0j8yhg8l9l0f5y55zcsk1mgf3qd46yh9xfqgg91szxa3yvca"))
(modules '((guix build utils)))
(snippet
'(begin
;; Remove bundled tarballs, APKs, word lists, speadsheets,
;; and other unnecessary unlicenced things.
(for-each delete-file-recursively (list "android"
"docs"
"tools"))
#t))))
(build-system linux-module-build-system)
(arguments
`(#:make-flags
(list (string-append "KSRC="
(assoc-ref %build-inputs "linux-module-builder")
"/lib/modules/build"))
#:phases
(modify-phases %standard-phases
(replace 'build
(lambda* (#:key (make-flags '()) #:allow-other-keys)
(apply invoke "make" make-flags))))
#:tests? #f)) ; no test suite
(supported-systems '("x86_64-linux" "i686-linux"))
(home-page "https://github.com/aircrack-ng/rtl8812au")
(synopsis "Linux driver for Realtek USB wireless network adapters")
(description
"This is Realtek's rtl8812au Linux driver for USB 802.11n wireless
network adapters, modified by the aircrack-ng project to support monitor mode
and frame injection. It provides a @code{88XXau} kernel module that supports
RTL8812AU, RTL8821AU, and RTL8814AU chips.")
(license license:gpl2+))))
(define-public rtl8821ce-linux-module
(let ((commit "69765eb288a8dfad3b055b906760b53e02ab1dea")
(revision "0"))
(package
(name "rtl8821ce-linux-module")
(version (git-version "0.0.0" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/tomaspinho/rtl8821ce")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32
"17jiw25k74kv5lnvgycvj2g1n06hbrpjz6p4znk4a62g136rhn4s"))))
(build-system linux-module-build-system)
(arguments
`(#:make-flags
(list "CC=gcc"
(string-append "KSRC="
(assoc-ref %build-inputs "linux-module-builder")
"/lib/modules/build"))
#:phases
(modify-phases %standard-phases
(replace 'build
(lambda* (#:key (make-flags '()) #:allow-other-keys)
(apply invoke "make" make-flags))))
#:tests? #f)) ; no test suite
(home-page "https://github.com/tomaspinho/rtl8821ce")
(synopsis "Linux driver for Realtek RTL8821CE wireless network adapters")
(description "This is Realtek's RTL8821CE Linux driver for wireless
network adapters.")
(license license:gpl2))))
(define-public vhba-module
(package
(name "vhba-module")
(version "20200106")
(source (origin
(method url-fetch)
(uri (string-append
"http://downloads.sourceforge.net/cdemu/vhba-module/vhba-module-"
version ".tar.bz2"))
(sha256
(base32
"10rlvsfj0fw6n0qmwcnvhimqnsnhi7n55lyl7fq1pkwggf5218sr"))))
(build-system linux-module-build-system)
(arguments
;; TODO: No tests?
`(#:tests? #f))
(home-page "https://cdemu.sourceforge.io/")
(synopsis "Kernel module that emulates SCSI devices")
(description "VHBA module provides a Virtual (SCSI) HBA, which is the link
between the CDemu userspace daemon and linux kernel.")
(license license:gpl2+)))
(define-public bbswitch-module
(package
(name "bbswitch-module")
(version "0.8")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/Bumblebee-Project/bbswitch")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"1glch4j0x1dzlp2yrb67v2r5jg9609jb6p8m251y78m74advqw0l"))))
(build-system linux-module-build-system)
(arguments
;; No tests.
`(#:tests? #f))
(home-page "https://github.com/Bumblebee-Project/bbswitch")
(synopsis "Kernel module that disables discrete Nvidia graphics cards")
(description "The bbswitch module provides a way to toggle the Nvidia
graphics card on Optimus laptops.")
(license license:gpl2)))
(define-public ddcci-driver-linux
(package
(name "ddcci-driver-linux")
(version "0.3.3")
(source
(origin
(method git-fetch)
(uri
(git-reference
(url "https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"0vkkja3ykjil783zjpwp0vz7jy2fp9ccazzi3afd4fjk8gldin7f"))))
(build-system linux-module-build-system)
(arguments
`(#:tests? #f ; no tests
#:phases
(modify-phases %standard-phases
(replace 'build
(lambda args
(for-each
(lambda (module)
(with-directory-excursion module
(apply (assoc-ref %standard-phases 'build) args)))
'("ddcci" "ddcci-backlight"))
#t))
(replace 'install
(lambda args
(for-each
(lambda (module)
(with-directory-excursion module
(apply (assoc-ref %standard-phases 'install) args)))
'("ddcci" "ddcci-backlight"))
#t)))))
(home-page "https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux")
(synopsis "Pair of Linux kernel drivers for DDC/CI monitors")
(description "This package provides two Linux kernel drivers, ddcci and
ddcci-backlight, that allows the control of DDC/CI monitors through the sysfs
interface. The ddcci module creates a character device for each DDC/CI
monitors in @file{/dev/bus/ddcci/[I²C busnumber]}. While the ddcci-backlight
module allows the control of the backlight level or luminance property when
supported under @file{/sys/class/backlight/}.")
(license license:gpl2+)))
(define-public v4l2loopback-linux-module
(package
(name "v4l2loopback-linux-module")
(version "0.12.5")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/umlaeute/v4l2loopback")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"1qi4l6yam8nrlmc3zwkrz9vph0xsj1cgmkqci4652mbpbzigg7vn"))))
(build-system linux-module-build-system)
(arguments
`(#:tests? #f)) ; no test suite
(home-page "https://github.com/umlaeute/v4l2loopback")
(synopsis "Linux kernel module to create virtual V4L2 video devices")
(description
"This Linux module creates virtual video devices. @acronym{V4L2, Video
for Linux 2} applications will treat these as ordinary video devices but read
video data generated by another application, instead of a hardware device such
as a capture card.
This lets you apply nifty effects to your Jitsi video, for example, but also
allows some more serious things like adding streaming capabilities to an
application by hooking GStreamer into the loopback device.")
(license license:gpl2+)))
;;;
;;; Pluggable authentication modules (PAM).
;;;
(define-public linux-pam
(package
(name "linux-pam")
(version "1.3.1")
(source
(origin
(method url-fetch)
(uri (string-append
"https://github.com/linux-pam/linux-pam/releases/download/v"
version "/Linux-PAM-" version ".tar.xz"))
(sha256
(base32
"1nyh9kdi3knhxcbv5v4snya0g3gff0m671lnvqcbygw3rm77mx7g"))
(patches (search-patches "linux-pam-no-setfsuid.patch"))))
(build-system gnu-build-system)
(native-inputs
`(("flex" ,flex)
;; TODO: optional dependencies
;; ("libxcrypt" ,libxcrypt)
;; ("cracklib" ,cracklib)
))
(arguments
`(;; Most users, such as `shadow', expect the headers to be under
;; `security'.
#:configure-flags (list (string-append "--includedir="
(assoc-ref %outputs "out")
"/include/security")
;; XXX: <rpc/rpc.h> is missing from glibc when
;; cross-compiling, so we have to disable NIS
;; support altogether.
,@(if (%current-target-system)
'("--disable-nis")
'()))
;; XXX: Tests won't run in chroot, presumably because /etc/pam.d
;; isn't available.
#:tests? #f))
(home-page "http://www.linux-pam.org/")
(synopsis "Pluggable authentication modules for Linux")
(description
"A *Free* project to implement OSF's RFC 86.0.
Pluggable authentication modules are small shared object files that can
be used through the PAM API to perform tasks, like authenticating a user
at login. Local and dynamic reconfiguration are its key features.")
(license license:bsd-3)))
(define-public linux-pam-1.2
(package
(inherit linux-pam)
(version "1.2.1")
(source
(origin
(method url-fetch)
(uri (string-append
"http://www.linux-pam.org/library/"
"Linux-PAM-" version ".tar.bz2"))
(sha256
(base32
"1n9lnf9gjs72kbj1g354v1xhi2j27aqaah15vykh7cnkq08i4arl"))
(patches (search-patches "linux-pam-no-setfsuid.patch"))))))
;;;
;;; Miscellaneous.
;;;
(define-public powerstat
(package
(name "powerstat")
(version "0.02.22")
(source
(origin
(method url-fetch)
(uri (string-append "https://kernel.ubuntu.com/~cking/tarballs/"
"powerstat/powerstat-" version ".tar.gz"))
(sha256
(base32 "0r355b9syqa2nhfy8ksvxyy5d58v0isf983842js091s6liy0x7g"))))
(build-system gnu-build-system)
(arguments
`(#:make-flags
(list (string-append "CC=" ,(cc-for-target))
(string-append "prefix=" (assoc-ref %outputs "out")))
#:tests? #f ; no test suite
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'respect-$prefix
;; https://bugs.launchpad.net/ubuntu/+source/powerstat/+bug/1877744
(lambda _
(substitute* "Makefile"
(("DIR=/usr/") "DIR=$(prefix)/"))
#t))
(delete 'configure)))) ; no configure script
(home-page "https://kernel.ubuntu.com/~cking/powerstat/")
(synopsis "Measure system power consumption")
(description
"Powerstat measures and reports your computer's power consumption in real
time. On mobile PCs, it uses ACPI battery information to measure the power
drain of the entire system.
Powerstat can also report @acronym{RAPL, Running Average Power Limit} power
domain measurements. These are available only on some hardware such as Intel
Sandybridge and newer, and cover only part of the machine's components such as
CPU, DRAM, and graphics. However, they provide accurate and immediate readings
and don't require a battery at all.
The output is like @command{vmstat} but also shows power consumption statistics:
at the end of a run, @command{powerstat} will calculate the average, standard
deviation, and minimum and maximum values. It can show a nice histogram too.")
(license license:gpl2)))
(define-public psmisc
(package
(name "psmisc")
(version "23.3")
(source
(origin
(method url-fetch)
(uri (string-append "mirror://sourceforge/psmisc/psmisc/psmisc-"
version ".tar.xz"))
(sha256
(base32 "16i7qzjmm6g0lzha8yzpfrlcxnvkgh95hkq9gdjd4zmzb8d0wxa1"))))
(build-system gnu-build-system)
(arguments
`(,@(if (%current-target-system)
'(#:configure-flags
(list
"ac_cv_func_malloc_0_nonnull=yes"
"ac_cv_func_realloc_0_nonnull=yes"))
'())))
(inputs `(("ncurses" ,ncurses)))
(home-page "https://gitlab.com/psmisc/psmisc")
(synopsis "Small utilities that use the proc file system")
(description
"This PSmisc package is a set of some small useful utilities that
use the proc file system. We're not about changing the world, but
providing the system administrator with some help in common tasks.")
(license license:gpl2+)))
(define-public util-linux
(package
(name "util-linux")
(version "2.35.1")
(source (origin
(method url-fetch)
(uri (string-append "mirror://kernel.org/linux/utils/"
"util-linux/v" (version-major+minor version) "/"
"util-linux-" version ".tar.xz"))
(sha256
(base32
"1yfpy6bkab4jw61mpx48gfy24yrqp4a7arvpis8csrkk53fkxpnr"))
(patches (search-patches "util-linux-tests.patch"))
(modules '((guix build utils)))
(snippet
;; We take 'nologin' from Shadow, the 'logger' program from
;; GNU Inetutils and 'kill' from GNU Coreutils.
'(begin
(substitute* "configure"
(("build_nologin=yes") "build_nologin=no")
(("build_logger=yes") "build_logger=no")
(("build_kill=yes") "build_kill=no"))
#t))))
(build-system gnu-build-system)
(outputs '("out" ;6.4 MiB executables and documentation
"lib" ;8.8 MiB shared libraries, headers and locales
"static")) ;2.9 MiB static .a libraries
(arguments
`(#:configure-flags (list "--disable-use-tty-group"
"--enable-fs-paths-default=/run/current-system/profile/sbin"
;; Don't try to chown root:root mount and umount
"--disable-makeinstall-chown"
"--localstatedir=/var"
(string-append "--localedir="
(assoc-ref %outputs "lib")
"/share/locale")
;; Install completions where our
;; bash-completion package expects them.
(string-append "--with-bashcompletiondir="
(assoc-ref %outputs "out")
"/etc/bash_completion.d"))
#:phases (modify-phases %standard-phases
(add-before 'configure 'patch-build-scripts
(lambda* (#:key outputs #:allow-other-keys)
(substitute* "configure"
;; The build system assumes that we want to install
;; libraries below $exec_prefix when $libdir does not
;; match any of the "usual" locations. Fix that.
(("usrlib_execdir='\\$\\{exec_prefix\\}'\\$libdir")
"usrlib_execdir=$libdir"))
#t))
(add-before 'build 'set-umount-file-name
(lambda* (#:key outputs #:allow-other-keys)
;; Tell 'eject' the right file name of 'umount'.
(let ((out (assoc-ref outputs "out")))
(substitute* "sys-utils/eject.c"
(("\"/bin/umount\"")
(string-append "\"" out "/bin/umount\"")))
#t)))
(add-before 'check 'pre-check
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(net (assoc-ref inputs "net-base")))
;; Change the test to refer to the right file.
(substitute* "tests/ts/misc/mcookie"
(("/etc/services")
(string-append net "/etc/services")))
;; The C.UTF-8 locale does not exist in our libc.
(substitute* "tests/ts/column/invalid-multibyte"
(("C\\.UTF-8") "en_US.utf8"))
#t)))
;; TODO: Remove the conditional on the next rebuild cycle.
,@(if (string-prefix? "arm" (%current-system))
'((add-before 'check 'disable-setarch-test
(lambda _
;; The setarch tests are unreliable in QEMU's
;; user-mode emulation, which is our primary
;; method of building ARMv7 packages.
;; <https://github.com/karelzak/util-linux/issues/601>
(substitute* "tests/ts/misc/setarch"
(("ts_init_subtest.*" all)
(string-append
all "\n"
"ts_skip \"setarch tests are unreliable under QEMU\"")))
#t)))
'())
(add-after 'install 'move-static-libraries
(lambda* (#:key outputs #:allow-other-keys)
(let ((lib (assoc-ref outputs "lib"))
(static (assoc-ref outputs "static")))
;; Move static libraries to the "static" output.
(mkdir-p (string-append static "/lib"))
(with-directory-excursion lib
(for-each (lambda (file)
(rename-file file
(string-append static "/"
file)))
(find-files "lib" "\\.a$"))
;; Remove references to the static library from the '.la'
;; files so that Libtool does the right thing when both
;; the shared and static library is available.
(substitute* (find-files "lib" "\\.la$")
(("old_library=.*") "old_library=''\n")))
#t)))
(add-after 'install 'adjust-pkg-config-files
(lambda* (#:key outputs #:allow-other-keys)
(let ((lib (assoc-ref outputs "lib")))
;; Drop the unused "prefix=" and "exec_prefix=" variables from
;; the pkg-config files to avoid a cyclic reference on "out".
(substitute* (find-files (string-append lib "/lib/pkgconfig")
"\\.pc$")
(("^(exec_)?prefix=.*") "")))
#t)))))
(inputs `(("zlib" ,zlib)
("ncurses" ,ncurses)
;; XXX: This is so that the 'pre-check' phase can find it.
,@(if (%current-target-system)
`(("net-base" ,net-base))
'())))
(native-inputs
`(("perl" ,perl)
("net-base" ,net-base))) ;for tests
(home-page "https://www.kernel.org/pub/linux/utils/util-linux/")
(synopsis "Collection of utilities for the Linux kernel")
(description "Util-linux is a diverse collection of Linux kernel
utilities. It provides dmesg and includes tools for working with file systems,
block devices, UUIDs, TTYs, and many other tools.")
;; Note that util-linux doesn't use the same license for all the
;; code. GPLv2+ is the default license for a code without an
;; explicitly defined license.
(license (list license:gpl3+ license:gpl2+ license:gpl2 license:lgpl2.0+
license:bsd-4 license:public-domain))))
;; util-linux optionally supports udev, which allows lsblk to read file system
;; metadata without special privileges. Add it as a separate package to avoid
;; a circular dependency, and to keep the size small.
(define-public util-linux+udev
(package/inherit
util-linux
(name "util-linux-with-udev")
(inputs
`(("udev" ,eudev)
,@(package-inputs util-linux)))))
(define-public ddate
(package
(name "ddate")
(version "0.2.2")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/bo0ts/ddate")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32 "1qchxnxvghbma6gp1g78wnjxsri0b72ha9axyk31cplssl7yn73f"))))
(build-system cmake-build-system)
(arguments '(#:tests? #f))
(home-page "https://github.com/bo0ts/ddate")
(synopsis "PERPETUAL DATE CONVERTER FROM GREGORIAN TO POEE CALENDAR")
(description
"ddate displays the Discordian date and holidays of a given date.
The Discordian calendar was made popular by the \"Illuminatus!\" trilogy
by Robert Shea and Robert Anton Wilson.")
(license license:public-domain)))
(define-public fbset
(package
(name "fbset")
(version "2.1")
(source
(origin
(method url-fetch)
(uri (string-append "http://users.telenet.be/geertu/Linux/fbdev/fbset-"
version ".tar.gz"))
(sha256
(base32 "080wnisi0jq7dp0jcwdp83rq8q8s3kw41vc712516xbv4jq4mzs0"))))
(build-system gnu-build-system)
(arguments
'(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-26))
#:phases
(modify-phases %standard-phases
(delete 'configure) ; no configure script
(add-before 'install 'pre-install
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(substitute* "Makefile"
(("mknod ") "true ")
;; The Makefile doesn't honour PREFIX or similar.
(("/usr") out))
(mkdir out)
(with-directory-excursion out
(for-each mkdir-p (list "sbin"
"man/man5"
"man/man8")))
#t)))
(add-after 'install 'install-fb.modes
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(etc (string-append out "/etc")))
(for-each (cut install-file <> etc)
(find-files "etc" "^fb\\.modes"))
(symlink "fb.modes.ATI"
(string-append etc "/fb.modes"))
#t))))
;; Parallel building races to create modes.tab.c.
#:parallel-build? #f
#:tests? #f)) ; no test suite
(native-inputs
`(("bison" ,bison)
("flex" ,flex)))
(home-page "http://users.telenet.be/geertu/Linux/fbdev/")
(synopsis "Show and modify Linux frame buffer settings")
(description
"The kernel Linux's @dfn{frame buffers} provide a simple interface to
different kinds of graphic displays. The @command{fbset} utility can query and
change various device settings such as depth, virtual resolution, and timing
parameters.")
(license license:gpl2)))
(define-public procps
(package
(name "procps")
(version "3.3.16")
(source (origin
(method url-fetch)
(uri (string-append "mirror://sourceforge/procps-ng/Production/"
"procps-ng-" version ".tar.xz"))
(sha256
(base32
"1br0g93ysqhlv13i1k4lfbimsgxnpy5rgs4lxfc9rkzdbpbaqplj"))))
(build-system gnu-build-system)
(arguments
`(#:modules ((guix build utils)
(guix build gnu-build-system)
(srfi srfi-1)
(srfi srfi-26))
,@(if (%current-target-system)
'(#:configure-flags
(list
"ac_cv_func_malloc_0_nonnull=yes"
"ac_cv_func_realloc_0_nonnull=yes"))
'())
#:phases
(modify-phases %standard-phases
(add-after
'install 'post-install
;; Remove commands and man pages redudant with
;; Coreutils.
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(dup (append-map (cut find-files out <>)
'("^kill" "^uptime"))))
(for-each delete-file dup)
#t))))))
(inputs `(("ncurses" ,ncurses)))
(home-page "https://gitlab.com/procps-ng/procps/")
(synopsis "Utilities that give information about processes")
(description
"Procps is the package that has a bunch of small useful utilities
that give information about processes using the Linux /proc file system.
The package includes the programs ps, top, vmstat, w, kill, free,
slabtop, and skill.")
(license license:gpl2)))
(define-public usbutils
(package
(name "usbutils")
(version "012")
(source
(origin
(method url-fetch)
(uri (string-append "mirror://kernel.org/linux/utils/usb/usbutils/"
"usbutils-" version ".tar.xz"))
(sha256
(base32 "0iiy0q7fzikavmdsjsb0sl9kp3gfh701qwyjjccvqh0qz4jlcqw8"))))
(build-system gnu-build-system)
(outputs (list "out" "python"))
(arguments
`(#:phases
(modify-phases %standard-phases
(add-before 'bootstrap 'patch-bootstrap-scripts
(lambda _
(substitute* "usbhid-dump/bootstrap"
(("/bin/bash") (which "bash")))
;; Don't let autogen.sh run configure with bogus options & CFLAGS.
(substitute* "autogen.sh"
(("^\\./configure.*") ""))
#t))
(add-after 'install 'separate-python-output
;; Separating one Python script shaves more than 106 MiB from :out.
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(out:python (assoc-ref outputs "python")))
(for-each (lambda (file)
(let ((old (string-append out "/" file))
(new (string-append out:python "/" file)))
(mkdir-p (dirname new))
(rename-file old new)))
(list "bin/lsusb.py"))
#t))))))
(inputs
`(("eudev" ,eudev)
("libusb" ,libusb)
("python" ,python)))
(native-inputs
`(("autoconf" ,autoconf)
("automake" ,automake)
("libtool" ,libtool)
("pkg-config" ,pkg-config)))
(home-page "http://www.linux-usb.org/")
(synopsis
"Tools for working with USB devices, such as lsusb")
(description
"Tools for working with USB devices, such as lsusb.")
(license license:gpl2+)))
(define-public e2fsprogs
(package
(name "e2fsprogs")
(version "1.45.6")
(source (origin
(method url-fetch)
(uri (string-append
"mirror://kernel.org/linux/kernel/people/tytso/"
"e2fsprogs/v" version "/"
"e2fsprogs-" version ".tar.xz"))
(sha256
(base32
"0mj2yizwygs7xww8jfy5mxjn8ww4pvc0b1hg1p2vsnirailsx9zz"))))
(build-system gnu-build-system)
(inputs `(("util-linux" ,util-linux "lib")))
(native-inputs `(("pkg-config" ,pkg-config)
("texinfo" ,texinfo) ;for the libext2fs Info manual
;; For tests.
("perl" ,perl)
("procps" ,procps)))
(arguments
'(;; util-linux is the preferred source for some of the libraries and
;; commands, so disable them (see, e.g.,
;; <http://git.buildroot.net/buildroot/commit/?id=e1ffc2f791b33633>.)
#:configure-flags (list "--disable-libblkid"
"--disable-libuuid" "--disable-uuidd"
"--disable-fsck"
;; Use symlinks instead of hard links for
;; 'fsck.extN' etc. This makes the resulting nar
;; smaller and is preserved across copies.
"--enable-symlink-install"
(string-append "LDFLAGS=-Wl,-rpath="
(assoc-ref %outputs "out")
"/lib")
;; Install libext2fs et al.
"--enable-elf-shlibs")
#:phases
(modify-phases %standard-phases
(add-before 'configure 'patch-shells
(lambda _
(substitute* "configure"
(("/bin/sh (.*)parse-types.sh" _ dir)
(string-append (which "sh") " " dir
"parse-types.sh")))
(substitute* "MCONFIG.in"
(("INSTALL_SYMLINK = /bin/sh")
"INSTALL_SYMLINK = sh"))
(substitute* (find-files "." "^Makefile.in$")
(("#!/bin/sh")
(string-append "#!" (which "sh"))))
#t))
(add-after 'install 'install-libs
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(lib (string-append out "/lib")))
(invoke "make" "install-libs")
;; Make the .a writable so that 'strip' works.
;; Failing to do that, due to debug symbols, we
;; retain a reference to the final
;; linux-libre-headers, which refer to the
;; bootstrap binaries.
(let ((archives (find-files lib "\\.a$")))
(for-each (lambda (file)
(chmod file #o666))
archives))
#t))))))
(home-page "http://e2fsprogs.sourceforge.net/")
(synopsis "Creating and checking ext2/ext3/ext4 file systems")
(description
"This package provides tools for manipulating ext2/ext3/ext4 file systems.")
(license (list license:gpl2 ;programs
license:lgpl2.0 ;libext2fs
license:x11)))) ;libuuid
(define e2fsprogs/static
(static-package
(package (inherit e2fsprogs)
(arguments
;; Do not build shared libraries.
(substitute-keyword-arguments (package-arguments e2fsprogs)
((#:configure-flags _)
'(list "--disable-blkid"))
((#:make-flags _)
'(list)))))))
(define-public e2fsck/static
(package
(name "e2fsck-static")
(version (package-version e2fsprogs))
(build-system trivial-build-system)
(source #f)
(inputs
`(("e2fsprogs" ,e2fsprogs/static)))
(arguments
`(#:modules ((guix build utils))
#:builder
(begin
(use-modules (guix build utils)
(ice-9 ftw)
(srfi srfi-26))
(let ((e2fsck (string-append (assoc-ref %build-inputs "e2fsprogs")
"/sbin/e2fsck"))
(bin (string-append (assoc-ref %outputs "out") "/sbin")))
(mkdir-p bin)
(with-directory-excursion bin
(copy-file e2fsck "e2fsck")
(remove-store-references "e2fsck")
(chmod "e2fsck" #o555))
#t))))
(home-page (package-home-page e2fsprogs))
(synopsis "Statically-linked e2fsck command from e2fsprogs")
(description "This package provides statically-linked e2fsck command taken
from the e2fsprogs package. It is meant to be used in initrds.")
(license (package-license e2fsprogs))))
(define-public extundelete
(package
(name "extundelete")
(version "0.2.4")
(source
(origin
(method url-fetch)
(uri (string-append "mirror://sourceforge/extundelete/"
"extundelete/" version "/extundelete-"
version ".tar.bz2"))
(sha256
(base32
"1x0r7ylxlp9lbj3d7sqf6j2a222dwy2nfpff05jd6mkh4ihxvyd1"))
(patches (search-patches "extundelete-e2fsprogs-1.44.patch"))))
(build-system gnu-build-system)
(inputs `(("e2fsprogs" ,e2fsprogs)))
(home-page "http://extundelete.sourceforge.net/")
(synopsis "Recover deleted files from ext2/3/4 partitions")
(description
"Extundelete is a set of tools that can recover deleted files from an
ext3 or ext4 partition.")
(license license:gpl2)))
(define-public zerofree
(package
(name "zerofree")
(version "1.1.1")
(home-page "https://frippery.org/uml/")
(source (origin
(method url-fetch)
(uri (string-append home-page name "-" version
".tgz"))
(sha256
(base32
"0rrqfa5z103ws89vi8kfvbks1cfs74ix6n1wb6vs582vnmhwhswm"))))
(build-system gnu-build-system)
(arguments
'(#:phases
(modify-phases %standard-phases
(delete 'configure) ; no configure script
(replace 'install
;; The Makefile lacks an ‘install’ target.
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(bin (string-append out "/bin")))
(chmod "zerofree" #o555)
(install-file "zerofree" bin)
#t))))
#:tests? #f)) ; no tests
(inputs `(("libext2fs" ,e2fsprogs)))
(synopsis "Zero non-allocated regions in ext2/ext3/ext4 file systems")
(description
"Zerofree finds the unallocated blocks with non-zero value content in an
ext2, ext3, or ext4 file system and fills them with zeroes (or another value).
This is a simple way to make disk images more compressible.
Zerofree requires the file system to be unmounted or mounted read-only.")
(license license:gpl2)))
(define-public strace
(package
(name "strace")
(version "5.7")
(home-page "https://strace.io")
(source (origin
(method url-fetch)
(uri (string-append home-page "/files/" version
"/strace-" version ".tar.xz"))
(sha256
(base32
"1n6cfz3i2krkyvxpdp3kmxhf7sy5xp0danzaiirbk5fdkfgvb15j"))))
(build-system gnu-build-system)
(arguments
'(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'patch-/bin/sh
(lambda _
(substitute* "strace.c"
(("/bin/sh") (which "sh")))
#t))
(add-after 'unpack 'disable-failing-tests
(lambda _
;; XXX These hang forever even if the test time-out is extended.
(substitute* "tests/Makefile.in"
(("^\tstrace-DD?D?\\.test \\\\.*") ""))
#t)))
;; Don't fail if the architecture doesn't support different personalities.
#:configure-flags '("--enable-mpers=check")
;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32459>.
#:parallel-tests? #f)) ; undeterministic failures
(native-inputs `(("perl" ,perl)))
(synopsis "System call tracer for Linux")
(description
"strace is a system call tracer, i.e. a debugging tool which prints out a
trace of all the system calls made by a another process/program.")
(license license:lgpl2.1+)))
(define-public ltrace
(package
(name "ltrace")
(version "0.7.3")
(source (origin
(method url-fetch)
(uri (string-append "http://www.ltrace.org/ltrace_" version
".orig.tar.bz2"))
(sha256
(base32
"00wmbdghqbz6x95m1mcdd3wd46l6hgcr4wggdp049dbifh3qqvqf"))))
(build-system gnu-build-system)
(inputs `(("libelf" ,libelf)))
(arguments
;; Compilation uses -Werror by default, but it fails.
'(#:configure-flags '("--disable-werror")))
(home-page "https://www.ltrace.org/")
(synopsis "Library call tracer for Linux")
(description
"ltrace intercepts and records dynamic library calls which are called by
an executed process and the signals received by that process. It can also
intercept and print the system calls executed by the program.")
(license license:gpl2+)))
(define-public alsa-lib
(package
(name "alsa-lib")
(version "1.2.2")
(source (origin
(method url-fetch)
(uri (string-append
"ftp://ftp.alsa-project.org/pub/lib/alsa-lib-"
version ".tar.bz2"))
(sha256
(base32
"1v5kb8jyvrpkvvq7dq8hfbmcj68lml97i4s0prxpfx2mh3c57s6q"))))
(build-system gnu-build-system)
(arguments
'(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
(assoc-ref %outputs "out")
"/lib"))))
(home-page "https://www.alsa-project.org/")
(synopsis "The Advanced Linux Sound Architecture libraries")
(description
"The Advanced Linux Sound Architecture (ALSA) provides audio and
MIDI functionality to the Linux-based operating system.")
(license license:lgpl2.1+)))
(define-public alsa-utils
(package
(name "alsa-utils")
(version "1.2.2")
(source (origin
(method url-fetch)
(uri (string-append "ftp://ftp.alsa-project.org/pub/utils/"
name "-" version ".tar.bz2"))
(sha256
(base32
"1wz460by17rmxrcydn583rd4lhj6wlvqs6x1j5pdzxn5g3app024"))))
(build-system gnu-build-system)
(arguments
;; XXX: Disable man page creation until we have DocBook.
'(#:configure-flags (list "--disable-xmlto"
;; The udev rule is responsible for restoring
;; the volume.
(string-append "--with-udev-rules-dir="
(assoc-ref %outputs "out")
"/lib/udev/rules.d"))
#:phases
(modify-phases %standard-phases
(add-before 'check 'disable-broken-test
(lambda _
;; XXX: The 1.1.8 release tarball is missing a header that's
;; required for this test to work. Fixed in 1.1.9.
(substitute* "axfer/test/Makefile"
((".*container-test.*") ""))
#t))
(add-before
'install 'pre-install
(lambda _
;; Don't try to mkdir /var/lib/alsa.
(substitute* "Makefile"
(("\\$\\(MKDIR_P\\) .*ASOUND_STATE_DIR.*")
"true\n"))
#t)))))
(native-inputs
`(("gettext" ,gettext-minimal)))
(inputs
`(("libsamplerate" ,libsamplerate)
("ncurses" ,ncurses)
("alsa-lib" ,alsa-lib)
("xmlto" ,xmlto)))
(home-page "http://www.alsa-project.org/")
(synopsis "Utilities for the Advanced Linux Sound Architecture (ALSA)")
(description
"The Advanced Linux Sound Architecture (ALSA) provides audio and
MIDI functionality to the Linux-based operating system.")
;; This is mostly GPLv2+ but a few files such as 'alsactl.c' are
;; GPLv2-only.
(license license:gpl2)))
(define-public alsa-plugins
(package
(name "alsa-plugins")
(version "1.2.2")
(source (origin
(method url-fetch)
(uri (string-append "ftp://ftp.alsa-project.org/pub/plugins/"
name "-" version ".tar.bz2"))
(sha256
(base32
"0z9k3ssbfk2ky2w13avgyf202j1drsz9sv3834bp33cj1i2hc3qw"))))
(build-system gnu-build-system)
;; TODO: Split libavcodec and speex if possible. It looks like they can not
;; be split, there are references to both in files.
;; TODO: Remove OSS related plugins, they add support to run native
;; ALSA applications on OSS however we do not offer OSS and OSS is
;; obsolete.
(outputs '("out" "pulseaudio" "jack"))
(arguments
`(#:configure-flags '(;; Do not install a "local" configuration targeted
;; for /etc/alsa. On Guix System plugins are loaded from
;; the ALSA service, and other distributions likely
;; won't use these files.
"--with-alsalconfdir=/tmp/noop")
#:phases
(modify-phases %standard-phases
(add-after 'install 'split
(lambda* (#:key inputs outputs #:allow-other-keys)
;; Distribute the binaries to the various outputs.
(let* ((out (assoc-ref outputs "out"))
(jack (assoc-ref outputs "jack"))
(jacklib (string-append jack "/lib/alsa-lib"))
(pua (assoc-ref outputs "pulseaudio"))
(pualib (string-append pua "/lib/alsa-lib")))
;; For jack.
(mkdir-p jacklib)
(for-each (lambda (file)
(rename-file file (string-append jacklib "/" (basename file))))
(find-files out ".*jack\\.(la|so)"))
;; For pulseaudio.
(mkdir-p pualib)
(for-each (lambda (file)
(rename-file file (string-append pualib "/" (basename file))))
(find-files out ".*pulse\\.(la|so)"))
#t))))))
(inputs
`(("alsa-lib" ,alsa-lib)
("jack" ,jack-1)
("speex" ,speex) ; libspeexdsp resampling plugin
("libsamplerate" ,libsamplerate) ; libsamplerate resampling plugin
("ffmpeg" ,ffmpeg) ; libavcodec resampling plugin, a52 plugin
("pulseaudio" ,pulseaudio))) ; PulseAudio plugin
(native-inputs
`(("pkg-config" ,pkg-config)))
(home-page "http://www.alsa-project.org/")
(synopsis "Plugins for the Advanced Linux Sound Architecture (ALSA)")
(description
"The Advanced Linux Sound Architecture (ALSA) provides audio and
MIDI functionality to the Linux-based operating system. This package enhances ALSA
by providing additional plugins which include: upmixing, downmixing, jackd and
pulseaudio support for native alsa applications, format conversion (s16 to a52), and
external rate conversion.")
(license (list license:gpl2+
;; `rate/rate_samplerate.c': LGPL v2.1 or later.
license:lgpl2.1+))))
(define-public iptables
(package
(name "iptables")
;; XXX When updating, remove the ‘install-missing-script’ phase.
(version "1.8.5")
(source
(origin
(method url-fetch)
(uri (list (string-append "mirror://netfilter.org/iptables/iptables-"
version ".tar.bz2")
(string-append "https://www.netfilter.org/projects/iptables/"
"files/iptables-" version ".tar.bz2")))
(sha256
(base32 "02a3575ypdpg6a2x752mhk3f7h1381ymkq1n0gss6fp6292xfmyl"))))
(build-system gnu-build-system)
(native-inputs
`(("pkg-config" ,pkg-config)
("flex" ,flex)
("bison" ,bison)))
(inputs
`(("libmnl" ,libmnl)
("libnftnl" ,libnftnl)))
(arguments
'(#:tests? #f ; no test suite
#:configure-flags ; add $libdir to the RUNPATH of executables
(list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib"))
#:phases
(modify-phases %standard-phases
(add-after 'install 'install-missing-script
;; A typo prevents installation of /sbin/iptables-apply. It's been
;; fixed upstream (d4ed0c741fc789bb09d977d74d30875fdd50d08b), but
;; a patch would require bootstrapping and more inputs. Simply copy
;; the file ourselves.
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(sbin (string-append out "/sbin")))
(install-file "iptables/iptables-apply" sbin)
#t))))))
(home-page "https://www.netfilter.org/projects/iptables/index.html")
(synopsis "Programs to configure Linux IP packet filtering rules")
(description
"@command{iptables} is the user-space command line program used to
configure the Linux 2.4.x and later IPv4 packet filtering ruleset
(@dfn{firewall}), including @dfn{NAT} (Network Address Translation).
This package also includes @command{ip6tables}, which is used to configure the
IPv6 packet filter.
Both commands are targeted at system administrators.")
(license license:gpl2+)))
(define-public lsscsi
(package
(name "lsscsi")
(version "0.31")
(source (origin
(method url-fetch)
(uri (string-append
"http://sg.danny.cz/scsi/lsscsi-" version ".tar.xz"))
(sha256
(base32
"1ry2y34xmpgxdbfbyvs8cjmbx0fn222yjdab87wj21q60nab5p75"))))
(build-system gnu-build-system)
(synopsis "Lists information about SCSI or NVMe devices in Linux")
(home-page "http://sg.danny.cz/scsi/lsscsi.html")
(description
"@command{lsscsi} lists SCSI logical units or SCSI targets. It can
also list NVMe namespaces or controllers and show the relationship between a
device's primary node name, its SCSI generic (sg) node name and its kernel
name.")
(license license:gpl2)))
(define-public ebtables
(package
(name "ebtables")
(version "2.0.11")
(source (origin
(method url-fetch)
(uri (string-append
"mirror://netfilter.org/ebtables/ebtables-"
version ".tar.gz"))
(sha256
(base32
"0apxgmkhsk3vxn9q3libxn3dgrdljrxyy4mli2gk49m7hi3na7xp"))))
(build-system gnu-build-system)
(inputs
`(("perl" ,perl)
("iptables" ,iptables)))
(synopsis "Ethernet bridge frame table administration")
(home-page "https://ebtables.netfilter.org/")
(description
"ebtables is an application program used to set up and maintain the
tables of rules (inside the Linux kernel) that inspect Ethernet frames. It is
analogous to the iptables application, but less complicated, due to the fact
that the Ethernet protocol is much simpler than the IP protocol.")
(license license:gpl2+)))
(define-public iproute
(package
(name "iproute2")
(version "5.7.0")
(source (origin
(method url-fetch)
(uri (string-append
"mirror://kernel.org/linux/utils/net/iproute2/iproute2-"
version ".tar.xz"))
(sha256
(base32
"088gs56iqhdlpw1iqjwrss4zxd4zbl2wl8s2implrrdajjxcfpbj"))))
(build-system gnu-build-system)
(arguments
`( ;; There is a test suite, but it wants network namespaces and sudo.
#:tests? #f
#:make-flags (let ((out (assoc-ref %outputs "out")))
(list "DESTDIR="
(string-append "BASH_COMPDIR=" out
"/etc/bash_completion.d")
(string-append "LIBDIR=" out "/lib")
(string-append "HDRDIR=" out "/include")
(string-append "SBINDIR=" out "/sbin")
(string-append "CONFDIR=" out "/etc")
(string-append "DOCDIR=" out "/share/doc/"
,name "-" ,version)
(string-append "MANDIR=" out "/share/man")))
#:phases (modify-phases %standard-phases
(add-before 'install 'pre-install
(lambda _
;; Don't attempt to create /var/lib/arpd.
(substitute* "Makefile"
(("^.*ARPDDIR.*$") ""))
#t)))))
(inputs
`(("db4" ,bdb)
("iptables" ,iptables)
("libmnl" ,libmnl)))
(native-inputs
`(("bison" ,bison)
("flex" ,flex)
("pkg-config" ,pkg-config)))
;; For tests.
;; ("libmnl" ,libmnl)
;; ("util-linux" ,util-linux)
(home-page
"https://wiki.linuxfoundation.org/networking/iproute2")
(synopsis
"Utilities for controlling TCP/IP networking and traffic in Linux")
(description
"Iproute2 is a collection of utilities for controlling TCP/IP networking
and traffic with the Linux kernel. The most important of these are
@command{ip}, which configures IPv4 and IPv6, and @command{tc} for traffic
control.
Most network configuration manuals still refer to ifconfig and route as the
primary network configuration tools, but ifconfig is known to behave
inadequately in modern network environments, and both should be deprecated.")
(license license:gpl2+)))
(define-public net-tools
;; XXX: This package is basically unmaintained, but it provides a few
;; commands not yet provided by Inetutils, such as 'route', so we have to
;; live with it.
(let ((commit "479bb4a7e11a4084e2935c0a576388f92469225b")
(revision "0"))
(package
(name "net-tools")
(version (string-append "1.60-" revision "." (string-take commit 7)))
(source (origin
(method url-fetch)
(uri (string-append "https://sourceforge.net/code-snapshots/git/"
"n/ne/net-tools/code.git/net-tools-code-"
commit ".zip"))
(file-name (string-append name "-" version ".zip"))
(sha256
(base32
"0hz9fda9d78spp774b6rr5xaxav7cm4h0qcpxf70rvdbrf6qx7vy"))))
(home-page "http://net-tools.sourceforge.net/")
(build-system gnu-build-system)
(arguments
`(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-1)
(srfi srfi-26))
#:phases
(modify-phases %standard-phases
(replace 'configure
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(mkdir-p (string-append out "/bin"))
(mkdir-p (string-append out "/sbin"))
;; Pretend we have everything...
(system "yes | make config")
;; ... except for the things we don't have.
;; HAVE_AFDECnet requires libdnet, which we don't have.
;; HAVE_HWSTRIP and HAVE_HWTR require kernel headers
;; that have been removed.
;; XXX SELINUX and AFBLUETOOTH are removed for now, but we should
;; think about adding them later.
(substitute* '("config.make" "config.h")
(("^.*HAVE_(AFDECnet|HWSTRIP|HWTR|SELINUX|AFBLUETOOTH)[ =]1.*$")
""))
#t)))
(add-after 'install 'remove-redundant-commands
(lambda* (#:key outputs #:allow-other-keys)
;; Remove commands and man pages redundant with Inetutils.
(let* ((out (assoc-ref outputs "out"))
(dup (append-map (cut find-files out <>)
'("^hostname"
"^(yp|nis|dns)?domainname"))))
(for-each delete-file dup)
#t))))
;; Binaries that depend on libnet-tools.a don't declare that
;; dependency, making it parallel-unsafe.
#:parallel-build? #f
#:tests? #f ; no test suite
#:make-flags (let ((out (assoc-ref %outputs "out")))
(list ,(string-append "CC=" (cc-for-target))
(string-append "BASEDIR=" out)
(string-append "INSTALLNLSDIR=" out "/share/locale")
(string-append "mandir=/share/man")))))
(native-inputs `(("gettext" ,gettext-minimal)
("unzip" ,unzip)))
(supported-systems (delete "i586-gnu" %supported-systems))
(synopsis "Tools for controlling the network subsystem in Linux")
(description
"This package includes the important tools for controlling the network
subsystem of the Linux kernel. This includes arp, ifconfig, netstat, rarp and
route. Additionally, this package contains utilities relating to particular
network hardware types (plipconfig, slattach) and advanced aspects of IP
configuration (iptunnel, ipmaddr).")
(license license:gpl2+))))
(define-public libcap
(package
(name "libcap")
(version "2.31")
(source (origin
(method url-fetch)
(uri (string-append
"mirror://kernel.org/linux/libs/security/linux-privs/"
"libcap2/libcap-" version ".tar.xz"))
(sha256
(base32
"0ikwm0kngrqa4ci80lqnrkk17kg09q7dxrz28y0gm5qw3vj8s266"))))
(build-system gnu-build-system)
(arguments '(#:phases
(modify-phases %standard-phases
(replace 'configure
;; Add $libdir to the RUNPATH of executables.
(lambda _
(substitute* "Make.Rules"
(("LDFLAGS := #-g")
(string-append "LDFLAGS := -Wl,-rpath="
%output "/lib")))
#t)))
#:test-target "test"
#:make-flags (list "lib=lib"
(string-append "prefix="
(assoc-ref %outputs "out"))
"RAISE_SETFCAP=no")))
(native-inputs `(("perl" ,perl)))
(supported-systems (delete "i586-gnu" %supported-systems))
(home-page "https://sites.google.com/site/fullycapable/")
(synopsis "Library for working with POSIX capabilities")
(description
"Libcap2 provides a programming interface to POSIX capabilities on
Linux-based operating systems.")
;; License is BSD-3 or GPLv2, at the user's choice.
(license license:gpl2)))
;; libcap 2.31 causes problems for 'fakeroot', so provide this newer variant.
;; To be merged with libcap on the next rebuild cycle.
(define-public libcap/next
(package
(inherit libcap)
(version "2.34")
(source (origin
(method url-fetch)
(uri (string-append
"mirror://kernel.org/linux/libs/security/linux-privs/"
"libcap2/libcap-" version ".tar.xz"))
(sha256
(base32
"048n1gy2p48vl9hkrr9wymfxxcpwj2aslz2bv79nhl4m2lhd9kdf"))))))
(define-public bridge-utils
(package
(name "bridge-utils")
(version "1.6")
(source
(origin
(method url-fetch)
(uri (string-append "mirror://kernel.org/linux/utils/net/bridge-utils/"
"bridge-utils-" version ".tar.xz"))
(sha256
(base32 "1j16kr44csyr4yqxly26l1yw2bh4nkiasgwvask2i2gvsnsyyryc"))))
(build-system gnu-build-system)
;; The tarball lacks all the generated files.
(native-inputs `(("autoconf" ,autoconf)
("automake" ,automake)))
(arguments
'(#:phases
(modify-phases %standard-phases
(add-before 'bootstrap 'patch-stuff
(lambda _
;; Fix "field ‘ip6’ has incomplete type" errors.
(substitute* "libbridge/libbridge.h"
(("#include <linux/if_bridge.h>")
"#include <linux/in6.h>\n#include <linux/if_bridge.h>"))
;; Ensure that the entire build fails if one of the
;; sub-Makefiles fails.
(substitute* "Makefile.in"
(("\\$\\(MAKE\\) \\$\\(MFLAGS\\) -C \\$\\$x ;")
"$(MAKE) $(MFLAGS) -C $$x || exit 1;"))
#t)))
#:tests? #f)) ; no 'check' target
(home-page "https://wiki.linuxfoundation.org/networking/bridge")
(synopsis "Manipulate Ethernet bridges")
(description
"Utilities for Linux's Ethernet bridging facilities. A bridge is a way
to connect two Ethernet segments together in a protocol independent way.
Packets are forwarded based on Ethernet address, rather than IP address (like
a router). Since forwarding is done at Layer 2, all protocols can go
transparently through a bridge.")
(license license:gpl2+)))
(define-public libnl
(package
(name "libnl")
(version "3.5.0")
(source (origin
(method url-fetch)
(uri (string-append
"https://github.com/thom311/libnl/releases/download/"
"libnl" (string-join (string-split version #\.) "_")
"/libnl-" version ".tar.gz"))
(sha256
(base32
"1yh5bqmkivd78x378x34gzb28lvykn6b9k3hgvvpdnj5jpn3689m"))))
(build-system gnu-build-system)
(native-inputs
`(("bison" ,bison)
("flex" ,flex)
("pkg-config" ,pkg-config)
("swig" ,swig)
("libnl3-doc"
,(origin
(method url-fetch)
(uri (string-append
"https://github.com/thom311/libnl/releases/download/libnl"
(string-join (string-split version #\.) "_")
"/libnl-doc-" version ".tar.gz"))
(sha256
(base32 "19p5y8q3cm5wqvamqc4s5syxnnkvzxy3gw8ivxk6fv9ybn8jm35h"))))))
(outputs `("out" "doc"))
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'install 'install-doc
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
(let ((dest (string-append (assoc-ref outputs "doc")
"/share/doc/libnl")))
(mkdir-p dest)
(invoke "tar" "xf" (assoc-ref
(or native-inputs inputs)
"libnl3-doc")
"--strip-components=1" "-C" dest)))))))
(home-page "https://www.infradead.org/~tgr/libnl/")
(synopsis "NetLink protocol library suite")
(description
"The libnl suite is a collection of libraries providing APIs to netlink
protocol based Linux kernel interfaces. Netlink is an IPC mechanism primarily
between the kernel and user space processes. It was designed to be a more
flexible successor to ioctl to provide mainly networking related kernel
configuration and monitoring interfaces.")
;; Most files are LGPLv2.1-only, but some are GPLv2-only (like
;; 'nl-addr-add.c'), so the result is GPLv2-only.
(license license:gpl2)))
;; libnl python extensions used to be outputs of libnl. However, as
;; cross-compiling python extensions is currently broken, create separate
;; packages for libnl python extensions.
(define (libnl-python-package python)
(let ((name (string-append "libnl-" python)))
(package
(inherit libnl)
(name name)
(inputs `(,@(cond
((string=? python "python2")
`(("python-2" ,python-2)))
((string=? python "python3")
`(("python-3" ,python-3))))))
(propagated-inputs `(("libnl" ,libnl)))
(outputs '("out"))
(arguments
`(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-1))
#:phases
(modify-phases %standard-phases
(replace 'install
(lambda* (#:key inputs outputs #:allow-other-keys)
(define (python-inst python)
(invoke python "setup.py" "build")
(invoke python "setup.py" "install"
(string-append "--prefix="
(assoc-ref %outputs "out")))
(invoke python "setup.py" "clean"))
(setenv "LDFLAGS" (format #f "-Wl,-rpath=~a/lib"
(assoc-ref inputs "libnl")))
(with-directory-excursion "./python" (python-inst ,python))
#t))))))))
(define-public libnl-python2 (libnl-python-package "python2"))
(define-public libnl-python3 (libnl-python-package "python3"))
(define-public iw
(package
(name "iw")
(version "4.14")
(source (origin
(method url-fetch)
(uri (string-append
"mirror://kernel.org/software/network/iw/iw-"
version ".tar.xz"))
(sha256
(base32
"12ddd6vh6vs97135bnlyr0szv7hvpbnmfh48584frzab0z0725ph"))))
(build-system gnu-build-system)
(native-inputs `(("pkg-config" ,pkg-config)))
(inputs `(("libnl" ,libnl)))
(arguments
`(#:make-flags
(let* ((target ,(%current-target-system))
(pkg-config (if target
(string-append target "-pkg-config")
"pkg-config")))
(list
,(string-append "CC=" (cc-for-target))
(string-append "PKG_CONFIG="
(assoc-ref %build-inputs "pkg-config")
"/bin/" pkg-config)
(string-append "PREFIX=" (assoc-ref %outputs "out"))))
#:phases (modify-phases %standard-phases (delete 'configure))))
(home-page "https://wireless.wiki.kernel.org/")
(synopsis "Tool for configuring wireless devices")
(description
"iw is a new nl80211 based CLI configuration utility for wireless
devices. It replaces @code{iwconfig}, which is deprecated.")
(license license:isc)))
(define-public powertop
(package
(name "powertop")
(version "2.13")
(source
(origin
(method url-fetch)
(uri (string-append "https://01.org/sites/default/files/downloads/"
"powertop-" version ".tar.gz"))
(sha256
(base32 "0y1ixw8v17fdb1ima0zshrd0rh4zxdh10r93nrrvq6d4lhn9jpx6"))))
(build-system gnu-build-system)
(arguments
'(#:phases
(modify-phases %standard-phases
;; TODO: Patch some hardcoded "wlan0" in calibrate/calibrate.cpp to
;; allow calibrating the network interface in Guix System.
(add-after 'unpack 'patch-absolute-file-names
(lambda* (#:key inputs #:allow-other-keys)
(let ((kmod (assoc-ref inputs "kmod")))
(substitute* (find-files "src" "\\.cpp$")
;; Give the right 'modprobe' file name so that essential
;; modules such as msr.ko can be loaded.
(("/sbin/modprobe") (string-append kmod "/bin/modprobe"))
;; These programs are only needed to calibrate, so using
;; relative file names avoids adding extra inputs. When they
;; are missing powertop gracefully handles it.
(("/usr/bin/hcitool") "hcitool")
(("/usr/bin/xset") "xset")
(("/usr/sbin/hciconfig") "hciconfig"))
#t))))))
(inputs
`(("kmod" ,kmod)
("libnl" ,libnl)
("ncurses" ,ncurses)
("pciutils" ,pciutils)
("zlib" ,zlib)))
(native-inputs
`(("pkg-config" ,pkg-config)))
(home-page "https://01.org/powertop/")
(synopsis "Analyze power consumption on Intel-based laptops")
(description
"PowerTOP is a Linux tool to diagnose issues with power consumption and
power management. In addition to being a diagnostic tool, PowerTOP also has
an interactive mode where the user can experiment various power management
settings for cases where the operating system has not enabled these
settings.")
(license license:gpl2)))
(define-public aumix
(package
(name "aumix")
(version "2.9.1")
(source (origin
(method url-fetch)
(uri (string-append
"http://www.jpj.net/~trevor/aumix/releases/aumix-"
version ".tar.bz2"))
(sha256
(base32
"0a8fwyxnc5qdxff8sl2sfsbnvgh6pkij4yafiln0fxgg6bal7knj"))))
(build-system gnu-build-system)
(inputs `(("ncurses" ,ncurses)))
(home-page "http://www.jpj.net/~trevor/aumix.html")
(synopsis "Audio mixer for X and the console")
(description
"Aumix adjusts an audio mixer from X, the console, a terminal,
the command line or a script.")
(license license:gpl2+)))
(define-public iotop
(package
(name "iotop")
(version "0.6")
(source
(origin
(method url-fetch)
(uri (string-append "http://guichaz.free.fr/iotop/files/iotop-"
version ".tar.gz"))
(sha256 (base32
"1kp8mqg2pbxq4xzpianypadfxcsyfgwcaqgqia6h9fsq6zyh4z0s"))))
(build-system python-build-system)
(arguments
'(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'fix-build-with-python3
(lambda _
(substitute* "setup.py"
(("itervalues") "values"))
#t)))
;; There are currently no checks in the package.
#:tests? #f))
(native-inputs `(("python" ,python)))
(home-page "http://guichaz.free.fr/iotop/")
(synopsis
"Displays the IO activity of running processes")
(description
"Iotop is a Python program with a top like user interface to show the
processes currently causing I/O.")
(license license:gpl2+)))
(define-public fuse
(package
(name "fuse")
(version "2.9.9")
(source (origin
(method url-fetch)
(uri (string-append "https://github.com/libfuse/libfuse/releases/"
"download/fuse-" version
"/fuse-" version ".tar.gz"))
(sha256
(base32
"1ddlq6kzxilccgbvxjfx80jx6kamgw4sv49phks2zhlcc1frvrnh"))
(patches (search-patches "fuse-overlapping-headers.patch"))))
(build-system gnu-build-system)
(inputs `(("util-linux" ,util-linux)))
(arguments
'(#:configure-flags (list (string-append "MOUNT_FUSE_PATH="
(assoc-ref %outputs "out")
"/sbin")
(string-append "INIT_D_PATH="
(assoc-ref %outputs "out")
"/etc/init.d")
;; The rule makes /dev/fuse 666.
(string-append "UDEV_RULES_PATH="
(assoc-ref %outputs "out")
"/lib/udev/rules.d"))
#:phases
(modify-phases %standard-phases
(add-before 'build 'set-file-names
(lambda* (#:key inputs #:allow-other-keys)
;; libfuse calls out to mount(8) and umount(8). Make sure
;; it refers to the right ones.
(substitute* '("lib/mount_util.c" "util/mount_util.c")
(("/bin/(u?)mount" _ maybe-u)
(string-append (assoc-ref inputs