add: more system modules

This commit is contained in:
ooks-io 2024-01-17 22:18:39 +13:00
parent 47eb3e0691
commit 793cc3131c
17 changed files with 291 additions and 56 deletions

View file

@ -20,5 +20,14 @@
pipewire = {
enable = lib.mkEnableOption "Enable pipewire module";
};
networking = {
enable = lib.mkEnableOption "Enable networking module";
};
virtualisation = {
enable = lib.mkEnableOption "Enable virtualisation module";
};
locale = {
enable = lib.mkEnableOption "Enable locale module";
};
};
}

View file

@ -1,11 +1,18 @@
{ lib, ... }: {
i18n = {
defaultLocale = lib.mkDefault "en_US.UTF-8";
supportedLocales = lib.mkDefault [
"en_US.UTF-8/UTF-8"
];
};
time.timeZone = lib.mkDefault "Pacific/Auckland";
services.geoclue2.enable = true;
}
{ lib, config, ... }:
let
cfg = config.systemModules.locale;
in
{
config = lib.mkIf cfg.enable {
i18n = {
defaultLocale = lib.mkDefault "en_US.UTF-8";
supportedLocales = lib.mkDefault [
"en_US.UTF-8/UTF-8"
];
};
time.timeZone = lib.mkDefault "Pacific/Auckland";
services.geoclue2.enable = true;
};
}

View file

@ -1,18 +1,25 @@
{ lib, ... }:
{ lib, config, ... }:
let
cfg = config.systemModules.networking;
in
{
networking.networkmanager = {
enable = true;
dns = "systemd-resolved";
};
networking.firewall.allowedTCPPorts = [57621];
services = {
openssh = {
config = lib.mkIf cfg.enable {
networking.networkmanager = {
enable = true;
settings.UseDns = true;
dns = "systemd-resolved";
};
resolved.enable = true;
};
networking.firewall.allowedTCPPorts = [57621];
systemd.services.NetworkManager-wait-online.enable = lib.mkForce false;
services = {
openssh = {
enable = true;
settings.UseDns = true;
};
resolved.enable = true;
};
systemd.services.NetworkManager-wait-online.enable = lib.mkForce false;
};
}

View file

@ -0,0 +1,14 @@
{ lib, ... }:
{
imports = [
./shell
./ooks.nix
];
options.systemModules.user = {
ooks = {
enable = lib.mkEnableOption "Enable the user ooks";
};
};
}

View file

@ -0,0 +1,28 @@
{ lib, pkgs, config, ... }:
let
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
cfg = config.systemModule.user.ooks;
in
{
config = lib.mkIf cfg.enable {
users.users.ooks = {
isNormalUser = true;
extraGroups = [
"wheel"
"video"
"audio"
] ++ ifTheyExist [
"git"
"network"
"libvirtd"
"deluge"
];
packages = [ pkgs.home-manager ];
};
home-manager.users.ooks = import ../../../../home/user/ooks/${config.networking.hostName};
};
}

View file

@ -0,0 +1,40 @@
{ lib, config, ... }:
let
cfg = config.systemModules.user.shell;
in
{
imports = [
./fish
# ./bash
# ./zsh
];
options.systemModules.user.shell = {
fish = {
enable = lib.mkEnableOption "Enable fish as the user shell";
};
zsh = {
enable = lib.mkEnableOption "Enable zsh as the user shell";
};
bash = {
enable = lib.mkEnableOption "Enable bash as the user shell";
};
};
config = {
assertions = [
{
assertion =
(lib.length (lib.filter (x: x) [
cfg.fish.enable or false
cfg.zsh.enable or false
cfg.bash.enable or false
]) <= 1);
message = "Only one user shell can be active in the configuration";
}
];
};
}

View file

@ -0,0 +1,19 @@
{ pkgs, lib, config, ... }:
let
cfg = config.systemModules.user.shell.fish;
in
{
config = lib.mkIf cfg.enable {
users.users.ooks.shell = pkgs.fish;
programs.fish = {
enable = true;
vendor = {
completions.enable = true;
config.enable = true;
functions.enable = true;
};
};
};
}

View file

@ -1,12 +0,0 @@
{ pkgs, ... }:
{
users.users.ooks.shell = pkgs.fish;
programs.fish = {
enable = true;
vendor = {
completions.enable = true;
config.enable = true;
functions.enable = true;
};
};
}

View file

@ -1,28 +1,33 @@
{config, pkgs, ... }:
{ lib, config, pkgs, ... }:
let
cfg = config.systemModules.virtualisation;
in
{
environment.systemPackages = with pkgs; [
virt-manager
virt-viewer
spice
spice-gtk
spice-protocol
win-virtio
win-spice
gnome.adwaita-icon-theme
];
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
virt-manager
virt-viewer
spice
spice-gtk
spice-protocol
win-virtio
win-spice
gnome.adwaita-icon-theme
];
virtualisation = {
libvirtd = {
enable = true;
qemu = {
swtpm.enable = true;
ovmf.enable = true;
ovmf.packages = [ pkgs.OVMFFull.fd ];
virtualisation = {
libvirtd = {
enable = true;
qemu = {
swtpm.enable = true;
ovmf.enable = true;
ovmf.packages = [ pkgs.OVMFFull.fd ];
};
};
spiceUSBRedirection.enable = true;
};
spiceUSBRedirection.enable = true;
services.spice-vdagentd.enable = true;
};
services.spice-vdagentd.enable = true;
}