Move from features to option based configuration

This commit is contained in:
2024-06-02 20:34:55 -05:00
parent 488fbf47fb
commit 21e825b2d1
28 changed files with 729 additions and 179 deletions

View File

@@ -1,23 +0,0 @@
{ pkgs, lib, ... }: {
services.borgbackup.jobs = {
home-ankaa =
let
user = "eesim";
home = "/home/${user}";
excludes = [ ".local/share/Steam/steamapps/common" ".cache" ];
in
{
inherit user;
paths = [ home ];
exclude = builtins.map (e: "${home}/${e}") excludes;
repo = "rf030789@rf030789.repo.borgbase.com:repo";
encryption = {
mode = "repokey-blake2";
passCommand = "cat ${home}/.ssh/borgbase_passphrase";
};
environment.BORG_RSH = "ssh -i ${home}/.ssh/id_ed25519_borgbase";
compression = "auto,lzma";
startAt = "daily";
};
};
}

14
modules/home/default.nix Normal file
View File

@@ -0,0 +1,14 @@
{ lib
, pkgs
, config
, ...
}:
{
imports = [
./git.nix
./direnv.nix
./git.nix
./qt.nix
];
}

26
modules/home/direnv.nix Normal file
View File

@@ -0,0 +1,26 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.simmer.direnv;
in
{
options.simmer.direnv = {
enable = mkOption {
description = "Whether to install and configure direnv";
type = types.bool;
default = true;
};
};
config = mkIf cfg.enable {
programs.direnv = {
enable = true;
enableBashIntegration = true;
nix-direnv.enable = true;
};
};
}

26
modules/home/git.nix Normal file
View File

@@ -0,0 +1,26 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.simmer.git;
in
{
options.simmer.git = {
enable = mkOption {
description = "Whether to install and configure git";
type = types.bool;
default = true;
};
};
config = mkIf cfg.enable {
programs.git = {
enable = true;
userName = "Ethan Simmons";
userEmail = "eesimmons9105@gmail.com";
};
};
}

37
modules/home/gtk.nix Normal file
View File

@@ -0,0 +1,37 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.simmer.gtk;
gui = config.simmer.gui;
in
{
options.simmer.gtk = {
theme.enable = mkOption {
description = "Whether to enable gtk themes";
type = types.bool;
default = gui.enable;
};
};
config = {
gtk = mkIf cfg.enable {
enable = true;
cursorTheme = {
name = "phinger-cursors-dark";
package = pkgs.phinger-cursors;
};
iconTheme = {
name = "awaida-dark";
package = pkgs.gnome.adwaita-icon-theme;
};
theme = {
name = "adw-gtk3-dark";
package = pkgs.adw-gtk3;
};
};
};
}

26
modules/home/qt.nix Normal file
View File

@@ -0,0 +1,26 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.simmer.qt;
gui = config.simmer.gui;
in
{
options.simmer.qt = {
theme.enable = mkOption {
description = "Whether to enable qt themes";
type = types.bool;
default = gui.enable;
};
};
config = {
qt.style = mkIf cfg.theme.enable {
name = "adwaita-dark";
package = pkgs.adwaita-qt;
};
};
}

78
modules/nix/audio.nix Normal file
View File

@@ -0,0 +1,78 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.simmer.audio;
in
{
options.simmer.audio = {
pipewire = {
enable = mkOption {
description = "Enable pipewire";
type = types.bool;
default = false;
};
pulseSupport = mkOption {
description = "Enable pulse support for pipewire";
type = types.bool;
default = true;
};
alsaSupport = mkOption {
description = "Enable alsa support for pipewire";
type = types.bool;
default = true;
};
};
music = {
enable = mkOption {
description = "Install music player";
type = types.bool;
default = false;
};
};
tools = {
helvum = mkOption {
description = "Install helvum";
type = types.bool;
default = false;
};
easyeffects = mkOption {
description = "Install easyeffects";
type = types.bool;
default = false;
};
pavucontrol = mkOption {
description = "Install pavucontrol";
type = types.bool;
default = cfg.pipewire.enable;
};
};
};
config = {
environment.systemPackages =
with pkgs; []
++ optional cfg.tools.helvum helvum
++ optional cfg.tools.easyeffects easyeffects
++ optional cfg.tools.pavucontrol pavucontrol
++ optional cfg.pipewire.pulseSupport pulseaudio
++ optional cfg.music.enable feishin;
security.rtkit.enable = mkIf cfg.pipewire.enable true;
services.pipewire = mkIf cfg.pipewire.enable {
enable = true;
alsa = mkIf cfg.pipewire.alsaSupport {
enable = true;
support32Bit = true;
};
pulse.enable = mkIf cfg.pipewire.pulseSupport true;
};
};
}

74
modules/nix/backup.nix Normal file
View File

@@ -0,0 +1,74 @@
{ pkgs
, lib
, config
, ...
}:
with lib; let
cfg = config.simmer.backup;
in
{
options.simmer.backup = {
enable = mkOption {
description = "Whether backups should be enabled";
type = types.bool;
default = false;
};
repo = mkOption {
description = "Which repository to backup to";
type = types.str;
};
paths = mkOption {
description = "Which paths to backup";
type = types.listOf types.str;
};
user = mkOption {
description = "Which user to run backup commands with";
type = types.str;
default = "root";
};
excludes = mkOption {
description = "Which directories to exclude";
type = types.listOf types.str;
default = [];
};
passphrase = mkOption {
description = "path to file containing passphrase";
type = types.path;
};
key = mkOption {
description = "Path to file containing SSH Key";
type = types.path;
};
repeat = mkOption {
description = "How often to run the backup (hourly, daily, weekly)";
type = types.enum [ "hourly" "daily" "weekly" ];
};
};
config = mkIf cfg.enable {
services.borgbackup.jobs = {
backup = {
user = cfg.user;
paths = cfg.paths;
exclude = cfg.excludes;
repo = cfg.repo;
encryption = {
mode = "repokey-blake2";
passCommand = "cat ${cfg.passphrase}";
};
environment.BORG_RSH = "ssh -i ${cfg.key}";
compression = "auto,lzma";
startAt = cfg.repeat;
};
};
};
}

58
modules/nix/common.nix Normal file
View File

@@ -0,0 +1,58 @@
{ lib
, pkgs
, localPackages
, config
, ...
}:
with lib; let
cfg = config.simmer.common;
in
{
options.simmer.common = {
neovim.enable = mkOption {
description = "Whether to install neovim and set as default editor";
type = types.bool;
default = true;
};
nil.enable = mkOption {
description = "Whether to install nil";
type = types.bool;
default = false;
};
shell = mkOption {
description = "Default shell to use (fish)";
type = types.enum [ "fish" ];
default = "fish";
};
};
config = {
environment.systemPackages = with pkgs; [
curl
wget
git
killall
vim
eza
ripgrep
fzf
ncdu
btop
]
++ optional cfg.nil.enable nil;
programs.neovim = mkIf cfg.neovim.enable {
enable = true;
defaultEditor = true;
};
programs.fish.enable = mkIf (cfg.shell == "fish") true;
};
}

17
modules/nix/default.nix Normal file
View File

@@ -0,0 +1,17 @@
{ lib
, pkgs
, config
, ...
}:
{
imports = [
./openssh.nix
./backup.nix
./audio.nix
./gui.nix
./common.nix
./networking.nix
./games.nix
];
}

61
modules/nix/games.nix Normal file
View File

