user factory reworks

This commit is contained in:
John Lancaster
2026-03-29 15:03:26 -05:00
parent 1991766a5e
commit 6d1cf5aa80
6 changed files with 56 additions and 52 deletions
+3 -4
View File
@@ -3,7 +3,8 @@
flake.modules.nixos.p14sConfiguration = { config, pkgs, lib, ... }:
let
hostname = "john-p14s";
flakeDir = "${config.home-manager.users.john.home.homeDirectory}/Documents/dendritic";
homeDirectory = config.home-manager.users.john.home.homeDirectory;
flakeDir = "${homeDirectory}/Documents/dendritic";
in
{
imports = [
@@ -128,9 +129,7 @@
}
];
sops.defaultSopsFile = ./secrets.yaml;
sops.age.sshKeyPaths = [
"${config.home-manager.users.john.home.homeDirectory}/.ssh/id_ed25519"
];
sops.age.sshKeyPaths = [ "${homeDirectory}/.ssh/id_ed25519" ];
mtls = {
enable = true;
subject = hostname;
+5 -7
View File
@@ -7,11 +7,9 @@ in
flake.nixosConfigurations."${hostname}" = inputs.nixpkgs.lib.nixosSystem {
modules = with inputs.self.modules; [
nixos.lxc
nixos."${username}"
nixos.mysops
nixos.step-ssh-host
inputs.home-manager.nixosModules.home-manager
nixos."${username}"
nixos.zsh
nixos.login-text
# nixos.mtls
# nixos.restic-server
@@ -25,17 +23,19 @@ in
step-ssh-host = {
hostname = hostname;
};
# This provides the secrets at install time
sops.defaultSopsFile = ./secrets.yaml;
home-manager.users."${username}" = {
imports = with inputs.self.modules; [
homeManager"${hostname}"
homeManager."${hostname}"
];
};
}
];
};
flake.modules.homeManager."${hostname}" = { config, lib, pkgs, ... }: {
flake.modules.homeManager."${hostname}" = { config, pkgs, lib, ... }: {
imports = with inputs.self.modules; [
homeManager.rebuild
homeManager.mysops
@@ -45,8 +45,6 @@ in
];
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager";
home.username = "${username}";
home.homeDirectory = "/home/${username}";
shell.program = "zsh";
docker.enable = true;
+15 -6
View File
@@ -1,9 +1,19 @@
# Lifted from:
# https://github.com/Doc-Steve/dendritic-design-with-flake-parts/blob/69edacdb5a4a6ca71d649bb8eb62cf8c630c8627/modules/users/bob%20%5BNDn%5D/bob.nix#L8
{ self, ... }:
{ self, inputs, ... }:
{
config.flake.factory.user = username: isAdmin: {
config.flake.factory.user = {
username,
isAdmin ? false,
noPassword ? false,
# homeImports ? [ ],
# homePackages ? [ ],
}: {
nixos."${username}" = { config, lib, pkgs, ... }: {
imports = [
inputs.home-manager.nixosModules.home-manager
];
users.users."${username}" = {
isNormalUser = true;
home = "/home/${username}";
@@ -22,7 +32,7 @@
enable = true;
extraRules = [{
users = [ "${username}" ];
commands = [{
commands = lib.mkIf noPassword [{
command = "ALL";
options = [ "NOPASSWD" ];
}];
@@ -31,11 +41,10 @@
# https://github.com/Doc-Steve/dendritic-design-with-flake-parts/wiki/Dendritic_Aspects#multi-context-aspect
home-manager.users."${username}" = {
imports = [ self.modules.homeManager."${username}" ];
home.username = "${username}";
home.homeDirectory = "/home/${username}";
imports = [
self.modules.homeManager."${username}"
];
# home.packages = homePackages;
};
};
};
+4 -11
View File
@@ -1,20 +1,13 @@
{ inputs, ... }:
{ self, inputs, ... }:
{
flake.modules.nixos.docker = {
virtualisation.docker = {
enable = true;
};
home-manager.sharedModules = with inputs.self.modules.homeManager; [
docker
];
virtualisation.docker.enable = true;
home-manager.sharedModules = [ inputs.self.modules.homeManager.docker ];
};
flake.modules.homeManager.docker = { config, lib, pkgs, ... }:
{
options.docker = {
enable = lib.mkEnableOption "Docker tools and utilities";
};
options.docker.enable = lib.mkEnableOption "Docker tools and utilities";
config = lib.mkIf config.docker.enable {
programs.lazydocker.enable = true;
programs.docker-cli.enable = true;
+12 -7
View File
@@ -1,4 +1,4 @@
{ inputs, ... }:
{ self, inputs, lib, ... }:
let
username = "john";
in
@@ -16,28 +16,33 @@ in
];
};
flake.modules.nixos."${username}" = {
flake.modules = lib.mkMerge [
(self.factory.user {
username = username;
isAdmin = true;
})
{
nixos."${username}" = {
imports = [
inputs.home-manager.nixosModules.home-manager
(inputs.self.factory.user username true).nixos."${username}"
];
users.users."${username}" = {
openssh.authorizedKeys.keys = inputs.self.meta.users."${username}".authorizedKeys;
extraGroups = [ "docker" ];
};
};
flake.modules.homeManager."${username}" = with inputs.self.meta.users."${username}"; {
# This module will be imported by the user factory
homeManager."${username}" = with inputs.self.meta.users."${username}"; {
home.stateVersion = "25.11";
xdg.enable = true;
programs.git.settings.user.name = name;
programs.git.settings.user.email = email;
imports = with inputs.self.modules.homeManager; [
ssh
shell-tools
git
];
};
}
];
}