feat: move to single-user config
This commit is contained in:
+10
-36
@@ -1,7 +1,6 @@
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
nixosModules = config.flake.modules.nixos;
|
||||
hmModules = config.flake.modules.homeManager;
|
||||
|
||||
resolvePackagePath =
|
||||
{
|
||||
@@ -40,6 +39,9 @@ let
|
||||
mkHost =
|
||||
machine:
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
account = config.repo.account;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
nixosModules.host-base
|
||||
@@ -53,50 +55,23 @@ let
|
||||
|
||||
programs.zsh.enable = true;
|
||||
|
||||
users.users = lib.mapAttrs (_: user: {
|
||||
users.users.${account.name} = {
|
||||
isNormalUser = true;
|
||||
home = user.account.homeDirectory;
|
||||
home = account.homeDirectory;
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"networkmanager"
|
||||
];
|
||||
shell = pkgs.zsh;
|
||||
}) machine.users;
|
||||
|
||||
home-manager.users = lib.mapAttrs (name: user: {
|
||||
imports = [ user.account.baseModule ];
|
||||
|
||||
meta = {
|
||||
inherit machine user;
|
||||
};
|
||||
};
|
||||
|
||||
home-manager.users.${account.name} = {
|
||||
home = {
|
||||
username = name;
|
||||
homeDirectory = user.account.homeDirectory;
|
||||
username = account.name;
|
||||
homeDirectory = account.homeDirectory;
|
||||
stateVersion = machine.hmStateVersion;
|
||||
};
|
||||
}) machine.users;
|
||||
};
|
||||
|
||||
mkWorkstationHost =
|
||||
machine:
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
(mkHost machine)
|
||||
nixosModules.workstation-base
|
||||
];
|
||||
|
||||
users.users = lib.mapAttrs (_: _: {
|
||||
extraGroups = [ "networkmanager" ];
|
||||
}) machine.users;
|
||||
|
||||
home-manager.users = lib.mapAttrs (_: user: {
|
||||
imports = [
|
||||
hmModules.workstation-base
|
||||
user.account.workstationModule
|
||||
];
|
||||
}) machine.users;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
@@ -110,7 +85,6 @@ in
|
||||
inherit
|
||||
mkCaddyReverseProxy
|
||||
mkHost
|
||||
mkWorkstationHost
|
||||
resolvePackagePath
|
||||
;
|
||||
};
|
||||
|
||||
+20
-63
@@ -1,5 +1,7 @@
|
||||
{ lib, ... }:
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
nixosModules = config.flake.modules.nixos;
|
||||
|
||||
sourceControlScopeType = lib.types.enum [
|
||||
"personal"
|
||||
"work"
|
||||
@@ -46,12 +48,11 @@ let
|
||||
);
|
||||
|
||||
accountType = lib.types.submodule (
|
||||
{ name, config, ... }:
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
|
||||
realName = lib.mkOption {
|
||||
@@ -73,16 +74,6 @@ let
|
||||
default = { };
|
||||
};
|
||||
|
||||
baseModule = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
default = { };
|
||||
};
|
||||
|
||||
workstationModule = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
default = { };
|
||||
};
|
||||
|
||||
sourceControl = lib.mkOption {
|
||||
type = sourceControlAccountType;
|
||||
default = { };
|
||||
@@ -160,7 +151,7 @@ let
|
||||
}
|
||||
);
|
||||
|
||||
sourceControlMachineUserType = lib.types.submodule (
|
||||
sourceControlMachineType = lib.types.submodule (
|
||||
{ ... }:
|
||||
{
|
||||
options = {
|
||||
@@ -177,27 +168,6 @@ let
|
||||
}
|
||||
);
|
||||
|
||||
machineUserType = lib.types.submodule (
|
||||
{ ... }:
|
||||
{
|
||||
options = {
|
||||
account = lib.mkOption {
|
||||
type = accountType;
|
||||
};
|
||||
|
||||
sourceControl = lib.mkOption {
|
||||
type = sourceControlMachineUserType;
|
||||
default = { };
|
||||
};
|
||||
|
||||
syncthingId = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
machineType = lib.types.submodule (
|
||||
{ name, config, ... }:
|
||||
{
|
||||
@@ -209,11 +179,7 @@ let
|
||||
|
||||
module = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
default = { };
|
||||
};
|
||||
|
||||
buildFunction = lib.mkOption {
|
||||
type = lib.types.functionTo lib.types.deferredModule;
|
||||
default = nixosModules.${name};
|
||||
};
|
||||
|
||||
stateVersion = lib.mkOption {
|
||||
@@ -230,19 +196,28 @@ let
|
||||
default = { };
|
||||
};
|
||||
|
||||
users = lib.mkOption {
|
||||
type = lib.types.attrsOf machineUserType;
|
||||
sourceControl = lib.mkOption {
|
||||
type = sourceControlMachineType;
|
||||
default = { };
|
||||
};
|
||||
|
||||
syncthingId = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
portable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
options.repo = {
|
||||
accounts = lib.mkOption {
|
||||
type = lib.types.attrsOf accountType;
|
||||
default = { };
|
||||
account = lib.mkOption {
|
||||
type = accountType;
|
||||
};
|
||||
|
||||
machines = lib.mkOption {
|
||||
@@ -250,11 +225,6 @@ in
|
||||
default = { };
|
||||
};
|
||||
|
||||
contact = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
default = { };
|
||||
};
|
||||
|
||||
desktop = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
default = { };
|
||||
@@ -279,17 +249,4 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config.flake.modules.homeManager.meta =
|
||||
{ ... }:
|
||||
{
|
||||
options.meta = {
|
||||
machine = lib.mkOption {
|
||||
type = machineType;
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = machineUserType;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user