summaryrefslogtreecommitdiffstats
path: root/modules/userSecret.nix
blob: 02502a2b36321af13db156c00669a4210706c9cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# "secret" consumer
{ config, lib, ... }:
let
  topConfig = config;
in
{
  options.users.users = lib.mkOption {
    type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
      options.passwordSecret = lib.mkOption {
        type = lib.types.nullOr topConfig.contracts.secret.consumer;
      };
      config = {
        hashedPasswordFile =
          lib.mkIf (config.passwordSecret.provider != null)
            config.passwordSecret.output.path;

        passwordSecret.input =
          lib.mkIf (config.passwordSecret.provider != null) {
            owner = "root";
            group = "root";
            mode = "0400";
          };
      };
    }));
  };
}