Refactor the shared/core namespace

- Move trivial modules to `services.nix`
- Gather user-related config in `users.nix`
- Move loading of shared home-manager config into `shared/core`
This commit is contained in:
Riley Apeldoorn 2023-06-17 20:48:22 +02:00
parent f4d9fc70fc
commit 75603bd327
6 changed files with 57 additions and 50 deletions

View file

@ -18,13 +18,7 @@
let mkUserConfig = path: {
imports = [ home-manager.nixosModules.home-manager ];
config = {
home-manager.users."riley" = a: lib.pipe a [
(import "${path}/home.nix")
(x: x // {
imports = [ ./shared/home ];
isNixos = true;
})
];
home-manager.users."riley" = (import "${path}/home.nix");
};
};
in {

View file

@ -3,28 +3,21 @@
{
imports = [
./services.nix
./backups.nix
./users.nix
./gui.nix
./nix.nix
./ssh.nix
./vpn.nix
];
config = {
users.users."riley" = {
shell = pkgs.bash;
isNormalUser = true;
extraGroups = ["wheel"];
packages = [ pkgs.helix pkgs.neovim ];
};
time.timeZone = "Europe/Amsterdam";
environment.systemPackages = (import ../env.nix pkgs);
services.earlyoom.enable = true;
environment.systemPackages = (import ../env.nix pkgs) ++ (with pkgs; [
# For Mae
neovim
# For me
helix
]);
};
}

19
shared/core/services.nix Normal file
View file

@ -0,0 +1,19 @@
# Services that are common and don't require complex configuration. If there are options
# involved, consider moving the service to its own module.
{ ... }: {
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
};
services.tailscale = {
# TODO: configure declaratively
enable = true;
interfaceName = "ts0";
};
services.earlyoom.enable = true;
}

View file

@ -1,19 +0,0 @@
{ pkgs, ... }:
{
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
};
users.users."riley" = {
# Add ssh client
packages = [ pkgs.openssh ];
# Authorize `riley` user on other machines to SSH into this machine.
openssh.authorizedKeys.keyFiles =
let userKey = sys: ../../system/${sys}/keys/riley.pub;
in map userKey [ "dev-lt-63" "strawberry" "lime" ];
};
}

29
shared/core/users.nix Normal file
View file

@ -0,0 +1,29 @@
# Manage user settings that don't specifically fit anywhere else.
{ pkgs, config, home-manager, lib, ... }: {
imports = [
home-manager.nixosModules.home-manager
];
config.home-manager.users."riley" = {
imports = [ ../home ];
isNixos = true;
home.stateVersion = lib.mkDefault config.system.stateVersion;
};
config.users.users."riley" = {
# TODO: Switch to a less ancient shell
shell = pkgs.bash;
isNormalUser = true;
extraGroups = [
# User is sudoer
"wheel"
];
# Authorize `riley` user on other machines to SSH into this machine.
openssh.authorizedKeys.keyFiles =
let userKey = sys: ../../system/${sys}/keys/riley.pub;
in map userKey [ "dev-lt-63" "strawberry" "lime" ];
};
}

View file

@ -1,9 +0,0 @@
{ ... }: {
services.tailscale = {
# TODO: configure declaratively
enable = true;
interfaceName = "ts0";
};
}