Move options to seperate modules so they can be shared between home manager and nixos

This commit is contained in:
2024-06-17 17:43:14 -05:00
parent 8f66309008
commit 4910af0d2c
23 changed files with 394 additions and 291 deletions

4
flake.lock generated
View File

@@ -2,8 +2,8 @@
"nodes": { "nodes": {
"currentSystem": { "currentSystem": {
"locked": { "locked": {
"lastModified": 1718580560, "lastModified": 1717721450,
"narHash": "sha256-M69Hx8goDX65ZC/F7ENITsGr3XYBCSsa4B+vDOnOGXs=", "narHash": "sha256-V2OISNdFOCaFrUjA6fLVe3HsZC9nn7vMjGfhKSHTRIk=",
"path": "/etc/nixos/hostname", "path": "/etc/nixos/hostname",
"type": "path" "type": "path"
}, },

View File

@@ -205,6 +205,7 @@
simmer = currentConfig; simmer = currentConfig;
} }
(import ./modules/nix) (import ./modules/nix)
(import ./modules/options)
systemConfig systemConfig
(./. + "/hosts/${hostname}/hardware-configuration.nix") (./. + "/hosts/${hostname}/hardware-configuration.nix")
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager

View File

@@ -1,14 +1,18 @@
{ {
config, config,
pkgs, pkgs,
systemConfig,
... ...
}: }:
{ {
imports = [ imports = [
../../modules/home ../../modules/home
../../modules/options
]; ];
simmer = systemConfig;
home = { home = {
username = "eesim"; username = "eesim";
homeDirectory = "/home/eesim"; homeDirectory = "/home/eesim";

View File

@@ -1,6 +1,7 @@
{ {
config, config,
pkgs, pkgs,
systemConfig,
... ...
}: }:
@@ -8,8 +9,11 @@
imports = [ imports = [
../../modules/home ../../modules/home
../../modules/options
]; ];
simmer = systemConfig;
home = { home = {
username = "eesim"; username = "eesim";
homeDirectory = "/home/eesim"; homeDirectory = "/home/eesim";

View File

@@ -1,14 +1,18 @@
{ {
config, config,
pkgs, pkgs,
systemConfig,
... ...
}: }:
{ {
imports = [ imports = [
../../modules/home ../../modules/home
../../modules/options
]; ];
simmer = systemConfig;
home = { home = {
username = "eesim"; username = "eesim";
# homeDirectory = "/home/eesim"; # homeDirectory = "/home/eesim";

View File

@@ -7,7 +7,7 @@
}: }:
with lib; let with lib; let
gui = systemConfig.gui; gui = config.simmer.gui;
modifier = "Mod4"; modifier = "Mod4";
in in
{ {

View File

@@ -9,42 +9,6 @@ with lib; let
in in
{ {
options.simmer.audio = {
pipewire = {
enable = mkOption {
description = "Enable pipewire";
type = types.bool;
default = false;
};
};
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 = { config = {
environment.systemPackages = with pkgs; [] environment.systemPackages = with pkgs; []
++ optional cfg.pipewire.enable pulseaudio ++ optional cfg.pipewire.enable pulseaudio

View File

@@ -8,52 +8,6 @@ with lib; let
cfg = config.simmer.backup; cfg = config.simmer.backup;
in 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 { config = mkIf cfg.enable {
services.borgbackup.jobs = { services.borgbackup.jobs = {
backup = { backup = {

View File

@@ -9,39 +9,6 @@ with lib; let
cfg = config.simmer.common; cfg = config.simmer.common;
in 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 = true;
};
shell = mkOption {
description = "Default shell to use (fish)";
type = types.enum [ "fish" ];
default = "fish";
};
caps = mkOption {
description = "What key to bind caps lock to";
type = types.enum [ "ctrl-esc" "esc" "caps" ];
default = "ctrl-esc";
};
nixpkgs = mkOption {
description = "Which nixpkgs version to use";
type = types.any;
};
};
config = { config = {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@@ -13,6 +13,5 @@
./common.nix ./common.nix
./networking.nix ./networking.nix
./games.nix ./games.nix
./system.nix
]; ];
} }

View File

@@ -8,50 +8,6 @@ with lib; let
cfg = config.simmer.games; cfg = config.simmer.games;
in 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;
};
minecraft.enable = mkOption {
description = "Whether to install minecraft launcher";
type = types.bool;
default = false;
};
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 { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; with localPackages.x86_64-linux; [] environment.systemPackages = with pkgs; with localPackages.x86_64-linux; []
++ optional cfg.protonup.enable protonup-qt ++ optional cfg.protonup.enable protonup-qt

View File

@@ -9,70 +9,7 @@ with lib; let
cfg = config.simmer.gui; cfg = config.simmer.gui;
in in
{ {
options.simmer.gui = {
enable = mkOption {
description = "Enable gui";
type = types.bool;
default = false;
};
sway = {
enable = mkOption {
description = "Install and configure sway window manager";
type = types.bool;
default = true;
};
desktop = mkOption {
description= "Use desktop configuration";
type = types.bool;
default = false;
};
};
terminal = mkOption {
description = "Which terminal to install (alacritty)";
type = types.enum [ pkgs.alacritty ];
default = pkgs.alacritty;
};
gtk = mkOption {
description = "Whether to configure gtk";
type = types.bool;
default = cfg.gui.enable;
};
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;
};
monitors = mkOption {
description = "Attribute set of system monitors";
type = types.attrs;
default = {};
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; with localPackages.x86_64-linux; [] environment.systemPackages = with pkgs; with localPackages.x86_64-linux; []
++ optionals cfg.sway.enable [ ++ optionals cfg.sway.enable [
wl-clipboard wl-clipboard

View File

@@ -10,51 +10,6 @@ with lib; let
in 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 = [];
};
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 = { config = {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
ldns ldns

View File

@@ -8,26 +8,6 @@ with lib; let
cfg = config.simmer.openssh; cfg = config.simmer.openssh;
in 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 { config = mkIf cfg.enable {
services.openssh = { services.openssh = {
enable = true; enable = true;

47
modules/options/audio.nix Normal file
View File

@@ -0,0 +1,47 @@
{ 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;
};
};
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;
};
};
};
}

View File

@@ -0,0 +1,55 @@
{ pkgs
, lib
, config
, ...
}:
with lib;
{
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" ];
};
};
}

View File

@@ -0,0 +1,41 @@
{ lib
, pkgs
, localPackages
, config
, ...
}:
with lib;
{
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 = true;
};
shell = mkOption {
description = "Default shell to use (fish)";
type = types.enum [ "fish" ];
default = "fish";
};
caps = mkOption {
description = "What key to bind caps lock to";
type = types.enum [ "ctrl-esc" "esc" "caps" ];
default = "ctrl-esc";
};
nixpkgs = mkOption {
description = "Which nixpkgs version to use";
type = types.any;
};
};
}

View File

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

55
modules/options/games.nix Normal file
View File

@@ -0,0 +1,55 @@
{ 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;
};
minecraft.enable = mkOption {
description = "Whether to install minecraft launcher";
type = types.bool;
default = false;
};
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;
};
};
}

73
modules/options/gui.nix Normal file
View File

@@ -0,0 +1,73 @@
{ 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;
};
sway = {
enable = mkOption {
description = "Install and configure sway window manager";
type = types.bool;
default = true;
};
desktop = mkOption {
description= "Use desktop configuration";
type = types.bool;
default = false;
};
};
terminal = mkOption {
description = "Which terminal to install (alacritty)";
type = types.enum [ pkgs.alacritty ];
default = pkgs.alacritty;
};
gtk = mkOption {
description = "Whether to configure gtk";
type = types.bool;
default = cfg.gui.enable;
};
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;
};
monitors = mkOption {
description = "Attribute set of system monitors";
type = types.attrs;
default = {};
};
};
}

View File

@@ -0,0 +1,57 @@
{ lib
, pkgs
, localPackages
, config
, ...
}:
with lib; let
cfg = config.simmer.networking;
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 = [];
};
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" ];
};
};
}

View File

@@ -0,0 +1,31 @@
{ 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;
};
};
}

View File

@@ -1,3 +1,4 @@
{ lib { lib
, pkgs , pkgs
, config , config