gap: ship Makefile.gappkg for future gap package use (#380430)
[NixPkgs.git] / pkgs / by-name / cr / cryptsetup / package.nix
blob8c35acda3e72a83e305c075ad5e8ff1dbacbfd56
2   lib,
3   stdenv,
4   fetchurl,
5   lvm2,
6   json_c,
7   asciidoctor,
8   openssl,
9   libuuid,
10   pkg-config,
11   popt,
12   nixosTests,
13   libargon2,
14   withInternalArgon2 ? false,
16   # Programs enabled by default upstream are implicitly enabled unless
17   # manually set to false.
18   programs ? { },
19   # The release tarballs contain precomputed manpage files, so we don't need
20   # to run asciidoctor on the man sources. By avoiding asciidoctor, we make
21   # the bare NixOS build hash independent of changes to the ruby ecosystem,
22   # saving mass-rebuilds.
23   rebuildMan ? false,
26 stdenv.mkDerivation rec {
27   pname = "cryptsetup";
28   version = "2.7.5";
30   outputs = [
31     "bin"
32     "out"
33     "dev"
34     "man"
35   ];
36   separateDebugInfo = true;
38   src = fetchurl {
39     url = "mirror://kernel/linux/utils/cryptsetup/v${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
40     hash = "sha256-0r5Dlbj1A7Dr9LLYHbkMNalwUKNY7iH+YqDftm5dVSI=";
41   };
43   patches = [
44     # Allow reading tokens from a relative path, see #167994
45     ./relative-token-path.patch
46   ];
48   postPatch = ''
49     patchShebangs tests
51     # O_DIRECT is filesystem dependent and fails in a sandbox (on tmpfs)
52     # and on several filesystem types (btrfs, zfs) without sandboxing.
53     # Remove it, see discussion in #46151
54     substituteInPlace tests/unit-utils-io.c --replace "| O_DIRECT" ""
55   '';
57   NIX_LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s";
59   configureFlags =
60     [
61       "--with-crypto_backend=openssl"
62       "--disable-ssh-token"
63     ]
64     ++ lib.optionals (!rebuildMan) [
65       "--disable-asciidoc"
66     ]
67     ++ lib.optionals (!withInternalArgon2) [
68       "--enable-libargon2"
69     ]
70     ++ lib.optionals stdenv.hostPlatform.isStatic [
71       "--disable-external-tokens"
72       # We have to override this even though we're removing token
73       # support, because the path still gets included in the binary even
74       # though it isn't used.
75       "--with-luks2-external-tokens-path=/"
76     ]
77     ++ (lib.mapAttrsToList (lib.flip lib.enableFeature)) programs;
79   nativeBuildInputs = [ pkg-config ] ++ lib.optionals rebuildMan [ asciidoctor ];
80   buildInputs = [
81     lvm2
82     json_c
83     openssl
84     libuuid
85     popt
86   ] ++ lib.optional (!withInternalArgon2) libargon2;
88   # The test [7] header backup in compat-test fails with a mysterious
89   # "out of memory" error, even though tons of memory is available.
90   # Issue filed upstream: https://gitlab.com/cryptsetup/cryptsetup/-/issues/763
91   doCheck = !stdenv.hostPlatform.isMusl;
93   passthru = {
94     tests = {
95       nixos = lib.optionalAttrs stdenv.hostPlatform.isLinux (
96         lib.recurseIntoAttrs (
97           lib.filterAttrs (name: _value: lib.hasPrefix "luks" name) nixosTests.installer
98         )
99       );
100     };
101   };
103   meta = {
104     homepage = "https://gitlab.com/cryptsetup/cryptsetup/";
105     description = "LUKS for dm-crypt";
106     changelog = "https://gitlab.com/cryptsetup/cryptsetup/-/raw/v${version}/docs/v${version}-ReleaseNotes";
107     license = lib.licenses.gpl2Plus;
108     mainProgram = "cryptsetup";
109     maintainers = with lib.maintainers; [ raitobezarius ];
110     platforms = with lib.platforms; linux;
111   };