refactor: standardize on formatter
This commit is contained in:
parent
723c16bbb5
commit
1284023e7a
20 changed files with 1131 additions and 1111 deletions
|
|
@ -1,29 +1,33 @@
|
|||
{ pkgs, lib, options, config, inputs, ... }:
|
||||
|
||||
let
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) types mkOption mkDefault foldl optionalAttrs;
|
||||
|
||||
cfg = config.snowfallorg;
|
||||
|
||||
user-names = builtins.attrNames cfg.user;
|
||||
|
||||
create-system-users = system-users: name:
|
||||
let
|
||||
user = cfg.user.${name};
|
||||
in
|
||||
system-users // (optionalAttrs user.create {
|
||||
create-system-users = system-users: name: let
|
||||
user = cfg.user.${name};
|
||||
in
|
||||
system-users
|
||||
// (optionalAttrs user.create {
|
||||
${name} = {
|
||||
home = mkDefault user.home.path;
|
||||
isHidden = mkDefault false;
|
||||
};
|
||||
});
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.snowfallorg = {
|
||||
user = mkOption {
|
||||
description = "User configuration.";
|
||||
default = { };
|
||||
type = types.attrsOf (types.submodule ({ name, ... }: {
|
||||
default = {};
|
||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||
options = {
|
||||
create = mkOption {
|
||||
description = "Whether to create the user automatically.";
|
||||
|
|
@ -46,28 +50,36 @@ in
|
|||
# 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;
|
||||
};
|
||||
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 = cfg.useUserPackages;
|
||||
config = {
|
||||
submoduleSupport.enable = true;
|
||||
submoduleSupport.externalPackageInstall = cfg.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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -77,6 +89,6 @@ in
|
|||
};
|
||||
|
||||
config = {
|
||||
users.users = (foldl create-system-users { } (user-names));
|
||||
users.users = foldl create-system-users {} user-names;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
inputs@{ pkgs, lib, options, config, ... }:
|
||||
|
||||
let
|
||||
inputs @ {
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) types mkOption mkIf mkDefault;
|
||||
|
||||
cfg = config.snowfallorg;
|
||||
|
|
@ -12,14 +16,12 @@ let
|
|||
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,19 +1,23 @@
|
|||
args@{ pkgs, lib, options, config, ... }:
|
||||
|
||||
let
|
||||
args @ {
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) types mkOption mkDefault foldl optionalAttrs optional;
|
||||
|
||||
cfg = config.snowfallorg;
|
||||
|
||||
inputs = args.inputs or { };
|
||||
inputs = args.inputs or {};
|
||||
|
||||
user-names = builtins.attrNames cfg.user;
|
||||
|
||||
create-system-users = system-users: name:
|
||||
let
|
||||
user = cfg.user.${name};
|
||||
in
|
||||
system-users // (optionalAttrs user.create {
|
||||
create-system-users = system-users: name: let
|
||||
user = cfg.user.${name};
|
||||
in
|
||||
system-users
|
||||
// (optionalAttrs user.create {
|
||||
${name} = {
|
||||
isNormalUser = mkDefault true;
|
||||
|
||||
|
|
@ -25,14 +29,12 @@ let
|
|||
extraGroups = optional user.admin "wheel";
|
||||
};
|
||||
});
|
||||
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.snowfallorg = {
|
||||
user = mkOption {
|
||||
description = "User configuration.";
|
||||
default = { };
|
||||
type = types.attrsOf (types.submodule ({ name, ... }: {
|
||||
default = {};
|
||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||
options = {
|
||||
create = mkOption {
|
||||
description = "Whether to create the user automatically.";
|
||||
|
|
@ -63,29 +65,39 @@ in
|
|||
# @NOTE(jakehamilton): 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);
|
||||
};
|
||||
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 = cfg.useUserPackages;
|
||||
config = {
|
||||
submoduleSupport.enable = true;
|
||||
submoduleSupport.externalPackageInstall = cfg.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 []);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -95,6 +107,6 @@ in
|
|||
};
|
||||
|
||||
config = {
|
||||
users.users = (foldl (create-system-users) { } (user-names));
|
||||
users.users = foldl create-system-users {} user-names;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue