71 lines
1.7 KiB
Nix
71 lines
1.7 KiB
Nix
{ config, lib, ... }:
|
|
let
|
|
cfg = config.alisceon.cloud-init;
|
|
defaultShell =
|
|
if cfg.defaultShell != null then
|
|
cfg.defaultShell
|
|
else
|
|
lib.getExe config.users.users.${cfg.user}.shell;
|
|
in
|
|
{
|
|
options.alisceon.cloud-init = {
|
|
enable = lib.mkEnableOption "shared cloud-init defaults";
|
|
|
|
user = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "alisceon";
|
|
description = "Default cloud-init user to configure.";
|
|
};
|
|
|
|
gecos = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "Alisceon";
|
|
description = "GECOS field for the default cloud-init user.";
|
|
};
|
|
|
|
groups = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [
|
|
"wheel"
|
|
"systemd-journal"
|
|
];
|
|
description = "Groups assigned to the default cloud-init user.";
|
|
};
|
|
|
|
defaultShell = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
description = "Shell path for the default cloud-init user.";
|
|
};
|
|
|
|
datasourceList = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [
|
|
"Oracle"
|
|
"ConfigDrive"
|
|
"NoCloud"
|
|
];
|
|
description = "cloud-init datasources to allow.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
networking.useNetworkd = lib.mkDefault true;
|
|
|
|
services.cloud-init = {
|
|
enable = true;
|
|
network.enable = true;
|
|
settings = {
|
|
datasource_list = cfg.datasourceList;
|
|
users = [ "default" ];
|
|
system_info.default_user = {
|
|
name = cfg.user;
|
|
gecos = cfg.gecos;
|
|
groups = cfg.groups;
|
|
shell = defaultShell;
|
|
lock_passwd = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|