diff --git a/flake.lock b/flake.lock index 2028006..5c9d844 100644 --- a/flake.lock +++ b/flake.lock @@ -117,11 +117,11 @@ ] }, "locked": { - "lastModified": 1714430505, - "narHash": "sha256-SSJQ/KOy8uISnoZgqDoRha7g7PFLSFP/BtMWm0wUz8Q=", + "lastModified": 1714515075, + "narHash": "sha256-azMK7aWH0eUc3IqU4Fg5rwZdB9WZBvimOGG3piqvtsY=", "owner": "nix-community", "repo": "home-manager", - "rev": "f8e6694edabe4aaa7a85aac47b43ea5d978b116d", + "rev": "6d3b6dc9222c12b951169becdf4b0592ee9576ef", "type": "github" }, "original": { diff --git a/hosts/Khanda/default.nix b/hosts/Khanda/default.nix index 1794fa1..ff1ccda 100644 --- a/hosts/Khanda/default.nix +++ b/hosts/Khanda/default.nix @@ -18,7 +18,7 @@ kdeconnect.enable = true; media.enable = true; office.enable = true; - pandoc.enable = true; + writing.enable = true; }; ui = { flatpak.enable = true; diff --git a/hosts/Shura/default.nix b/hosts/Shura/default.nix index ace13f3..88e5c34 100644 --- a/hosts/Shura/default.nix +++ b/hosts/Shura/default.nix @@ -32,8 +32,8 @@ in kdeconnect.enable = true; media.enable = true; office.enable = true; - pandoc.enable = true; recording.enable = true; + writing.enable = true; }; ui = { flatpak.enable = true; diff --git a/modules/apps/default.nix b/modules/apps/default.nix index eb6c3b5..603d066 100644 --- a/modules/apps/default.nix +++ b/modules/apps/default.nix @@ -6,7 +6,7 @@ ./kdeconnect.nix ./media.nix ./office.nix - ./pandoc.nix ./recording.nix + ./writing.nix ]; } \ No newline at end of file diff --git a/modules/apps/development.nix b/modules/apps/development.nix index ecd1e1f..148d492 100644 --- a/modules/apps/development.nix +++ b/modules/apps/development.nix @@ -26,6 +26,7 @@ with lib; kubectl kubernetes-helm kubevirt # Virtctl command-line tool + statix # Nix linting tool ]; }) ]; diff --git a/modules/apps/office.nix b/modules/apps/office.nix index d646d44..3afad93 100644 --- a/modules/apps/office.nix +++ b/modules/apps/office.nix @@ -16,13 +16,5 @@ with lib; "org.libreoffice.LibreOffice" "us.zoom.Zoom" ]; - - # Spelling and grammer checking: hosted on localhost:8081 - services.languagetool = { - enable = true; - port = 8090; - public = false; - allowOrigin = "*"; - }; }; } diff --git a/modules/apps/pandoc.nix b/modules/apps/pandoc.nix deleted file mode 100644 index f695e15..0000000 --- a/modules/apps/pandoc.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - cfg = config.host.apps.pandoc; -in -with lib; -{ - options = { - host.apps.pandoc.enable = mkEnableOption (mdDoc "Enables pandoc"); - }; - - config = mkIf cfg.enable { - environment.systemPackages = with pkgs; [ - haskellPackages.pandoc - haskellPackages.pandoc-cli - haskellPackages.pandoc-crossref - texliveSmall - ]; - }; -} \ No newline at end of file diff --git a/modules/apps/writing.nix b/modules/apps/writing.nix new file mode 100644 index 0000000..475ebd3 --- /dev/null +++ b/modules/apps/writing.nix @@ -0,0 +1,29 @@ +{ pkgs, config, lib, ... }: + +let + cfg = config.host.apps.writing; +in +with lib; +{ + options = { + host.apps.writing.enable = mkEnableOption (mdDoc "Enables writing and editing tools"); + }; + + config = mkIf cfg.enable { + # Install packages for building ebooks + environment.systemPackages = with pkgs; [ + haskellPackages.pandoc + haskellPackages.pandoc-cli + haskellPackages.pandoc-crossref + texliveSmall + ]; + + # Spelling and grammer checking: hosted on localhost:8081 + services.languagetool = { + enable = true; + port = 8090; + public = false; + allowOrigin = "*"; + }; + }; +} \ No newline at end of file diff --git a/modules/base/default.nix b/modules/base/default.nix index b3dfa38..aa0e31c 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -4,6 +4,7 @@ ./bootloader.nix ./network.nix ./nix.nix + ./programs.nix ./shell.nix ./system.nix ]; diff --git a/modules/base/network.nix b/modules/base/network.nix index 4e40820..8b9b05b 100644 --- a/modules/base/network.nix +++ b/modules/base/network.nix @@ -5,8 +5,6 @@ _: { # Enable firewall nftables.enable = true; - firewall = { - enable = true; - }; + firewall.enable = true; }; } \ No newline at end of file diff --git a/modules/base/programs.nix b/modules/base/programs.nix new file mode 100644 index 0000000..bf5db31 --- /dev/null +++ b/modules/base/programs.nix @@ -0,0 +1,29 @@ +# Set up program defaults +{ config, ... }: { + # Set up base apps + programs = { + direnv.enable = true; + + nano = { + enable = true; + syntaxHighlight = true; + nanorc = '' + set linenumbers + set tabsize 4 + set softwrap + ''; + }; + + nh = { + enable = true; + flake = "${config.users.users.aires.home}/Development/nix-configuration"; + + # Alternative garbage collection system to nix.gc.automatic + clean = { + enable = true; + dates = "daily"; + extraArgs = "--keep-since 7d --keep 10"; # Keep the last 10 entries + }; + }; + }; +} \ No newline at end of file diff --git a/modules/base/system.nix b/modules/base/system.nix index ce4f3df..ed03924 100644 --- a/modules/base/system.nix +++ b/modules/base/system.nix @@ -1,121 +1,54 @@ -{ pkgs, config, lib, inputs, ... }: - # System options -let - cfg = config.host.system; -in -with lib; -{ - config = { - # Set up the environment - environment = { - # Install base packages - systemPackages = with pkgs; [ - bash - dconf # Needed to fix an issue with Home-manager. See https://github.com/nix-community/home-manager/issues/3113 - git - home-manager - nano - p7zip - fastfetch - nh # Nix Helper: https://github.com/viperML/nh - ]; +{ pkgs, config, ... }: { + # Set up the environment + environment = { + # Install base packages + systemPackages = with pkgs; [ + bash + dconf # Needed to fix an issue with Home-manager. See https://github.com/nix-community/home-manager/issues/3113 + direnv + git + home-manager + nano + p7zip + fastfetch + nh # Nix Helper: https://github.com/viperML/nh + ]; - variables = { - EDITOR = "nano"; # Set default editor to nano - }; - - # System configuration file overrides - etc = { - # Reduce systemd logout time to 30s - "systemd/system.conf.d/10-reduce-logout-wait-time.conf" = { - text = '' - [Manager] - DefaultTimeoutStopSec=30s - ''; - }; - }; + variables = { + EDITOR = "nano"; # Set default editor to nano }; + }; - # Configure automatic updates - system = { - # Enable automatic updates - autoUpgrade = { - enable = true; - flake = "${config.users.users.aires.home}/Development/nix-configuration"; - dates = "daily"; - allowReboot = false; - operation = "boot"; # Don't switch, just create a boot entry - }; + # Configure automatic updates + system.autoUpgrade = { + enable = true; + flake = "${config.users.users.aires.home}/Development/nix-configuration"; + dates = "daily"; + allowReboot = false; + operation = "boot"; # Don't switch, just create a boot entry + }; + + # Enable fwupd (firmware updater) + services.fwupd.enable = true; + + # Set your time zone. + time.timeZone = "America/New_York"; + + # Select internationalisation properties. + i18n = { + defaultLocale = "en_US.UTF-8"; + + extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; }; - - # Set your time zone. - time.timeZone = "America/New_York"; - - # Select internationalisation properties. - i18n = { - defaultLocale = "en_US.UTF-8"; - - extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; - }; - }; - - # Set up base apps - programs = { - direnv.enable = true; - - nano = { - enable = true; - syntaxHighlight = true; - nanorc = '' - set linenumbers - set tabsize 4 - set softwrap - ''; - }; - - nh = { - enable = true; - flake = "/home/aires/Development/nix-configuration"; - - # Alternative garbage collection system to nix.gc.automatic - clean = { - enable = true; - dates = "daily"; - extraArgs = "--keep-since 7d --keep 10"; # Keep the last 10 entries - }; - }; - }; - - services = { - # Scrub BTRFS partitions if the root partition is btrfs - btrfs.autoScrub = lib.mkIf (config.fileSystems."/".fsType == "btrfs") { - enable = true; - interval = "weekly"; - fileSystems = [ "/" ]; - }; - - # Enable fwupd (firmware updater) - fwupd.enable = true; - - # Allow systemd user services to keep running after the user has logged out - logind.killUserProcesses = false; - - # Enable SMART monitoring - smartd = { - enable = true; - autodetect = true; - notifications.wall.enable = true; - }; - }; }; } diff --git a/modules/roles/server.nix b/modules/roles/server.nix index 1651d7b..f60d3c0 100644 --- a/modules/roles/server.nix +++ b/modules/roles/server.nix @@ -8,7 +8,6 @@ in config = mkIf (role == "server") { environment.systemPackages = with pkgs; [ - direnv htop ]; }; diff --git a/modules/roles/workstation.nix b/modules/roles/workstation.nix index 53ad625..54a2ff8 100644 --- a/modules/roles/workstation.nix +++ b/modules/roles/workstation.nix @@ -14,11 +14,6 @@ in flatpak.enable = true; }; - environment.systemPackages = with pkgs; [ - direnv - statix # Nix linting tool - ]; - boot = { # Enable Plymouth plymouth.enable = true; diff --git a/modules/services/btrfs.nix b/modules/services/btrfs.nix new file mode 100644 index 0000000..6f38114 --- /dev/null +++ b/modules/services/btrfs.nix @@ -0,0 +1,9 @@ +# Services to run on BTRFS filesystems. +# Only run if the root partition is BTRFS. +{ config, lib, ... }: { + services.btrfs.autoScrub = lib.mkIf (config.fileSystems."/".fsType == "btrfs") { + enable = true; + interval = "weekly"; + fileSystems = [ "/" ]; + }; +} \ No newline at end of file diff --git a/modules/services/default.nix b/modules/services/default.nix index e0a4a78..aad0471 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -1,8 +1,11 @@ { ... }: { imports = [ ./apcupsd.nix + ./btrfs.nix ./duplicacy-web.nix ./k3s.nix ./msmtp.nix + ./smartd.nix + ./systemd.nix ]; } \ No newline at end of file diff --git a/modules/services/smartd.nix b/modules/services/smartd.nix new file mode 100644 index 0000000..d8d7092 --- /dev/null +++ b/modules/services/smartd.nix @@ -0,0 +1,8 @@ +# Configure SMART monitoring +_: { + services.smartd = { + enable = true; + autodetect = true; + notifications.wall.enable = true; + }; +} \ No newline at end of file diff --git a/modules/services/systemd.nix b/modules/services/systemd.nix new file mode 100644 index 0000000..de661e9 --- /dev/null +++ b/modules/services/systemd.nix @@ -0,0 +1,17 @@ +# Configure systemD +_: { + services = { + # Allow systemd user services to keep running after the user has logged out + logind.killUserProcesses = false; + }; + + # Reduce systemd logout time to 30s + environment.etc = { + "systemd/system.conf.d/10-reduce-logout-wait-time.conf" = { + text = '' + [Manager] + DefaultTimeoutStopSec=30s + ''; + }; + }; +} \ No newline at end of file