1 { config, lib, pkgs, ... }:
3 # NOTE for now nothing is installed into /etc/bee-clef/. the config files are used as read-only from the nix store.
7 cfg = config.services.bee-clef;
10 maintainers = with maintainers; [ attila-lendvai ];
17 enable = mkEnableOption (lib.mdDoc "clef external signer instance for Ethereum Swarm Bee");
20 type = types.nullOr types.str;
21 default = "/var/lib/bee-clef";
22 description = lib.mdDoc ''
23 Data dir for bee-clef. Beware that some helper scripts may not work when changed!
24 The service itself should work fine, though.
28 passwordFile = mkOption {
29 type = types.nullOr types.str;
30 default = "/var/lib/bee-clef/password";
31 description = lib.mdDoc "Password file for bee-clef.";
37 description = lib.mdDoc ''
38 User the bee-clef daemon should execute under.
45 description = lib.mdDoc ''
46 Group the bee-clef daemon should execute under.
54 config = mkIf cfg.enable {
55 # if we ever want to have rules.js under /etc/bee-clef/
56 # environment.etc."bee-clef/rules.js".source = ${pkgs.bee-clef}/rules.js
58 systemd.packages = [ pkgs.bee-clef ]; # include the upstream bee-clef.service file
60 systemd.tmpfiles.rules = [
61 "d '${cfg.dataDir}/' 0750 ${cfg.user} ${cfg.group}"
62 "d '${cfg.dataDir}/keystore' 0700 ${cfg.user} ${cfg.group}"
65 systemd.services.bee-clef = {
67 # these are needed for the ensure-clef-account script
73 wantedBy = [ "bee.service" "multi-user.target" ];
78 ExecStartPre = ''${pkgs.bee-clef}/share/bee-clef/ensure-clef-account "${cfg.dataDir}" "${pkgs.bee-clef}/share/bee-clef/"'';
80 "" # this hides/overrides what's in the original entry
81 "${pkgs.bee-clef}/share/bee-clef/bee-clef-service start"
84 "" # this hides/overrides what's in the original entry
85 "${pkgs.bee-clef}/share/bee-clef/bee-clef-service stop"
88 "CONFIGDIR=${cfg.dataDir}"
89 "PASSWORD_FILE=${cfg.passwordFile}"
94 users.users = optionalAttrs (cfg.user == "bee-clef") {
99 description = "Daemon user for the bee-clef service";
103 users.groups = optionalAttrs (cfg.group == "bee-clef") {