8 cfg = config.programs.benchexec;
9 opt = options.programs.benchexec;
12 if builtins.isString x then config.users.users ? ${x} else
13 if builtins.isInt x then x else
14 throw "filterUsers expects string (username) or int (UID)";
17 if builtins.isString x then config.users.users.${x}.uid else
18 if builtins.isInt x then x else
19 throw "uid expects string (username) or int (UID)";
22 options.programs.benchexec = {
23 enable = lib.mkEnableOption "BenchExec";
24 package = lib.options.mkPackageOption pkgs "benchexec" { };
26 users = lib.options.mkOption {
27 type = with lib.types; listOf (either str int);
29 Users that intend to use BenchExec.
30 Provide usernames of users that are configured via {option}`${options.users.users}` as string,
31 and UIDs of "mutable users" as integers.
32 Control group delegation will be configured via systemd.
33 For more information, see <https://github.com/sosy-lab/benchexec/blob/3.18/doc/INSTALL.md#setting-up-cgroups>.
36 example = lib.literalExpression ''
38 "alice" # username of a user configured via ${options.users.users}
39 1007 # UID of a mutable user
45 config = lib.mkIf cfg.enable {
48 assertion = config.users.users ? ${user};
50 The user '${user}' intends to use BenchExec (via `${opt.users}`), but is not configured via `${options.users.users}`.
53 (builtins.filter builtins.isString cfg.users)
56 assertion = config.users.mutableUsers;
58 The user with UID '${id}' intends to use BenchExec (via `${opt.users}`), but mutable users are disabled via `${options.users.mutableUsers}`.
61 (builtins.filter builtins.isInt cfg.users)
64 environment.systemPackages = [ cfg.package ];
66 # See <https://github.com/sosy-lab/benchexec/blob/3.18/doc/INSTALL.md#setting-up-cgroups>.
67 systemd.services = builtins.listToAttrs (map
69 name = "user@${builtins.toString (uid user)}";
71 serviceConfig.Delegate = "yes";
72 overrideStrategy = "asDropin";
75 (builtins.filter filterUsers cfg.users));
77 # See <https://github.com/sosy-lab/benchexec/blob/3.18/doc/INSTALL.md#requirements>.
78 virtualisation.lxc.lxcfs.enable = lib.mkDefault true;
80 # See <https://github.com/sosy-lab/benchexec/blob/3.18/doc/INSTALL.md#requirements>.
82 cpu-energy-meter.enable = lib.mkDefault true;
83 pqos-wrapper.enable = lib.mkDefault true;
86 # See <https://github.com/sosy-lab/benchexec/blob/3.18/doc/INSTALL.md#kernel-requirements>.
87 security.unprivilegedUsernsClone = true;
90 meta.maintainers = with lib.maintainers; [ lorenzleutgeb ];