14 withInternalArgon2 ? false,
16 # Programs enabled by default upstream are implicitly enabled unless
17 # manually set to false.
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.
26 stdenv.mkDerivation rec {
36 separateDebugInfo = true;
39 url = "mirror://kernel/linux/utils/cryptsetup/v${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
40 hash = "sha256-0r5Dlbj1A7Dr9LLYHbkMNalwUKNY7iH+YqDftm5dVSI=";
44 # Allow reading tokens from a relative path, see #167994
45 ./relative-token-path.patch
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" ""
57 NIX_LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s";
61 "--with-crypto_backend=openssl"
64 ++ lib.optionals (!rebuildMan) [
67 ++ lib.optionals (!withInternalArgon2) [
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=/"
77 ++ (lib.mapAttrsToList (lib.flip lib.enableFeature)) programs;
79 nativeBuildInputs = [ pkg-config ] ++ lib.optionals rebuildMan [ asciidoctor ];
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;
95 nixos = lib.optionalAttrs stdenv.hostPlatform.isLinux (
96 lib.recurseIntoAttrs (
97 lib.filterAttrs (name: _value: lib.hasPrefix "luks" name) nixosTests.installer
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;