@@ -0,0 +1,61 @@
{ lib
, pkgs
, config
, localPackages
, ...
}:
with lib; let
cfg = config.simmer.games;
in
{
options.simmer.games = {
enable = mkOption {
description = "Whether to enable games";
type = types.bool;
default = false;
};
protonup.enable = mkOption {
description = "Whether to install protonup";
type = types.bool;
default = true;
};
lutris.enable = mkOption {
description = "Whether to install lutris";
type = types.bool;
default = false;
};
steam.enable = mkOption {
description = "Whether to install steam";
type = types.bool;
default = true;
};
gamescope.enable = mkOption {
description = "Whether to install gamescope";
type = types.bool;
default = cfg.steam.enable;
};
discord.enable = mkOption {
description = "Whether to install discord";
type = types.bool;
default = true;
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; with localPackages.x86_64-linux;
[]
++ optional cfg.protonup.enable protonup-qt
++ optional cfg.gamescope.enable gamescope-old
++ optional cfg.discord.enable vesktop
++ optionals cfg.lutris.enable [ lutris wine ];
programs.steam = mkIf cfg.steam.enable {
enable = true;
};
};
}

85
modules/nix/gui.nix Normal file
View File

@@ -0,0 +1,85 @@
{ lib
, pkgs
, config
, localPackages
, ...
}:
with lib; let
cfg = config.simmer.gui;
in
{
options.simmer.gui = {
enable = mkOption {
description = "Enable gui";
type = types.bool;
default = false;
};
wm = mkOption {
description = "Which window manager to install";
type = types.enum [ "sway" ];
default = "sway";
};
terminal = mkOption {
description = "Which terminal to install (alacritty)";
type = types.enum [ pkgs.alacritty ];
default = pkgs.alacritty;
};
protonmail = mkOption {
description = "Whether to install protonmail bridge and mail application";
type = types.bool;
default = false;
};
secrets = mkOption {
description = "Whether to enable secrets handling with gnomke-keyring";
type = types.bool;
default = cfg.protonmail;
};
matrix = mkOption {
description = "Whether to install a matrix client";
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; with localPackages.x86_64-linux; []
++ optionals (cfg.wm == "sway") [
wl-clipboard
grim
slurp
waybar
swaybg
kickoff
kickoff-dot-desktop
wayland-pipewire-idle-inhibit
firefox
mpv
]
++ [ cfg.terminal ]
++ optional cfg.matrix cinny-desktop
++ optional cfg.secrets libsecret
++ optionals cfg.protonmail [ thunderbird protonmail-bridge ];
programs.sway.enable = mkIf (cfg.wm == "sway") true;
programs.dconf.enable = mkIf cfg.secrets true;
services.gnome.gnome-keyring.enable = mkIf cfg.secrets true;
services.dbus.packages = mkIf cfg.secrets [ pkgs.gnome.seahorse ];
xdg.portal.wlr.enable = true;
programs.thunar.enable = true;
fonts.packages = with pkgs; [
font-awesome
];
};
}

View File

@@ -0,0 +1,74 @@
{ lib
, pkgs
, localPackages
, config
, ...
}:
with lib; let
cfg = config.simmer.networking;
openssh = config.simmer.openssh;
in
{
options.simmer.networking = {
firewall = {
enable = mkOption {
description = "Whether to enable firewall";
type = types.bool;
default = true;
};
allowedTCPPorts = mkOption {
description = "Which tcp ports to allow through firewall";
type = types.listOf types.int;
default = []
++ optional openssh.enable openssh.port;
};
allowedUDPPorts = mkOption {
description = "Which udp ports to allow through firewall";
type = types.listOf types.int;
default = [];
};
};
wireguard = {
enable = mkOption {
description = "Whether to install wireguard";
type = types.bool;
default = false;
};
};
networkmanager = {
enable = mkOption {
description = "Whether to enable network manager";
type = types.bool;
default = true;
};
};
nameservers = mkOption {
description = "Which nameservers to use";
type = types.listOf types.str;
default = [ "1.1.1.1" ];
};
};
config = {
environment.systemPackages = with pkgs; [
ldns
]
++ optional cfg.wireguard.enable wireguard-tools;
networking.networkmanager.enable = cfg.networkmanager.enable;
networking.nameservers = cfg.nameservers;
networking.firewall = {
enable = cfg.firewall.enable;
allowedTCPPorts = cfg.firewall.allowedTCPPorts;
allowedUDPPorts = cfg.firewall.allowedUDPPorts;
};
};
}

42
modules/nix/openssh.nix Normal file
View File

@@ -0,0 +1,42 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.simmer.openssh;
in
{
options.simmer.openssh = {
enable = mkOption {
description = "Whether to enable openssh server";
type = types.bool;
default = false;
};
port = mkOption {
description = "What port the server should run on";
type = types.int;
default = 22;
};
allow-password = mkOption {
description = "Whether the server should allow password authenitication" ;
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
services.openssh = {
enable = true;
ports = [ cfg.port ];
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
};
}

View File

@@ -1,16 +0,0 @@
{ lib
, pkgs
, openssh-port ? 22
, ...
}:
{
services.openssh = {
enable = true;
ports = [ openssh-port ];
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
}