| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 |
|
| 24 | (define-module (gnu packages cryptsetup)
|
| 25 | #:use-module ((guix licenses) #:prefix license:)
|
| 26 | #:use-module (guix packages)
|
| 27 | #:use-module (guix download)
|
| 28 | #:use-module (guix build-system cmake)
|
| 29 | #:use-module (guix build-system gnu)
|
| 30 | #:use-module (guix gexp)
|
| 31 | #:use-module (guix utils)
|
| 32 | #:use-module (gnu packages)
|
| 33 | #:use-module (gnu packages gnupg)
|
| 34 | #:use-module (gnu packages password-utils)
|
| 35 | #:use-module (gnu packages pkg-config)
|
| 36 | #:use-module (gnu packages popt)
|
| 37 | #:use-module (gnu packages linux)
|
| 38 | #:use-module (gnu packages ruby-xyz)
|
| 39 | #:use-module (gnu packages web))
|
| 40 |
|
| 41 | (define-public cryptsetup-minimal
|
| 42 | (package
|
| 43 | (name "cryptsetup-minimal")
|
| 44 | (version "2.8.4")
|
| 45 | (source (origin
|
| 46 | (method url-fetch)
|
| 47 | (uri (string-append "mirror://kernel.org/linux/utils/cryptsetup/v"
|
| 48 | (version-major+minor version)
|
| 49 | "/cryptsetup-" version ".tar.xz"))
|
| 50 | (sha256
|
| 51 | (base32
|
| 52 | "10wa3vx0dx04kv2wy165gvnyi81swawgnnj51xwcr6jcjvw4cgj4"))))
|
| 53 | (build-system gnu-build-system)
|
| 54 | (arguments
|
| 55 | `(#:configure-flags
|
| 56 | (append
|
| 57 | (if (assoc-ref %build-inputs "ruby-asciidoctor")
|
| 58 | '()
|
| 59 | (list "--disable-asciidoc"))
|
| 60 | (list
|
| 61 | |
| 62 | "--enable-libargon2"
|
| 63 | |
| 64 | "--with-crypto_backend=gcrypt"
|
| 65 | |
| 66 | "--with-default-luks-format=LUKS1"
|
| 67 | |
| 68 | |
| 69 | "--disable-external-tokens"
|
| 70 | "--disable-ssh-token"
|
| 71 | |
| 72 | |
| 73 | (string-append "--with-libgcrypt-prefix="
|
| 74 | (assoc-ref %build-inputs "libgcrypt"))))))
|
| 75 | (native-inputs
|
| 76 | (list pkg-config))
|
| 77 | (inputs
|
| 78 | (list argon2
|
| 79 | json-c
|
| 80 | libgcrypt
|
| 81 | lvm2 |
| 82 | popt
|
| 83 | `(,util-linux "lib"))) |
| 84 | (synopsis "Set up transparent encryption of block devices using dm-crypt")
|
| 85 | (description
|
| 86 | "Cryptsetup is a utility used to conveniently set up disk encryption based
|
| 87 | on the @code{dm-crypt} Linux kernel module. It is most often used to manage
|
| 88 | LUKS volumes but also supports plain dm-crypt volumes and loop-AES, TrueCrypt
|
| 89 | (including VeraCrypt extension), and BitLocker formats.
|
| 90 |
|
| 91 | @acronym{LUKS, Linux Unified Key Setup} is the standard for hard disk encryption
|
| 92 | with the kernel Linux. It provides a standard on-disk-format compatible amongst
|
| 93 | distributions as well as secure management of multiple user passwords. LUKS
|
| 94 | stores all necessary setup information in the partition header to facilitate
|
| 95 | data transport and migration.
|
| 96 |
|
| 97 | The package also includes the @command{veritysetup} and @command{integritysetup}
|
| 98 | utilities to conveniently configure the @code{dm-verity} and @code{dm-integrity}
|
| 99 | block integrity kernel modules.")
|
| 100 | (license license:gpl2)
|
| 101 | (home-page "https://gitlab.com/cryptsetup/cryptsetup")))
|
| 102 |
|
| 103 | (define-public cryptsetup
|
| 104 | (package/inherit cryptsetup-minimal
|
| 105 | (name "cryptsetup")
|
| 106 | (native-inputs `(,(if (supported-package? ruby-asciidoctor/minimal)
|
| 107 | `("ruby-asciidoctor" ,ruby-asciidoctor/minimal)
|
| 108 | '())
|
| 109 | ,@(package-native-inputs cryptsetup-minimal)))))
|
| 110 |
|
| 111 | (define-public (libcryptsetup-propagated-inputs)
|
| 112 | (list argon2
|
| 113 | json-c
|
| 114 | libgcrypt
|
| 115 | lvm2
|
| 116 | `(,util-linux "lib")))
|
| 117 |
|
| 118 | (define (static-library library)
|
| 119 | "Return a variant of package LIBRARY that provides static libraries ('.a'
|
| 120 | files). This assumes LIBRARY uses Libtool."
|
| 121 | (package
|
| 122 | (inherit library)
|
| 123 | (name (string-append (package-name library) "-static"))
|
| 124 | (arguments
|
| 125 | (substitute-keyword-arguments arguments
|
| 126 | ((#:configure-flags flags #~'())
|
| 127 | (let* ((build-system (package-build-system library))
|
| 128 | (static-flags (cond ((eq? build-system cmake-build-system)
|
| 129 | '("-DBUILD_SHARED_LIBS=OFF"))
|
| 130 | (else
|
| 131 | '("--disable-shared" "--enable-static")))))
|
| 132 | #~(append '#$static-flags
|
| 133 | #$flags)))))))
|
| 134 |
|
| 135 | (define-public cryptsetup-static
|
| 136 | |
| 137 | (package
|
| 138 | (inherit cryptsetup-minimal)
|
| 139 | (name "cryptsetup-static")
|
| 140 | (arguments
|
| 141 | (substitute-keyword-arguments arguments
|
| 142 | ((#:configure-flags flags ''())
|
| 143 | `(cons* "--disable-shared"
|
| 144 | "--enable-static-cryptsetup"
|
| 145 |
|
| 146 | "--disable-veritysetup"
|
| 147 | "--disable-integritysetup"
|
| 148 | |
| 149 | |
| 150 | |
| 151 | (format #f "BLKID_CFLAGS=-I~a"
|
| 152 | (search-input-directory %build-inputs "include/blkid"))
|
| 153 | (format #f "BLKID_LIBS=-L~a -lblkid"
|
| 154 | (dirname (search-input-file %build-inputs "lib/libblkid.a")))
|
| 155 | ,flags))
|
| 156 | ((#:allowed-references refs '())
|
| 157 | '())
|
| 158 | ((#:modules modules '())
|
| 159 | '((ice-9 ftw)
|
| 160 | (ice-9 match)
|
| 161 | (guix build utils)
|
| 162 | (guix build gnu-build-system)))
|
| 163 | ((#:phases phases #~%standard-phases)
|
| 164 | #~(modify-phases #$phases
|
| 165 | (add-after 'install 'remove-cruft
|
| 166 | (lambda* (#:key outputs #:allow-other-keys)
|
| 167 | |
| 168 | (let ((out (assoc-ref outputs "out")))
|
| 169 | (with-directory-excursion out
|
| 170 | (let ((dirs (scandir "."
|
| 171 | (match-lambda
|
| 172 | ((or "." "..") #f)
|
| 173 | (_ #t)))))
|
| 174 | (for-each delete-file-recursively
|
| 175 | (delete "sbin" dirs))
|
| 176 | (for-each (lambda (file)
|
| 177 | (rename-file (string-append file
|
| 178 | ".static")
|
| 179 | file)
|
| 180 | (remove-store-references file))
|
| 181 | '("sbin/cryptsetup"))
|
| 182 | #t)))))))))
|
| 183 | (inputs
|
| 184 | (let ((libgcrypt-static
|
| 185 | (package
|
| 186 | (inherit (static-library libgcrypt))
|
| 187 | (propagated-inputs
|
| 188 | `(("libgpg-error-host" ,(static-library libgpg-error)))))))
|
| 189 | `(("argon2" ,(static-library argon2))
|
| 190 | ("json-c" ,(static-library json-c))
|
| 191 | ("libgcrypt" ,libgcrypt-static)
|
| 192 | ("lvm2" ,lvm2-static)
|
| 193 | ("util-linux" ,util-linux "static")
|
| 194 | ("util-linux" ,util-linux "lib")
|
| 195 | ("popt" ,(static-library popt)))))
|
| 196 | (synopsis "Hard disk encryption tool (statically linked)")))
|