diff --git a/flake.lock b/flake.lock index 0f2ef7d..02d1277 100644 --- a/flake.lock +++ b/flake.lock @@ -2,8 +2,8 @@ "nodes": { "currentSystem": { "locked": { - "lastModified": 1718580560, - "narHash": "sha256-M69Hx8goDX65ZC/F7ENITsGr3XYBCSsa4B+vDOnOGXs=", + "lastModified": 1717721450, + "narHash": "sha256-V2OISNdFOCaFrUjA6fLVe3HsZC9nn7vMjGfhKSHTRIk=", "path": "/etc/nixos/hostname", "type": "path" }, diff --git a/flake.nix b/flake.nix index b073dc9..f71180e 100644 --- a/flake.nix +++ b/flake.nix @@ -205,6 +205,7 @@ simmer = currentConfig; } (import ./modules/nix) + (import ./modules/options) systemConfig (./. + "/hosts/${hostname}/hardware-configuration.nix") home-manager.nixosModules.home-manager diff --git a/hosts/alpheratz/home.nix b/hosts/alpheratz/home.nix index 0217500..b5f0b1a 100644 --- a/hosts/alpheratz/home.nix +++ b/hosts/alpheratz/home.nix @@ -1,14 +1,18 @@ { config, pkgs, + systemConfig, ... }: { imports = [ ../../modules/home + ../../modules/options ]; + simmer = systemConfig; + home = { username = "eesim"; homeDirectory = "/home/eesim"; diff --git a/hosts/ankaa/home.nix b/hosts/ankaa/home.nix index 9c9832b..76b75b5 100644 --- a/hosts/ankaa/home.nix +++ b/hosts/ankaa/home.nix @@ -1,6 +1,7 @@ { config, pkgs, + systemConfig, ... }: @@ -8,8 +9,11 @@ imports = [ ../../modules/home + ../../modules/options ]; + simmer = systemConfig; + home = { username = "eesim"; homeDirectory = "/home/eesim"; diff --git a/hosts/default/home.nix b/hosts/default/home.nix index 85faae8..cddd1a1 100644 --- a/hosts/default/home.nix +++ b/hosts/default/home.nix @@ -1,14 +1,18 @@ { config, pkgs, + systemConfig, ... }: { imports = [ ../../modules/home + ../../modules/options ]; + simmer = systemConfig; + home = { username = "eesim"; # homeDirectory = "/home/eesim"; diff --git a/modules/home/sway.nix b/modules/home/sway.nix index 851349f..790490a 100644 --- a/modules/home/sway.nix +++ b/modules/home/sway.nix @@ -7,7 +7,7 @@ }: with lib; let - gui = systemConfig.gui; + gui = config.simmer.gui; modifier = "Mod4"; in { diff --git a/modules/nix/audio.nix b/modules/nix/audio.nix index 7091800..dc09e63 100644 --- a/modules/nix/audio.nix +++ b/modules/nix/audio.nix @@ -9,42 +9,6 @@ with lib; let 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 = { environment.systemPackages = with pkgs; [] ++ optional cfg.pipewire.enable pulseaudio diff --git a/modules/nix/backup.nix b/modules/nix/backup.nix index e485aad..a3a27db 100644 --- a/modules/nix/backup.nix +++ b/modules/nix/backup.nix @@ -8,52 +8,6 @@ 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 = { diff --git a/modules/nix/common.nix b/modules/nix/common.nix index f7d903f..ed1307d 100644 --- a/modules/nix/common.nix +++ b/modules/nix/common.nix @@ -9,39 +9,6 @@ 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 = 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 = { environment.systemPackages = with pkgs; [ diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 1b225f7..7fefff3 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -13,6 +13,5 @@ ./common.nix ./networking.nix ./games.nix - ./system.nix ]; } diff --git a/modules/nix/games.nix b/modules/nix/games.nix index 290a2d3..4158c07 100644 --- a/modules/nix/games.nix +++ b/modules/nix/games.nix @@ -8,50 +8,6 @@ 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; - }; - }; - config = mkIf cfg.enable { environment.systemPackages = with pkgs; with localPackages.x86_64-linux; [] ++ optional cfg.protonup.enable protonup-qt diff --git a/modules/nix/gui.nix b/modules/nix/gui.nix index 028fbd0..cca8c8a 100644 --- a/modules/nix/gui.nix +++ b/modules/nix/gui.nix @@ -9,70 +9,7 @@ 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 = {}; - }; - - }; - - config = mkIf cfg.enable { - environment.systemPackages = with pkgs; with localPackages.x86_64-linux; [] ++ optionals cfg.sway.enable [ wl-clipboard diff --git a/modules/nix/networking.nix b/modules/nix/networking.nix index 9440359..6647639 100644 --- a/modules/nix/networking.nix +++ b/modules/nix/networking.nix @@ -10,51 +10,6 @@ with lib; let 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 = { environment.systemPackages = with pkgs; [ ldns diff --git a/modules/nix/openssh.nix b/modules/nix/openssh.nix index 98b4824..93f1939 100644 --- a/modules/nix/openssh.nix +++ b/modules/nix/openssh.nix @@ -8,26 +8,6 @@ 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; diff --git a/modules/options/audio.nix b/modules/options/audio.nix new file mode 100644 index 0000000..58fa548 --- /dev/null +++ b/modules/options/audio.nix @@ -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; + }; + }; + }; +} diff --git a/modules/options/backup.nix b/modules/options/backup.nix new file mode 100644 index 0000000..8025a1b --- /dev/null +++ b/modules/options/backup.nix @@ -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" ]; + }; + + }; +} diff --git a/modules/options/common.nix b/modules/options/common.nix new file mode 100644 index 0000000..0dfee12 --- /dev/null +++ b/modules/options/common.nix @@ -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; + }; + }; +} diff --git a/modules/options/default.nix b/modules/options/default.nix new file mode 100644 index 0000000..311e149 --- /dev/null +++ b/modules/options/default.nix @@ -0,0 +1,18 @@ +{ lib +, pkgs +, config +, ... +}: + +{ + imports = [ + ./audio.nix + ./backup.nix + ./common.nix + ./games.nix + ./gui.nix + ./networking.nix + ./openssh.nix + ./system.nix + ]; +} diff --git a/modules/options/games.nix b/modules/options/games.nix new file mode 100644 index 0000000..aa9bdb3 --- /dev/null +++ b/modules/options/games.nix @@ -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; + }; + }; +} diff --git a/modules/options/gui.nix b/modules/options/gui.nix new file mode 100644 index 0000000..98da05f --- /dev/null +++ b/modules/options/gui.nix @@ -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 = {}; + }; + + }; +} diff --git a/modules/options/networking.nix b/modules/options/networking.nix new file mode 100644 index 0000000..b56b96d --- /dev/null +++ b/modules/options/networking.nix @@ -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" ]; + }; + }; +} diff --git a/modules/options/openssh.nix b/modules/options/openssh.nix new file mode 100644 index 0000000..6496a23 --- /dev/null +++ b/modules/options/openssh.nix @@ -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; + }; + }; +} diff --git a/modules/nix/system.nix b/modules/options/system.nix similarity index 99% rename from modules/nix/system.nix rename to modules/options/system.nix index ed4e7fb..513c1cf 100644 --- a/modules/nix/system.nix +++ b/modules/options/system.nix @@ -1,3 +1,4 @@ + { lib , pkgs , config