NixOS configuration for HPC cluster https://docs.hpc.informatik.hs-fulda.de/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.1 KiB

  1. { pkgs, lib, config, ... }:
  2. with lib;
  3. let
  4. ca = pkgs.stdenv.mkDerivation {
  5. name = "hpc-ca";
  6. nativeBuildInputs = [ pkgs.minica ];
  7. phases = [ "buildPhase" "installPhase" ];
  8. buildPhase = ''
  9. minica \
  10. -ca-key ca.key.pem \
  11. -ca-cert ca.cert.pem \
  12. -domains "ca.${config.networking.domain}"
  13. '';
  14. installPhase = ''
  15. mkdir -p $out
  16. mv ca.key.pem $out/
  17. mv ca.cert.pem $out/
  18. '';
  19. };
  20. ca-cert = pkgs.runCommandNoCCLocal "hpc-ca.cert" { } ''
  21. cp "${ca}/ca.cert.pem" $out
  22. '';
  23. mkCert = domain: pkgs.stdenv.mkDerivation {
  24. name = "hpc-ca:${domain}";
  25. nativeBuildInputs = [ pkgs.minica ];
  26. phases = [ "buildPhase" "installPhase" ];
  27. buildPhase = ''
  28. minica \
  29. -ca-key "${ca}/ca.key.pem" \
  30. -ca-cert "${ca}/ca.cert.pem" \
  31. -domains "${domain}"
  32. '';
  33. installPhase = ''
  34. mkdir -p $out
  35. mv "${domain}/key.pem" $out/
  36. mv "${domain}/cert.pem" $out/
  37. ln -s "${ca}/ca.cert.pem" $out/ca.pem
  38. '';
  39. };
  40. in
  41. {
  42. security.pki.certificateFiles = [
  43. ca-cert
  44. ];
  45. _module.args = {
  46. inherit mkCert;
  47. };
  48. }