Move from features to option based configuration
This commit is contained in:
78
modules/nix/audio.nix
Normal file
78
modules/nix/audio.nix
Normal 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
74
modules/nix/backup.nix
Normal 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
58
modules/nix/common.nix
Normal 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
17
modules/nix/default.nix
Normal 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
61
modules/nix/games.nix
Normal 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
85
modules/nix/gui.nix
Normal 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
|
||||
];
|
||||
};
|
||||
}
|
||||
74
modules/nix/networking.nix
Normal file
74
modules/nix/networking.nix
Normal 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
42
modules/nix/openssh.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user