From aa0efee791b610489ba51ccc23898c9a0f8d3950 Mon Sep 17 00:00:00 2001 From: TheWanderingCrow Date: Tue, 3 Jun 2025 14:41:12 -0400 Subject: [PATCH] work --- README.md | 2 - hosts/common/users/primary/default.nix | 57 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 hosts/common/users/primary/default.nix diff --git a/README.md b/README.md index 9c3c4d4..297e5a1 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,6 @@ - `darwin` - Custom modules specific to dariwn-based hosts - `home-manager` - Custom modules to home-manager - `nixos` - Custom modules specific to nixos-based hosts -- `nixos-installer` - A stripped down version of the main nix-config flake used - exclusively during installation of NixOS and nix-config on hosts. - `overlays` - Custom modifications to upstream packages. - Currently not using overlays. - `pkgs` - Custom packages meant to be shared or upstreamed. diff --git a/hosts/common/users/primary/default.nix b/hosts/common/users/primary/default.nix new file mode 100644 index 0000000..a2fbfd1 --- /dev/null +++ b/hosts/common/users/primary/default.nix @@ -0,0 +1,57 @@ +{ + inputs, + pkgs, + config, + lib, + ... +}: let + hostSpec = config.hostSpec; + pubKeys = lib.filesystem.listFilesRecursive ./keys; +in + { + users.users.${hostSpec.username} = { + name = hostSpec.username; + shell = pkgs.zsh; + + openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key); + + # Create ssh sockets directory for controlpaths when homemanager not loaded (i.e. isMinimal) + systemd.tmpfiles.rules = let + user = config.users.users.${hostSpec.username}.name; + group = config.users.users.${hostSpec.username}.group; + in [ + "d /home/${hostSpec.username}/.ssh 0750 ${user} ${group} -" + "d /home/${hostSpec.username}/.ssh/sockets 0750 ${user} ${group} -" + ]; + + programs.zsh.enable = true; + environment.systemPackages = [ + pkgs.git + pkgs.vim + ]; + }; + } + // lib.optionalAttrs (inputs ? "home-manager") { + home-manager = { + extraSpecialArgs = { + inherit pkgs inputs; + hostSpec = config.hostSpec; + }; + users.${hostSpec.username}.imports = lib.flatten ( + lib.optional (!hostSpec.isMinimal) [ + ( + {config, ...}: + import (lib.custom.relativeToRoot "home/${hostSpec.username}/${hostSpec.hostName}.nix") { + inherit + pkgs + inputs + config + lib + hostSpec + ; + } + ) + ] + ); + }; + }