diff options
author | tv <tv@krebsco.de> | 2021-02-05 17:43:24 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2021-02-05 17:46:45 +0100 |
commit | bbbd3d6cd89cc797fab9245decca62e05eb994b7 (patch) | |
tree | d71bbcd20ad9d5b96da5c82dd9d5249c5376557d /krebs/3modules | |
parent | 9c2d517c498e1ea2fa27366d19dc01856fa136ee (diff) |
krebs.setuid: disambiguate `config`
Diffstat (limited to 'krebs/3modules')
-rw-r--r-- | krebs/3modules/setuid.nix | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/krebs/3modules/setuid.nix b/krebs/3modules/setuid.nix index 97cf21cdd..3e068736b 100644 --- a/krebs/3modules/setuid.nix +++ b/krebs/3modules/setuid.nix @@ -1,11 +1,9 @@ -{ config, pkgs, lib, ... }: with import <stockholm/lib>; -let - cfg = config.krebs.setuid; +{ config, pkgs, ... }: let out = { options.krebs.setuid = api; - config = mkIf (cfg != {}) imp; + config = mkIf (config.krebs.setuid != {}) imp; }; api = mkOption { @@ -14,11 +12,11 @@ let # TODO make wrapperDir configurable inherit (config.security) wrapperDir; inherit (config.users) groups users; - in types.attrsOf (types.submodule ({ config, ... }: { + in types.attrsOf (types.submodule (self: let cfg = self.config; in { options = { name = mkOption { type = types.filename; - default = config._module.args.name; + default = cfg._module.args.name; }; envp = mkOption { type = types.nullOr (types.attrsOf types.str); @@ -58,21 +56,21 @@ let }; }; config.activate = let - src = pkgs.exec config.name { - inherit (config) envp filename; + src = pkgs.exec cfg.name { + inherit (cfg) envp filename; }; - dst = "${wrapperDir}/${config.name}"; + dst = "${wrapperDir}/${cfg.name}"; in '' cp ${src} ${dst} - chown ${config.owner}.${config.group} ${dst} - chmod ${config.mode} ${dst} + chown ${cfg.owner}.${cfg.group} ${dst} + chmod ${cfg.mode} ${dst} ''; })); }; imp = { system.activationScripts."krebs.setuid" = stringAfter [ "wrappers" ] - (concatMapStringsSep "\n" (getAttr "activate") (attrValues cfg)); + (concatMapStringsSep "\n" (getAttr "activate") (attrValues config.krebs.setuid)); }; in out |