{ config, lib, pkgs, ... }: with lib; let # Defines the structure of a libkookie user definition userCfg = with types; (submodule { options = { name = mkOption { type = str; description = "The name of the user"; }; cfg = mkOption { description = "The user configuration"; }; pubkeys = mkOption { type = listOf str; default = []; description = "Set of ssh public keys to include"; }; }; }); in { options.libkookie = { activeUsers = mkOption { type = with types; listOf userCfg; default = []; description = '' List of active users on this system. This set is used to determine for which users the home-manager specific modules need to be included, or which ssh pubkeys are installed. ''; }; }; config = { users.mutableUsers = false; users.users = builtins.listToAttrs (map ({ name, cfg, pubkeys }: nameValuePair "${name}" (cfg // { group = "${name}"; openssh.authorizedKeys.keys = pubkeys; })) config.libkookie.activeUsers); users.groups = builtins.listToAttrs (map ({ name, ... }: nameValuePair "${name}" {}) config.libkookie.activeUsers); }; }