implementing modules for system applications

This commit is contained in:
cnst
2024-08-18 13:49:05 +02:00
parent 38f68c3550
commit a4306380e3
101 changed files with 1105 additions and 452 deletions

View File

@@ -0,0 +1,15 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.blueman;
in {
options = {
modules.sysd.blueman.enable = mkEnableOption "Enables blueman";
};
config = mkIf cfg.enable {
services.blueman.enable = true;
};
}

View File

@@ -0,0 +1,21 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.dbus;
in {
options = {
modules.sysd.dbus.enable = mkEnableOption "Enables dbus";
};
config = mkIf cfg.enable {
services.dbus = {
enable = true;
packages = with pkgs; [
gcr
];
};
};
}

View File

@@ -0,0 +1,15 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.fwupd;
in {
options = {
modules.sysd.fwupd.enable = mkEnableOption "Enables fwupd";
};
config = mkIf cfg.enable {
services.fwupd.enable = true;
};
}

View File

@@ -0,0 +1,15 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.gnome-keyring;
in {
options = {
modules.sysd.gnome-keyring.enable = mkEnableOption "Enables gnome-keyring";
};
config = mkIf cfg.enable {
services.gnome.gnome-keyring.enable = true;
};
}

View File

@@ -0,0 +1,30 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.greetd;
in {
options = {
modules.sysd.greetd.enable = mkEnableOption "Enables greetd";
};
config = mkIf cfg.enable {
services.greetd = {
enable = true;
settings = {
# AUTOLOGIN
# initial_session = {
# command = "${pkgs.hyprland}/bin/Hyprland";
# user = "cnst"; # <- select which user to auto-login
# };
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet -r --remember-session --asterisks";
user = "greeter";
};
};
};
security.pam.services.greetd.enableGnomeKeyring = true;
};
}

View File

@@ -0,0 +1,15 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.gvfs;
in {
options = {
modules.sysd.gvfs.enable = mkEnableOption "Enables gvfs";
};
config = mkIf cfg.enable {
services.gvfs.enable = true;
};
}

View File

@@ -0,0 +1,20 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.locate;
in {
options = {
modules.sysd.locate.enable = mkEnableOption "Enables plocate";
};
config = mkIf cfg.enable {
services.locate = {
enable = true;
package = pkgs.plocate;
localuser = null;
};
};
}

View File

@@ -0,0 +1,19 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.mullvad;
in {
options = {
modules.sysd.mullvad.enable = mkEnableOption "Enables mullvad";
};
config = mkIf cfg.enable {
services.mullvad-vpn = {
enable = true;
package = pkgs.mullvad-vpn;
};
};
}

View File

@@ -0,0 +1,24 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.pipewire;
in {
options = {
modules.sysd.pipewire.enable = mkEnableOption "Enables pipewire";
};
config = mkIf cfg.enable {
hardware.pulseaudio.enable = false;
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
};
};
}

View File

@@ -0,0 +1,18 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.powerd;
in {
options = {
modules.sysd.powerd.enable = mkEnableOption "Enables power-profiles-daemon";
};
config = mkIf cfg.enable {
services = {
power-profiles-daemon.enable = true;
upower.enable = true;
};
};
}

View File

@@ -0,0 +1,32 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.samba;
in {
options = {
modules.sysd.samba.enable = mkEnableOption "Enables samba";
};
config = mkIf cfg.enable {
services = {
samba = {
enable = true;
package = pkgs.samba4Full;
openFirewall = true;
};
avahi = {
publish.enable = true;
publish.userServices = true;
enable = true;
openFirewall = true;
};
samba-wsdd = {
enable = true;
openFirewall = true;
};
};
};
}

View File

@@ -0,0 +1,73 @@
{
config,
lib,
pkgs,
self,
...
}: let
defaultConfig = {
defaultSopsFile = "${self}/secrets/cnix-secrets.yaml";
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/cnix-secrets.yaml";
};
ssh_host = {
format = "yaml";
sopsFile = "${self}/secrets/cnix-secrets.yaml";
};
};
};
hostSpecificConfig = lib.mkMerge [
(lib.mkIf (config.networking.hostName == "toothpc") {
defaultSopsFile = "${self}/secrets/toothpc-secrets.yaml";
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/toothpc-secrets.yaml";
};
ssh_host = {
format = "yaml";
sopsFile = "${self}/secrets/toothpc-secrets.yaml";
};
};
})
(lib.mkIf (config.networking.hostName == "adampad") {
defaultSopsFile = "${self}/secrets/adampad-secrets.yaml";
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/adampad-secrets.yaml";
};
ssh_host = {
format = "yaml";
sopsFile = "${self}/secrets/adampad-secrets.yaml";
};
};
})
];
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.sops;
in {
options = {
modules.sysd.sops.enable = mkEnableOption "Enables sops";
};
config = mkIf cfg.enable {
sops = lib.mkMerge [
{
age = {sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"];};
gnupg = {
home = "~/.gnupg";
sshKeyPaths = [];
};
}
defaultConfig
hostSpecificConfig
];
environment.systemPackages = [
pkgs.sops
pkgs.age
];
};
}

View File

@@ -0,0 +1,20 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.ssh;
in {
options = {
modules.sysd.ssh.enable = mkEnableOption "Enables ssh";
};
config = mkIf cfg.enable {
services.openssh = {
enable = true;
};
programs.ssh = {
startAgent = true;
};
};
}

View File

@@ -0,0 +1,15 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.udisks;
in {
options = {
modules.sysd.udisks.enable = mkEnableOption "Enables udisks";
};
config = mkIf cfg.enable {
services.udisks2.enable = true;
};
}

View File

@@ -0,0 +1,29 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.xserver.amd;
in {
options = {
modules.sysd.xserver.amd.enable = mkEnableOption "Enables xserver with amdgpu";
};
config = mkIf cfg.enable {
services.xserver = {
enable = true;
videoDrivers = ["amdgpu"];
# xkb = {
# extraLayouts.hhkbse = {
# description = "HHKBse by cnst";
# languages = ["se"];
# symbolsFile = /home/cnst/.nix-config/nixos/hosts/cnix/xkb/symbols/hhkbse;
# };
# layout = "hhkbse";
# # dir = "/home/cnst/.nix-config/nixos/xkb";
# variant = "";
# options = "lv3:rwin_switch";
# };
};
};
}

View File

@@ -0,0 +1,30 @@
{
config,
lib,
hostConfig,
...
}: let
path = "${hostConfig}/cnix/xkb/symbols";
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.xserver.amd.hhkbse;
in {
options = {
modules.sysd.xserver.amd.hhkbse.enable = mkEnableOption "Enables xserver for amdgpu with HHKBSE";
};
config = mkIf cfg.enable {
services.xserver = {
enable = true;
videoDrivers = ["amdgpu"];
xkb = {
extraLayouts.hhkbse = {
description = "HHKBse by cnst";
languages = ["se"];
symbolsFile = "${path}/hhkbse";
};
layout = "hhkbse";
variant = "";
options = "lv3:rwin_switch";
};
};
};
}

View File

@@ -0,0 +1,19 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.sysd.xserver.nvidia;
in {
options = {
modules.sysd.xserver.nvidia.enable = mkEnableOption "Enables xserver with nvidia";
};
config = mkIf cfg.enable {
services.xserver = {
enable = true;
videoDrivers = ["nvidia"];
xkb.layout = "se";
};
};
}