mirror of
https://github.com/mjallen18/snowfall-lib.git
synced 2026-04-18 09:05:58 -05:00
style: fmt
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkOption
|
||||
mkDefault
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
user-names = builtins.attrNames cfg.users;
|
||||
|
||||
create-system-users = system-users: name: let
|
||||
user = cfg.users.${name};
|
||||
in
|
||||
create-system-users =
|
||||
system-users: name:
|
||||
let
|
||||
user = cfg.users.${name};
|
||||
in
|
||||
system-users
|
||||
// (optionalAttrs user.create {
|
||||
${name} = {
|
||||
@@ -30,77 +32,84 @@
|
||||
isHidden = mkDefault false;
|
||||
};
|
||||
});
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["snowfallorg" "user"] ["snowfallorg" "users"])
|
||||
(mkRenamedOptionModule [ "snowfallorg" "user" ] [ "snowfallorg" "users" ])
|
||||
];
|
||||
|
||||
options.snowfallorg = {
|
||||
users = mkOption {
|
||||
description = "User configuration.";
|
||||
default = {};
|
||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||
options = {
|
||||
create = mkOption {
|
||||
description = "Whether to create the user automatically.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
default = { };
|
||||
type = types.attrsOf (
|
||||
types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
create = mkOption {
|
||||
description = "Whether to create the user automatically.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
home = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
home = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "/Users/${name}";
|
||||
};
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "/Users/${name}";
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
# HM-compatible options taken from:
|
||||
# https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14
|
||||
type = types.submoduleWith {
|
||||
specialArgs =
|
||||
{
|
||||
osConfig = config;
|
||||
modulesPath = "${inputs.home-manager}/modules";
|
||||
}
|
||||
// config.home-manager.extraSpecialArgs;
|
||||
modules =
|
||||
[
|
||||
({
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = import "${modulesPath}/modules.nix" {
|
||||
inherit pkgs lib;
|
||||
useNixpkgsModule = !config.home-manager.useGlobalPkgs;
|
||||
};
|
||||
config = mkOption {
|
||||
# HM-compatible options taken from:
|
||||
# https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14
|
||||
type = types.submoduleWith {
|
||||
specialArgs = {
|
||||
osConfig = config;
|
||||
modulesPath = "${inputs.home-manager}/modules";
|
||||
}
|
||||
// config.home-manager.extraSpecialArgs;
|
||||
modules = [
|
||||
(
|
||||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = import "${modulesPath}/modules.nix" {
|
||||
inherit pkgs lib;
|
||||
useNixpkgsModule = !config.home-manager.useGlobalPkgs;
|
||||
};
|
||||
|
||||
config = {
|
||||
submoduleSupport.enable = true;
|
||||
submoduleSupport.externalPackageInstall = config.home-manager.useUserPackages;
|
||||
config = {
|
||||
submoduleSupport.enable = true;
|
||||
submoduleSupport.externalPackageInstall = config.home-manager.useUserPackages;
|
||||
|
||||
home.username = config.users.users.${name}.name;
|
||||
home.homeDirectory = config.users.users.${name}.home;
|
||||
home.username = config.users.users.${name}.name;
|
||||
home.homeDirectory = config.users.users.${name}.home;
|
||||
|
||||
nix.package = config.nix.package;
|
||||
};
|
||||
})
|
||||
]
|
||||
++ config.home-manager.sharedModules;
|
||||
nix.package = config.nix.package;
|
||||
};
|
||||
}
|
||||
)
|
||||
]
|
||||
++ config.home-manager.sharedModules;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}));
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
users.users = foldl create-system-users {} user-names;
|
||||
users.users = foldl create-system-users { } user-names;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
inputs @ {
|
||||
inputs@{
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) types mkOption mkIf mkDefault;
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkOption
|
||||
mkIf
|
||||
mkDefault
|
||||
;
|
||||
|
||||
cfg = config.snowfallorg;
|
||||
|
||||
@@ -16,12 +22,14 @@ inputs @ {
|
||||
has-user-name = (cfg.user.name or null) != null;
|
||||
|
||||
default-home-directory =
|
||||
if (os-user-home != null)
|
||||
then os-user-home
|
||||
else if pkgs.stdenv.isDarwin
|
||||
then "/Users/${cfg.user.name}"
|
||||
else "/home/${cfg.user.name}";
|
||||
in {
|
||||
if (os-user-home != null) then
|
||||
os-user-home
|
||||
else if pkgs.stdenv.isDarwin then
|
||||
"/Users/${cfg.user.name}"
|
||||
else
|
||||
"/home/${cfg.user.name}";
|
||||
in
|
||||
{
|
||||
options.snowfallorg = {
|
||||
user = {
|
||||
enable = mkOption {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
args @ {
|
||||
args@{
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkOption
|
||||
mkDefault
|
||||
@@ -18,13 +18,15 @@ args @ {
|
||||
|
||||
cfg = config.snowfallorg;
|
||||
|
||||
inputs = args.inputs or {};
|
||||
inputs = args.inputs or { };
|
||||
|
||||
user-names = builtins.attrNames cfg.users;
|
||||
|
||||
create-system-users = system-users: name: let
|
||||
user = cfg.users.${name};
|
||||
in
|
||||
create-system-users =
|
||||
system-users: name:
|
||||
let
|
||||
user = cfg.users.${name};
|
||||
in
|
||||
system-users
|
||||
// (optionalAttrs user.create {
|
||||
${name} = {
|
||||
@@ -38,88 +40,95 @@ args @ {
|
||||
extraGroups = optional user.admin "wheel";
|
||||
};
|
||||
});
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["snowfallorg" "user"] ["snowfallorg" "users"])
|
||||
(mkRenamedOptionModule [ "snowfallorg" "user" ] [ "snowfallorg" "users" ])
|
||||
];
|
||||
|
||||
options.snowfallorg = {
|
||||
users = mkOption {
|
||||
description = "User configuration.";
|
||||
default = {};
|
||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||
options = {
|
||||
create = mkOption {
|
||||
description = "Whether to create the user automatically.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
default = { };
|
||||
type = types.attrsOf (
|
||||
types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
create = mkOption {
|
||||
description = "Whether to create the user automatically.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
admin = mkOption {
|
||||
description = "Whether the user should be added to the wheel group.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
admin = mkOption {
|
||||
description = "Whether the user should be added to the wheel group.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
home = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
home = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "/home/${name}";
|
||||
};
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "/home/${name}";
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
# HM-compatible options taken from:
|
||||
# https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14
|
||||
# NOTE: This has been adapted to support documentation generation without
|
||||
# having home-manager options fully declared.
|
||||
type = types.submoduleWith {
|
||||
specialArgs =
|
||||
{
|
||||
osConfig = config;
|
||||
modulesPath = "${inputs.home-manager or "/"}/modules";
|
||||
}
|
||||
// (config.home-manager.extraSpecialArgs or {});
|
||||
modules =
|
||||
[
|
||||
({
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
if inputs ? home-manager
|
||||
then {
|
||||
imports = import "${modulesPath}/modules.nix" {
|
||||
inherit pkgs lib;
|
||||
useNixpkgsModule = !(config.home-manager.useGlobalPkgs or false);
|
||||
};
|
||||
config = mkOption {
|
||||
# HM-compatible options taken from:
|
||||
# https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14
|
||||
# NOTE: This has been adapted to support documentation generation without
|
||||
# having home-manager options fully declared.
|
||||
type = types.submoduleWith {
|
||||
specialArgs = {
|
||||
osConfig = config;
|
||||
modulesPath = "${inputs.home-manager or "/"}/modules";
|
||||
}
|
||||
// (config.home-manager.extraSpecialArgs or { });
|
||||
modules = [
|
||||
(
|
||||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
if inputs ? home-manager then
|
||||
{
|
||||
imports = import "${modulesPath}/modules.nix" {
|
||||
inherit pkgs lib;
|
||||
useNixpkgsModule = !(config.home-manager.useGlobalPkgs or false);
|
||||
};
|
||||
|
||||
config = {
|
||||
submoduleSupport.enable = true;
|
||||
submoduleSupport.externalPackageInstall = config.home-manager.useUserPackages;
|
||||
config = {
|
||||
submoduleSupport.enable = true;
|
||||
submoduleSupport.externalPackageInstall = config.home-manager.useUserPackages;
|
||||
|
||||
home.username = config.users.users.${name}.name;
|
||||
home.homeDirectory = config.users.users.${name}.home;
|
||||
home.username = config.users.users.${name}.name;
|
||||
home.homeDirectory = config.users.users.${name}.home;
|
||||
|
||||
nix.package = config.nix.package;
|
||||
};
|
||||
}
|
||||
else {})
|
||||
]
|
||||
++ (config.home-manager.sharedModules or []);
|
||||
nix.package = config.nix.package;
|
||||
};
|
||||
}
|
||||
else
|
||||
{ }
|
||||
)
|
||||
]
|
||||
++ (config.home-manager.sharedModules or [ ]);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}));
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
users.users = foldl create-system-users {} user-names;
|
||||
users.users = foldl create-system-users { } user-names;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user