aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/version-control.scm
blob: 13669925ab04a8526b734df52afad0febcce1d05 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Nils Gillmann <ng0@n0.is>
;;; Copyright © 2016 Sou Bunnbu <iyzsong@member.fsf.org>
;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Christopher Baines <mail@cbaines.net>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu services version-control)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services shepherd)
  #:use-module (gnu services web)
  #:use-module (gnu system shadow)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages admin)
  #:use-module (guix records)
  #:use-module (guix gexp)
  #:use-module (guix store)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 format)
  #:use-module (ice-9 match)
  #:export (git-daemon-service
            git-daemon-service-type
            git-daemon-configuration
            git-daemon-configuration?

            git-http-configuration
            git-http-configuration?
            git-http-nginx-location-configuration

            <gitolite-configuration>
            gitolite-configuration
            gitolite-configuration-package
            gitolite-configuration-user
            gitolite-configuration-rc-file
            gitolite-configuration-admin-pubkey

            <gitolite-rc-file>
            gitolite-rc-file
            gitolite-rc-file-umask
            gitolite-rc-file-git-config-keys
            gitolite-rc-file-roles
            gitolite-rc-file-enable

            gitolite-service-type))

;;; Commentary:
;;;
;;; Version Control related services.
;;;
;;; Code:


;;;
;;; Git daemon.
;;;

