My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/infra/libkookie/modules/harness/users.nix

39 lines
1.2 KiB

{ 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);
};
}