about summary refs log tree commit diff
path: root/tools/hash-password.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hash-password.nix')
-rw-r--r--tools/hash-password.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/hash-password.nix b/tools/hash-password.nix
new file mode 100644
index 0000000000..6192436c17
--- /dev/null
+++ b/tools/hash-password.nix
@@ -0,0 +1,15 @@
+# Utility for invoking slappasswd with the correct options for
+# creating an ARGON2 password hash.
+{ pkgs, ... }:
+
+let
+  script = pkgs.writeShellScriptBin "hash-password" ''
+    ${pkgs.openldap}/bin/slappasswd -o module-load=argon2 -h '{ARGON2}' "$@"
+  '';
+in
+script.overrideAttrs (old: {
+  doCheck = true;
+  checkPhase = ''
+    ${pkgs.stdenv.shell} $out/bin/hash-password -s example-password > /dev/null
+  '';
+})