From 7ab2df21a6c5cb6c3f7fbcb20334b97785768207 Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 21 May 2024 09:22:03 -0400 Subject: [PATCH] More messing around; added a module template --- hosts/Haven/default.nix | 16 ++++---- .../services => hosts/Haven}/etc/apcupsd.conf | 0 hosts/Khanda/default.nix | 18 ++++---- hosts/Pihole/default.nix | 16 ++------ modules/autoimport.nix | 1 + modules/module.nix.template | 41 +++++++++++++++++++ modules/services/airsonic.nix | 1 + modules/services/apcupsd.nix | 10 ++++- modules/services/forgejo.nix | 1 + modules/ui/flatpak.nix | 3 +- modules/ui/gnome.nix | 9 ++-- modules/users/aires/default.nix | 2 - modules/users/gremlin/default.nix | 3 -- 13 files changed, 76 insertions(+), 45 deletions(-) rename {modules/services => hosts/Haven}/etc/apcupsd.conf (100%) create mode 100644 modules/module.nix.template diff --git a/hosts/Haven/default.nix b/hosts/Haven/default.nix index cfbdaba..a778ec7 100644 --- a/hosts/Haven/default.nix +++ b/hosts/Haven/default.nix @@ -42,7 +42,10 @@ in }; }; }; - apcupsd.enable = true; + apcupsd = { + enable = true; + configText = builtins.readFile ./etc/apcupsd.conf; + }; airsonic = { enable = true; domain = config.secrets.networking.primaryDomain; @@ -79,15 +82,12 @@ in ports = [ config.secrets.hosts.haven.ssh.port ]; }; }; - users = { - aires = { + users.aires = { + enable = true; + services.syncthing = { enable = true; - services.syncthing = { - enable = true; - autostart = false; - }; + autostart = false; }; - media.enable = true; }; }; diff --git a/modules/services/etc/apcupsd.conf b/hosts/Haven/etc/apcupsd.conf similarity index 100% rename from modules/services/etc/apcupsd.conf rename to hosts/Haven/etc/apcupsd.conf diff --git a/hosts/Khanda/default.nix b/hosts/Khanda/default.nix index 3bb3370..1b784dc 100644 --- a/hosts/Khanda/default.nix +++ b/hosts/Khanda/default.nix @@ -19,16 +19,14 @@ flatpak.enable = true; gnome.enable = true; }; - users = { - aires = { - enable = true; - autologin = true; - services = { - syncthing = { - enable = true; - autostart = true; - enableTray = false; - }; + users.aires = { + enable = true; + autologin = true; + services = { + syncthing = { + enable = true; + autostart = true; + enableTray = false; }; }; }; diff --git a/hosts/Pihole/default.nix b/hosts/Pihole/default.nix index ba33daf..b0899c5 100644 --- a/hosts/Pihole/default.nix +++ b/hosts/Pihole/default.nix @@ -13,6 +13,10 @@ role = "server"; users.aires.enable = true; boot.enable = false; + services.ssh = { + enable = true; + ports = [ nix-secrets.hosts.haven.ssh.port ]; + }; }; networking.hostName = "Pihole"; @@ -34,16 +38,4 @@ }; }; }; - - # Enable SSH - services.openssh = { - enable = true; - ports = [ 33105 ]; - - settings = { - PasswordAuthentication = true; - AllowUsers = [ "aires" ]; - PermitRootLogin = "no"; - }; - }; } diff --git a/modules/autoimport.nix b/modules/autoimport.nix index d6955fd..471674b 100644 --- a/modules/autoimport.nix +++ b/modules/autoimport.nix @@ -14,6 +14,7 @@ let files = dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir)); + # Search all files and folders within and below the current directory. # Filters out directories that belong to home-manager, and don't end with .nix or are this file. # Also, make the strings absolute validFiles = diff --git a/modules/module.nix.template b/modules/module.nix.template new file mode 100644 index 0000000..d76d5cb --- /dev/null +++ b/modules/module.nix.template @@ -0,0 +1,41 @@ +# This is an example of a blank module. +{ config, lib, ... }: + +let + cfg = config.host.services.myModule; +in +{ + options = { + host.services.myModule = { + enable = lib.mkEnableOption (lib.mdDoc "Enables this example module."); + attributes = lib.mkOption { + default = { }; + type = lib.types.attrs; + description = "An example of an attributes option."; + }; + string = lib.mkOption { + default = ""; + type = lib.types.str; + description = "An example of a string option."; + }; + list = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.int; + description = "An example of a list (of integers) option."; + }; + enum = mkOption { + default = "one"; + type = types.enum [ + "one" + "two" + ]; + description = "An example of an enum option."; + }; + }; + + }; + + config = mkIf cfg.enable { + # Add changes applied by this module here. + }; +} diff --git a/modules/services/airsonic.nix b/modules/services/airsonic.nix index c797d63..b22d484 100644 --- a/modules/services/airsonic.nix +++ b/modules/services/airsonic.nix @@ -14,6 +14,7 @@ in autostart = lib.mkEnableOption (lib.mdDoc "Automatically starts Airsonic at boot."); enable = lib.mkEnableOption (lib.mdDoc "Enables Airsonic Advanced media streaming service."); home = lib.mkOption { + default = ""; type = lib.types.str; description = "Where to store Airsonic's files"; }; diff --git a/modules/services/apcupsd.nix b/modules/services/apcupsd.nix index cbc4fbd..2c3ba7a 100644 --- a/modules/services/apcupsd.nix +++ b/modules/services/apcupsd.nix @@ -10,13 +10,19 @@ in with lib; { options = { - host.services.apcupsd.enable = mkEnableOption (mdDoc "Enables apcupsd"); + host.services.apcupsd = { + enable = mkEnableOption (mdDoc "Enables apcupsd"); + configText = lib.mkOption { + type = lib.types.str; + description = "The configuration to pass to apcupsd."; + }; + }; }; config = mkIf cfg.enable { services.apcupsd = { enable = true; - configText = builtins.readFile ./etc/apcupsd.conf; + configText = cfg.configText; }; }; } diff --git a/modules/services/forgejo.nix b/modules/services/forgejo.nix index 466aee4..90cf8d0 100644 --- a/modules/services/forgejo.nix +++ b/modules/services/forgejo.nix @@ -29,6 +29,7 @@ in autostart = lib.mkEnableOption (lib.mdDoc "Automatically starts Forgejo at boot."); enable = lib.mkEnableOption (lib.mdDoc "Enables Forgejo Git hosting service."); home = lib.mkOption { + default = ""; type = lib.types.str; description = "Where to store Forgejo's files"; }; diff --git a/modules/ui/flatpak.nix b/modules/ui/flatpak.nix index f7e65de..3dac0cd 100644 --- a/modules/ui/flatpak.nix +++ b/modules/ui/flatpak.nix @@ -38,13 +38,12 @@ with lib; } ]; - # Install Flatpaks. For details, see https://github.com/gmodena/nix-flatpak + # Install base Flatpaks. For details, see https://github.com/gmodena/nix-flatpak packages = [ "com.github.tchx84.Flatseal" "md.obsidian.Obsidian" "net.waterfox.waterfox" "org.keepassxc.KeePassXC" - "org.mozilla.firefox" ]; }; diff --git a/modules/ui/gnome.nix b/modules/ui/gnome.nix index c80e899..cc6d25a 100644 --- a/modules/ui/gnome.nix +++ b/modules/ui/gnome.nix @@ -36,12 +36,10 @@ with lib; # Enable Gnome desktopManager.gnome.enable = true; - displayManager = { - gdm.enable = true; - }; + displayManager.gdm.enable = true; # Remove default packages that came with the install - excludePackages = with pkgs; [ xterm ]; + excludePackages = [ pkgs.xterm ]; }; # Install Flatpaks @@ -66,8 +64,7 @@ with lib; "org.gtk.Gtk3theme.Adwaita-dark" ]; - # Disable CUPS - not needed - printing.enable = false; + printing.enable = true; }; environment = { diff --git a/modules/users/aires/default.nix b/modules/users/aires/default.nix index d3680fe..074fc64 100644 --- a/modules/users/aires/default.nix +++ b/modules/users/aires/default.nix @@ -99,8 +99,6 @@ with lib; shellAliases = { update = "upgrade"; upgrade = "nh os boot --update --ask"; - protontricks = "flatpak run com.github.Matoking.protontricks"; - please = "sudo"; }; loginExtra = "fastfetch"; }; diff --git a/modules/users/gremlin/default.nix b/modules/users/gremlin/default.nix index 78dfc46..b54f755 100644 --- a/modules/users/gremlin/default.nix +++ b/modules/users/gremlin/default.nix @@ -108,9 +108,6 @@ with lib; file = "p10k.zsh"; } ]; - shellAliases = { - please = "sudo"; - }; }; }; };