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