(define-record-type* <git-daemon-configuration>
  git-daemon-configuration
  make-git-daemon-configuration
  git-daemon-configuration?
  (package          git-daemon-configuration-package        ;package
                    (default git))
  (export-all?      git-daemon-configuration-export-all     ;boolean
                    (default #f))
  (base-path        git-daemon-configuration-base-path      ;string | #f
                    (default "/srv/git"))
  (user-path        git-daemon-configuration-user-path      ;string | #f
                    (default #f))
  (listen           git-daemon-configuration-listen         ;list of string
                    (default '()))
  (port             git-daemon-configuration-port           ;number | #f
                    (default #f))
  (whitelist        git-daemon-configuration-whitelist      ;list of string
                    (default '()))
  (extra-options    git-daemon-configuration-extra-options  ;list of string
                    (default '())))

(define git-daemon-shepherd-service
  (match-lambda
    (($ <git-daemon-configuration>
        package export-all? base-path user-path
        listen port whitelist extra-options)
     (let* ((git     (file-append package "/bin/git"))
            (command `(,git
                       "daemon" "--syslog" "--reuseaddr"
                       ,@(if export-all?
                             '("--export-all")
                             '())
                       ,@(if base-path
                             `(,(string-append "--base-path=" base-path))
                             '())
                       ,@(if user-path
                             `(,(string-append "--user-path=" user-path))
                             '())
                       ,@(map (cut string-append "--listen=" <>) listen)
                       ,@(if port
                             `(,(string-append
                                 "--port=" (number->string port)))
                             '())
                       ,@extra-options
                       ,@whitelist)))
       (list (shepherd-service
              (documentation "Run the git-daemon.")
              (requirement '(networking))
              (provision '(git-daemon))
              (start #~(make-forkexec-constructor '#$command
                                                  #:user "git-daemon"
                                                  #:group "git-daemon"))
              (stop #~(make-kill-destructor))))))))

(define %git-daemon-accounts
  ;; User account and group for git-daemon.
  (list (user-group
         (name "git-daemon")
         (system? #t))
        (user-account
         (name "git-daemon")
         (system? #t)
         (group "git-daemon")
         (comment "Git daemon user")
         (home-directory "/var/empty")
         (shell (file-append shadow "/sbin/nologin")))))

(define (git-daemon-activation config)
  "Return the activation gexp for git-daemon using CONFIG."
  (let ((base-path (git-daemon-configuration-base-path config)))
    #~(begin
        (use-modules (guix build utils))
        ;; Create the 'base-path' directory when it's not '#f'.
        (and=> #$base-path mkdir-p))))

(define git-daemon-service-type
  (service-type
   (name 'git-daemon)
   (extensions
    (list (service-extension shepherd-root-service-type
                             git-daemon-shepherd-service)
          (service-extension account-service-type
                             (const %git-daemon-accounts))
          (service-extension activation-service-type
                             git-daemon-activation)))
   (description
    "Expose Git respositories over the insecure @code{git://} TCP-based
protocol.")
   (default-value (git-daemon-configuration))))

(define* (git-daemon-service #:key (config (git-daemon-configuration)))
  "Return a service that runs @command{git daemon}, a simple TCP server to
expose repositories over the Git protocol for annoymous access.

The optional @var{config} argument should be a
@code{<git-daemon-configuration>} object, by default it allows read-only
access to exported repositories under @file{/srv/git}."
  (service git-daemon-service-type config))


;;;
;;; HTTP access.  Add the result of calling
;;; git-http-nginx-location-configuration to an nginx-server-configuration's
;;; "locations" field.
;;;

(define-record-type* <git-http-configuration>
  git-http-configuration
  make-git-http-configuration
  git-http-configuration?
  (package          git-http-configuration-package        ;package
                    (default git))
  (git-root         git-http-configuration-git-root       ;string
                    (default "/srv/git"))
  (export-all?      git-http-configuration-export-all?    ;boolean
                    (default #f))
  (uri-path         git-http-configuration-uri-path       ;string
                    (default "/git/"))
  (fcgiwrap-socket  git-http-configuration-fcgiwrap-socket ;string
                    (default "127.0.0.1:9000")))

(define* (git-http-nginx-location-configuration #:optional
                                                (config
                                                 (git-http-configuration)))
  (match config
    (($ <git-http-configuration> package git-root export-all?
                                 uri-path fcgiwrap-socket)
     (nginx-location-configuration
      (uri (string-append "~ /" (string-trim-both uri-path #\/) "(/.*)"))
      (body
       (list
        (list "fastcgi_pass " fcgiwrap-socket ";")
        (list "fastcgi_param SCRIPT_FILENAME "
              package "/libexec/git-core/git-http-backend"
              ";")
        "fastcgi_param QUERY_STRING $query_string;"
        "fastcgi_param REQUEST_METHOD $request_method;"
        "fastcgi_param CONTENT_TYPE $content_type;"
        "fastcgi_param CONTENT_LENGTH $content_length;"
        (if export-all?
            "fastcgi_param GIT_HTTP_EXPORT_ALL \"\";"
            "")
        (list "fastcgi_param GIT_PROJECT_ROOT " git-root ";")
        "fastcgi_param PATH_INFO $1;"))))))


;;;
;;; Gitolite
;;;

(define-record-type* <gitolite-rc-file>
  gitolite-rc-file make-gitolite-rc-file
  gitolite-rc-file?
  (umask           gitolite-rc-file-umask
                   (default #o0077))
  (git-config-keys gitolite-rc-file-git-config-keys
                   (default ""))
  (roles           gitolite-rc-file-roles
                   (default '(("READERS" . 1)
                              ("WRITERS" . 1))))
  (enable          gitolite-rc-file-enable
                   (default '("help"
                              "desc"
                              "info"
                              "perms"
                              "writable"
                              "ssh-authkeys"
                              "git-config"
                              "daemon"
                              "gitweb"))))

(define-gexp-compiler (gitolite-rc-file-compiler
                       (file <gitolite-rc-file>) system target)
  (match file
    (($ <gitolite-rc-file> umask git-config-keys roles enable)
     (apply text-file* "gitolite.rc"
      `("%RC = (\n"
        "    UMASK => " ,(format #f "~4,'0o" umask) ",\n"
        "    GIT_CONFIG_KEYS => '" ,git-config-keys "',\n"
        "    ROLES => {\n"
        ,@(map (match-lambda
                 ((role . value)
                  (simple-format #f "        ~A => ~A,\n" role value)))
               roles)
        "    },\n"
        "\n"
        "    ENABLE => [\n"
        ,@(map (lambda (value)
                 (simple-format #f "        '~A',\n" value))
               enable)
        "    ],\n"
        ");\n"
        "\n"
        "1;\n")))))

(define-record-type* <gitolite-configuration>
  gitolite-configuration make-gitolite-configuration
  gitolite-configuration?
  (package        gitolite-configuration-package
                  (default gitolite))
  (user           gitolite-configuration-user
                  (default "git"))
  (group          gitolite-configuration-group
                  (default "git"))
  (home-directory gitolite-configuration-home-directory
                  (default "/var/lib/gitolite"))
  (rc-file        gitolite-configuration-rc-file
                  (default (gitolite-rc-file)))
  (admin-pubkey   gitolite-configuration-admin-pubkey))

(define gitolite-accounts
  (match-lambda
    (($ <gitolite-configuration> package user group home-directory
                                 rc-file admin-pubkey)
     ;; User group and account to run Gitolite.
     (list (user-group (name user) (system? #t))
           (user-account
            (name user)
            (group group)
            (system? #t)
            (comment "Gitolite user")
            (home-directory home-directory))))))

(define gitolite-activation
  (match-lambda
    (($ <gitolite-configuration> package user group home
                                 rc-file admin-pubkey)
     #~(begin
         (use-modules (ice-9 match)
                      (guix build utils))

         (let* ((user-info (getpwnam #$user))
                (admin-pubkey #$admin-pubkey)
                (pubkey-file (string-append
                              #$home "/"
                              (basename
                               (strip-store-file-name admin-pubkey)))))

           (simple-format #t "guix: gitolite: installing ~A\n" #$rc-file)
           (copy-file #$rc-file #$(string-append home "/.gitolite.rc"))

           ;; The key must be writable, so copy it from the store
           (copy-file admin-pubkey pubkey-file)

           (chmod pubkey-file #o500)
           (chown pubkey-file
                  (passwd:uid user-info)
                  (passwd:gid user-info))

           ;; Set the git configuration, to avoid gitolite trying to use
           ;; the hostname command, as the network might not be up yet
           (with-output-to-file #$(string-append home "/.gitconfig")
             (lambda ()
               (display "[user]
        name = GNU Guix
        email = guix@localhost
")))
           ;; Run Gitolite setup, as this updates the hooks and include the
           ;; admin pubkey if specified. The admin pubkey is required for
           ;; initial setup, and will replace the previous key if run after
           ;; initial setup
           (match (primitive-fork)
             (0
              ;; Exit with a non-zero status code if an exception is thrown.
              (dynamic-wind
                (const #t)
                (lambda ()
                  (setenv "HOME" (passwd:dir user-info))
                  (setenv "USER" #$user)
                  (setgid (passwd:gid user-info))
                  (setuid (passwd:uid user-info))
                  (primitive-exit
                   (system* #$(file-append package "/bin/gitolite")
                            "setup"
                            "-m" "gitolite setup by GNU Guix"
                            "-pk" pubkey-file)))
                (lambda ()
                  (primitive-exit 1))))
             (pid (waitpid pid)))

           (when (file-exists? pubkey-file)
             (delete-file pubkey-file)))))))

(define gitolite-service-type
  (service-type
   (name 'gitolite)
   (extensions
    (list (service-extension activation-service-type
                             gitolite-activation)
          (service-extension account-service-type
                             gitolite-accounts)
          (service-extension profile-service-type
                             ;; The Gitolite package in Guix uses
                             ;; gitolite-shell in the authorized_keys file, so
                             ;; gitolite-shell needs to be on the PATH for
                             ;; gitolite to work.
                             (lambda (config)
                               (list
                                (gitolite-configuration-package config))))))
   (description
    "Setup @command{gitolite}, a Git hosting tool providing access over SSH..
By default, the @code{git} user is used, but this is configurable.
Additionally, Gitolite can integrate with with tools like gitweb or cgit to
provide a web interface to view selected repositories.")))
.org> ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2016, 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2016 Roel Janssen <roel@gnu.org> ;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com> ;;; Copyright © 2017 Hartmut Goebel <h.goebel@crazy-compilers.com> ;;; Copyright © 2017 Stefan Reichör <stefan@xsteve.at> ;;; Copyright © 2018 Vasile Dumitrascu <va511e@yahoo.com> ;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2018 Rutger Helling <rhelling@mykolab.com> ;;; Copyright © 2018, 2019 Pierre Neidhardt <mail@ambrevar.xyz> ;;; ;;; 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 disk) #:use-module (gnu packages) #:use-module (gnu packages autotools) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages c) #:use-module (gnu packages check) #:use-module (gnu packages compression) #:use-module (gnu packages cryptsetup) #:use-module (gnu packages databases) #:use-module (gnu packages docbook) #:use-module (gnu packages documentation) #:use-module (gnu packages elf) #:use-module (gnu packages gettext) #:use-module (gnu packages glib) #:use-module (gnu packages gnome) #:use-module (gnu packages gnupg) #:use-module (gnu packages gnuzilla) #:use-module (gnu packages gtk) #:use-module (gnu packages guile) #:use-module (gnu packages linux) #:use-module (gnu packages ncurses) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) #:use-module (gnu packages popt) #:use-module (gnu packages python) #:use-module (gnu packages readline) #:use-module (gnu packages swig) #:use-module (gnu packages vim) #:use-module (gnu packages w3m) #:use-module (gnu packages web) #:use-module (gnu packages xml) #:use-module (guix build-system gnu) #:use-module (guix build-system python) #:use-module (guix build-system trivial) #:use-module (guix build-system scons) #:use-module (guix download) #:use-module (guix git-download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages)) (define-public parted (package (name "parted") (version "3.2") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/parted/parted-" version ".tar.xz")) (patches (search-patches "parted-glibc-compat.patch")) (sha256 (base32 "1r3qpg3bhz37mgvp9chsaa3k0csby3vayfvz8ggsqz194af5i2w5")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-after 'unpack 'fix-locales-and-python (lambda* (#:key inputs #:allow-other-keys) (substitute* "tests/t0251-gpt-unicode.sh" (("C.UTF-8") "en_US.utf8")) ;not in Glibc locales (substitute* "tests/msdos-overlap" (("/usr/bin/python") (which "python")))))))) (inputs `(("lvm2" ,lvm2) ("readline" ,readline) ("util-linux" ,util-linux))) (native-inputs `(("gettext" ,gettext-minimal) ;; For the tests. ("perl" ,perl) ("python" ,python-2))) (home-page "https://www.gnu.org/software/parted/") (synopsis "Disk partition editor") (description "GNU Parted is a package for creating and manipulating disk partition tables. It includes a library and command-line utility.") (license license:gpl3+))) (define-public fdisk (package (name "fdisk") (version "2.0.0a1") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/fdisk/gnufdisk-" version ".tar.gz")) (sha256 (base32 "1d8za79kw8ihnp2br084rgyjv9whkwp7957rzw815i0izx6xhqy9")))) (build-system gnu-build-system) (inputs `(("gettext" ,gettext-minimal) ("guile" ,guile-1.8) ("util-linux" ,util-linux) ("parted" ,parted))) ;; The build neglects to look for its own headers in its own tree. A next ;; release should fix this, but may never come: GNU fdisk looks abandoned. (arguments `(#:phases (modify-phases %standard-phases (add-after 'unpack 'skip-broken-header-probes (lambda _ (substitute* "backend/configure" (("gnufdisk-common.h .*") "\n")) #t))) #:make-flags (list (string-append "CPPFLAGS=" " -I../common/include " " -I../debug/include " " -I../exception/include")))) (home-page "https://www.gnu.org/software/fdisk/") (synopsis "Low-level disk partitioning and formatting") (description "GNU fdisk provides a GNU version of the common disk partitioning tool fdisk. fdisk is used for the creation and manipulation of disk partition tables, and it understands a variety of different formats.") (license license:gpl3+))) (define-public gptfdisk (package (name "gptfdisk") (version "1.0.4") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/gptfdisk/gptfdisk/" version "/" name "-" version ".tar.gz")) (sha256 (base32 "13d7gff4prl1nsdknjigmb7bbqhn79165n01v4y9mwbnd0d3jqxn")))) (build-system gnu-build-system) (inputs `(("gettext" ,gettext-minimal) ("ncurses" ,ncurses) ("popt" ,popt) ("util-linux" ,util-linux))) ; libuuid (arguments `(#:test-target "test" #:phases (modify-phases %standard-phases ;; no configure script (delete 'configure) ;; no install target (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin")) (man (string-append out "/share/man/man8"))) (install-file "gdisk" bin) (install-file "sgdisk" bin) (install-file "cgdisk" bin) (install-file "fixparts" bin) (install-file "cgdisk.8" man) (install-file "fixparts.8" man) (install-file "gdisk.8" man) (install-file "sgdisk.8" man))))))) (home-page "http://www.rodsbooks.com/gdisk/") (synopsis "Low-level GPT disk partitioning and formatting") (description "GPT fdisk (aka gdisk) is a text-mode partitioning tool that works on Globally Unique Identifier (@dfn{GUID}) Partition Table (@dfn{GPT}) disks, rather than on the older Master Boot Record (@dfn{MBR}) partition scheme.") (license license:gpl2))) (define-public ddrescue (package (name "ddrescue") (version "1.23") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/ddrescue/ddrescue-" version ".tar.lz")) (sha256 (base32 "13cd6c0x91zq10vdlyl6r5rib47bmsn5sshmkin3igwj8pa2vbm9")))) (build-system gnu-build-system) (home-page "https://www.gnu.org/software/ddrescue/ddrescue.html") (synopsis "Data recovery utility") (native-inputs `(("lzip" ,lzip))) (description "GNU ddrescue is a fully automated data recovery tool. It copies data from one file to another, working to rescue data in case of read errors. The program also includes a tool for manipulating its log files, which are used to recover data more efficiently by only reading the necessary blocks.") (license license:gpl3+))) (define-public dosfstools (package (name "dosfstools") (version "4.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/" name "/" name "/releases/download/v" version "/" name "-" version ".tar.xz")) (sha256 (base32 "0wy13i3i4x2bw1hf5m4fd0myh61f9bcrs035fdlf6gyc1jksrcp6")))) (build-system gnu-build-system) (arguments `(#:make-flags (list (string-append "PREFIX=" %output) "CC=gcc"))) (native-inputs `(("xxd" ,xxd))) ; for tests (home-page "https://github.com/dosfstools/dosfstools") (synopsis "Utilities for making and checking MS-DOS FAT file systems") (description "The dosfstools package includes the mkfs.fat and fsck.fat utilities, which respectively make and check MS-DOS FAT file systems.") (license license:gpl3+))) (define dosfstools/static (static-package (package (inherit dosfstools)))) (define-public fatfsck/static (package (name "fatfsck-static") (version (package-version dosfstools)) (build-system trivial-build-system) (source #f) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let ((src (string-append (assoc-ref %build-inputs "dosfstools") "/sbin")) (exe "fsck.fat") (bin (string-append (assoc-ref %outputs "out") "/sbin"))) (mkdir-p bin) (with-directory-excursion bin (copy-file (string-append src "/" exe) exe) (remove-store-references exe) (chmod exe #o555) ;; Add fsck.vfat symlink to match the Linux driver name. (symlink exe "fsck.vfat") #t))))) (inputs `(("dosfstools" ,dosfstools/static))) (home-page (package-home-page dosfstools)) (synopsis "Statically linked fsck.fat from dosfstools") (description "This package provides a statically-linked @command{fsck.fat} and a @command{fsck.vfat} compatibility symlink for use in an initrd.") (license (package-license dosfstools)))) (define-public sdparm (package (name "sdparm") (version "1.10") (source (origin (method url-fetch) (uri (string-append "http://sg.danny.cz/sg/p/" name "-" version ".tar.xz")) (sha256 (base32 "1jjq3lzgfy4r76rc26q02lv4wm5cb4dx5nh913h489zjrr4f3jbx")))) (build-system gnu-build-system) (home-page "http://sg.danny.cz/sg/sdparm.html") (synopsis "Provide access to SCSI device parameters") (description "Sdparm reads and modifies SCSI device parameters. These devices can be SCSI disks, in which case the role of @command{sdparm} is similar to its namesake: the @command{hdparm} utility originally designed for ATA disks. However, @command{sdparm} can be used to access parameters on any device that uses a SCSI command set. Such devices include CD/DVD drives (irrespective of transport), SCSI and ATAPI tape drives, and SCSI enclosures. This utility can also send commands associated with starting and stopping the media, loading and unloading removable media and some other housekeeping functions.") (license license:bsd-3))) (define-public idle3-tools (package (name "idle3-tools") (version "0.9.1") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/idle3-tools/idle3-tools-" version ".tgz")) (sha256 (base32 "00ia7xq9yldxyl9gz0mr4xa568nav14p0fnv82f2rbbkg060cy4p")))) (build-system gnu-build-system) (arguments `(#:tests? #f ;no test suite #:phases (modify-phases %standard-phases (delete 'configure)) #:make-flags (list "CC=gcc" (string-append "manprefix=") (string-append "DESTDIR=" (assoc-ref %outputs "out"))))) (home-page "http://idle3-tools.sourceforge.net") (synopsis "Change or disable Western Digital hard drives' Idle3 timer") (description "Idle3-tools provides a utility to get, set, or disable the Idle3 timer present in many Western Digital hard drives. This timer is part of the \"IntelliPark\" feature that stops the disk when not in use. Unfortunately, the default timer setting is not well suited to Linux or other *nix systems, and can dramatically shorten the lifespan of the drive if left unchecked.") (license license:gpl3+))) (define-public gparted (package (name "gparted") (version "0.32.0") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/gparted/gparted/gparted-" version "/gparted-" version ".tar.gz")) (sha256 (base32 "1fjp4c8jc0kjbbih1x1vs9v40d9lncma642kflnmy0bixxnvh7df")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; tests require a network connection #:configure-flags '("--disable-scrollkeeper"))) (inputs `(("util-linux" ,util-linux) ("parted" ,parted) ("glib" ,glib) ("gtkmm" ,gtkmm-2) ("libxml2" ,libxml2) ("libxslt" ,libxslt) ("gnome-doc-utils" ,gnome-doc-utils) ("docbook-xml" ,docbook-xml-4.2) ("python" ,python-2) ("python-libxml2" ,python2-libxml2) ("which" ,which))) (native-inputs `(("intltool" ,intltool) ("pkg-config" ,pkg-config))) (home-page "https://gparted.org/") (synopsis "Partition editor to graphically manage disk partitions") (description "GParted is a GNOME partition editor for creating, reorganizing, and deleting disk partitions. It uses libparted from the parted project to detect and manipulate partition tables. Optional file system tools permit managing file systems not included in libparted.") ;; The home page says GPLv2, but the source code says GPLv2+. (license license:gpl2+))) (define-public pydf (package (name "pydf") (version "12") (source (origin (method url-fetch) (uri (pypi-uri "pydf" version)) (sha256 (base32 "0f8ly8xyp93i2hm9c0qjqd4y86nz73axw2f09z01mszwmg1sfivz")))) (build-system python-build-system) (home-page "http://kassiopeia.juls.savba.sk/~garabik/software/pydf/") (synopsis "Colourised @command{df} clone") (description "All-singing, all-dancing, fully colourised @command{df} clone written in Python. It displays the amount of disk space available on the mounted file systems, using different colours for different types of file systems. Output format is completely customizable.") (license license:public-domain))) (define-public f3 (package (name "f3") (version "7.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/AltraMayor/f3.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0zglsmz683jg7f9wc6vmgljyg9w87pbnjw5x4w6x02w8233zvjqf")))) (build-system gnu-build-system) (arguments '(#:tests? #f ; no check target #:make-flags (list "CC=gcc" (string-append "PREFIX=" %output)) #:phases (modify-phases %standard-phases (delete 'configure) ; no configure script (add-after 'build 'build-extra (lambda* (#:key make-flags #:allow-other-keys) (apply invoke "make" "extra" make-flags))) (add-after 'build 'install-extra (lambda* (#:key make-flags #:allow-other-keys) (apply invoke "make" "install-extra" make-flags)))))) (inputs `(("eudev" ,eudev) ("parted" ,parted))) (home-page "http://oss.digirati.com.br/f3/") (synopsis "Test real capacity of flash memory cards and such.") (description "F3 (Fight Flash Fraud or Fight Fake Flash) tests the full capacity of a flash card (flash drive, flash disk, pendrive). F3 writes to the card and then checks if can read it. It will assure you haven't been sold a card with a smaller capacity than stated.") (license license:gpl3+))) (define-public python-parted (package (name "python-parted") (version "3.11.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/dcantrell/pyparted/archive/v" version ".tar.gz")) (sha256 (base32 "0r1nyjj40nacnfnv17x2mnsj6ga1qplyxyza82v2809dfhim2fwq")))) (build-system python-build-system) (arguments `(#:phases (modify-phases %standard-phases (delete 'check) (add-after 'install 'check (lambda* (#:key outputs inputs #:allow-other-keys) (add-installed-pythonpath inputs outputs) ;; See <https://github.com/dcantrell/pyparted/issues/47>. (substitute* "tests/test__ped_ped.py" (("\"/tmp/temp-device-\"") "self.path")) (invoke "python" "-m" "unittest" "discover" "-v") #t))))) (native-inputs `(("e2fsprogs" ,e2fsprogs) ("pkg-config" ,pkg-config))) (propagated-inputs `(("python-six" ,python-six))) (inputs `(("parted" ,parted))) (home-page "https://github.com/dcantrell/pyparted") (synopsis "Parted bindings for Python") (description "This package provides @code{parted} bindings for Python.") (license license:gpl2+))) (define-public python2-parted (package-with-python2 python-parted)) (define-public duperemove (package (name "duperemove") (version "0.11") (source (origin (method url-fetch) (uri (string-append "https://github.com/markfasheh/duperemove/archive/v" version ".tar.gz")) (sha256 (base32 "0rjmmh42yqw9a5j6sp31cqwxk3s97dsi4xz0wpxpllj7bsp3aiw5")) (file-name (string-append name "-" version ".tar.gz")))) (build-system gnu-build-system) (native-inputs `(("pkg-config" ,pkg-config))) (inputs `(("glib" ,glib) ("sqlite" ,sqlite))) (arguments `(#:tests? #f ; no test suite #:phases (modify-phases %standard-phases (delete 'configure)) ; no configure script #:make-flags (list (string-append "PREFIX=" %output) "CC=gcc"))) (home-page "https://github.com/markfasheh/duperemove") (synopsis "Tools for de-duplicating file system data") (description "Duperemove is a simple tool for finding duplicated extents and submitting them for deduplication. When given a list of files it will hash their contents on a block by block basis and compare those hashes to each other, finding and categorizing blocks that match each other. When given the @option{-d} option, duperemove will submit those extents for deduplication using the Linux kernel extent-same @code{ioctl}. Duperemove can store the hashes it computes in a @dfn{hash file}. If given an existing hash file, duperemove will only compute hashes for those files which have changed since the last run. Thus you can run duperemove repeatedly on your data as it changes, without having to re-checksum unchanged data. Duperemove can also take input from the @command{fdupes} program.") (license license:gpl2))) (define-public ranger (package (name "ranger") (version "1.9.2") (source (origin (method url-fetch) (uri (string-append "https://ranger.github.io/" "ranger-" version ".tar.gz")) (sha256 (base32 "12kbsqakbxs09y0x8hy66mmaf72rk0p850x7ryk2ghkq7wfin78f")))) (build-system python-build-system) (inputs `(("w3m" ,w3m))) (native-inputs `(("which" ,which) ;; For tests. ("python-pytest" ,python-pytest))) (arguments '( ;; The 'test' target runs developer tools like pylint, which fail. #:test-target "test_pytest" #:phases (modify-phases %standard-phases (add-after 'configure 'wrap-program ;; Tell 'ranger' where 'w3mimgdisplay' is. (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (ranger (string-append out "/bin/ranger")) (w3m (assoc-ref inputs "w3m")) (w3mimgdisplay (string-append w3m "/libexec/w3m/w3mimgdisplay"))) (wrap-program ranger `("W3MIMGDISPLAY_PATH" ":" prefix (,w3mimgdisplay))) #t))) (replace 'check ;; The default check phase simply prints 'Ran 0 tests in 0.000s'. (lambda* (#:key test-target #:allow-other-keys) (invoke "make" test-target)))))) (home-page "https://ranger.github.io/") (synopsis "Console file manager") (description "ranger is a console file manager with Vi key bindings. It provides a minimalistic and nice curses interface with a view on the directory hierarchy. It ships with @code{rifle}, a file launcher that is good at automatically finding out which program to use for what file type.") (license license:gpl3))) (define-public volume-key (package (name "volume-key") (version "0.3.12") (source (origin (method url-fetch) (uri (string-append "https://releases.pagure.org/volume_key/volume_key-" version ".tar.xz")) (sha256 (base32 "16rhfz6sjwxlmss1plb2wv2i3jq6wza02rmz1d2jrlnsq67p98vc")))) (build-system gnu-build-system) (native-inputs `(("pkg-config" ,pkg-config) ("util-linux" ,util-linux) ("swig" ,swig) ("python" ,python-3))) ; used to generate the Python bindings (inputs `(("cryptsetup" ,cryptsetup) ("nss" ,nss) ("lvm2" ,lvm2) ; for "-ldevmapper" ("glib" ,glib) ("gpgme" ,gpgme))) (arguments `(#:tests? #f ; not sure how tests are supposed to pass, even when run manually #:phases (modify-phases %standard-phases (add-before 'configure 'patch-python.h-path (lambda* (#:key inputs #:allow-other-keys) (let ((python (assoc-ref inputs "python"))) (substitute* "Makefile.in" (("/usr/include/python") (string-append python "/include/python"))) #t)))))) (home-page "https://pagure.io/volume_key") (synopsis "Manipulate storage volume encryption keys") (description "This package provides a library for manipulating storage volume encryption keys and storing them separately from volumes to handle forgotten passphrases.") (license license:gpl2))) (define-public ndctl (package (name "ndctl") (version "63") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/pmem/ndctl.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "060nsza8xic769bxj3pvl70a9885bwrc0myw16l095i3z6w7yzwq")))) (build-system gnu-build-system) (native-inputs `(("asciidoc" ,asciidoc) ("automake" ,automake) ("autoconf" ,autoconf) ("bash-completion" ,bash-completion) ("docbook-xsl" ,docbook-xsl) ("libtool" ,libtool) ("libxml2" ,libxml2) ("pkg-config" ,pkg-config) ("xmlto" ,xmlto) ;; Required for offline docbook generation. ("which" ,which))) (inputs `(("eudev" ,eudev) ("json-c" ,json-c) ("kmod" ,kmod) ("util-linux" ,util-linux))) (arguments `(#:configure-flags (list "--disable-asciidoctor" ; use docbook-xsl instead "--without-systemd") #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-FHS-file-names (lambda _ (substitute* "git-version-gen" (("/bin/sh") (which "sh"))) (substitute* "git-version" (("/bin/bash") (which "bash"))) #t))) #:make-flags (let ((out (assoc-ref %outputs "out"))) (list (string-append "BASH_COMPLETION_DIR=" out "/share/bash-completion/completions"))))) (home-page "https://github.com/pmem/ndctl") (synopsis "Manage the non-volatile memory device sub-system in the Linux kernel") (description "This package provides a utility library for managing the libnvdimm (non-volatile memory device) sub-system in the Linux kernel.") ;; COPYING says LGPL2.1, but many source files are GPL2 so that's ;; the effective license. Note that some files under ccan/ are ;; covered by BSD-3 or public domain, see the individual folders. (license license:gpl2))) (define-public dmraid (package (name "dmraid") (version "1.0.0.rc16-3") (source (origin (method url-fetch) (uri (string-append "https://people.redhat.com/~heinzm/sw/dmraid/src/dmraid-" version ".tar.bz2")) (sha256 (base32 "1n7vsqvh7y6yvil682q129d21yhb0cmvd5fvsbkza7ypd78inhlk")))) (build-system gnu-build-system) (inputs `(("lvm2" ,lvm2))) (native-inputs `(("which" ,which))) (arguments `(#:tests? #f ; No tests. ;; Prevent a race condition where some target would attempt to link ;; libdmraid.so before it had been built as reported in ;; <https://bugs.gnu.org/31999#187>. #:parallel-build? #f #:phases (modify-phases %standard-phases (add-before 'configure 'change-directory (lambda _ (chdir (string-append ,version "/dmraid")) (substitute* "make.tmpl.in" (("/bin/sh") (which "sh"))) #t))) #:configure-flags (list ;; Make sure programs such as 'dmevent_tool' can ;; find libdmraid.so. (string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out") "/lib")))) (home-page "https://people.redhat.com/~heinzm/sw/dmraid/") (synopsis "Device mapper RAID interface") (description "This software supports RAID device discovery, RAID set activation, creation, removal, rebuild and display of properties for ATARAID/DDF1 metadata. @command{dmraid} uses @file{libdevmapper} and the device-mapper kernel runtime to create devices with respective mappings for the ATARAID sets discovered.") (license license:gpl2+))) (define-public libblockdev (package (name "libblockdev") (version "2.20") (source (origin (method url-fetch) (uri (string-append "https://github.com/storaged-project/" "libblockdev/releases/download/" version "-1/libblockdev-" version ".tar.gz")) (sha256 (base32 "092snk5jyv48na4d46v1ckiy859zwpb3r0ivnxv3km5vzsp76y7q")))) (build-system gnu-build-system) (native-inputs `(("pkg-config" ,pkg-config) ("python" ,python-wrapper) ("util-linux" ,util-linux))) (inputs `(("btrfs-progs" ,btrfs-progs) ("cryptsetup" ,cryptsetup) ("dosfstools" ,dosfstools) ("dmraid" ,dmraid) ("eudev" ,eudev) ("glib" ,glib) ("gobject-introspection" ,gobject-introspection) ("kmod" ,kmod) ("libbytesize" ,libbytesize) ("libyaml" ,libyaml) ("lvm2" ,lvm2) ("mdadm" ,mdadm) ("ndctl" ,ndctl) ("nss" ,nss) ("parted" ,parted) ("volume-key" ,volume-key) ;; ("xfsprogs" ,xfsprogs) ; TODO: Package? )) (home-page "https://github.com/storaged-project/libblockdev") (synopsis "Library for manipulating block devices") (description "libblockdev is a C library supporting GObject introspection for manipulation of block devices. It has a plugin-based architecture where each technology (like LVM, Btrfs, MD RAID, Swap...) is implemented in a separate plugin, possibly with multiple implementations (e.g. using LVM CLI or the new LVM D-Bus API).") (license license:lgpl2.1+))) (define-public rmlint (package (name "rmlint") (version "2.8.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/sahib/rmlint") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1gc7gbnh0qg1kl151cv1ld87vhpm1v3pnkn7prhscdcc21jrg8nz")))) (build-system scons-build-system) (arguments `(#:scons ,scons-python2 #:scons-flags (list (string-append "--prefix=" %output) (string-append "--actual-prefix=" %output)) #:tests? #f ; No tests? #:phases (modify-phases %standard-phases (add-after 'unpack 'scons-propagate-environment (lambda* (#:key inputs #:allow-other-keys) ;; TODO: `rmlint --gui` fails with ;; "Failed to load shredder: No module named 'shredder'". ;; The GUI might also need extra dependencies, such as ;; python-gobject, python-cairo, dconf, librsvg, gtksourceview3. (substitute* "lib/cmdline.c" (("const char \\*commands\\[\\] = \\{\"python3\", \"python\", NULL\\};") (string-append "const char *commands[] = {\"" (assoc-ref inputs "python") "/bin/python" "\", \"python\", NULL};"))) ;; By design, SCons does not, by default, propagate ;; environment variables to subprocesses. See: ;; <http://comments.gmane.org/gmane.linux.distributions.nixos/4969> ;; Here, we modify the SConstruct file to arrange for ;; environment variables to be propagated. (substitute* "SConstruct" (("^env = Environment\\(.*\\)" all) (string-append all "\nenv['ENV']=os.environ")))))))) (native-inputs `(("pkg-config" ,pkg-config) ("glib:bin" ,glib "bin") ("python-sphinx" ,python-sphinx))) (inputs `(("python" ,python-wrapper) ("glib" ,glib) ("libelf" ,libelf) ("elfutils" ,elfutils) ("json-glib" ,json-glib) ("libblkid" ,util-linux))) (home-page "https://rmlint.rtfd.org") (synopsis "Remove duplicates and other lint from the filesystem") (description "@command{rmlint} finds space waste and other broken things on your filesystem and offers to remove it. @command{rmlint} can find: @itemize @item duplicate files and duplicate directories, @item non-stripped binaries (i.e. binaries with debug symbols), @item broken symbolic links, @item empty files and directories, @item files with broken user and/or group ID. @end itemize\n") (license license:gpl3+)))