diff --git a/flake.nix b/flake.nix index 9044be5..18a923a 100755 --- a/flake.nix +++ b/flake.nix @@ -75,11 +75,9 @@ ./profiles/user0 ./profiles/user1 config.nixosModules.desktop - config.nixosModules.hyprland - config.nixosModules.wayland - config.nixosModules.personal - config.nixosModules.shared + config.nixosModules.core config.nixosModules.sops + config.nixosModules.system inputs.home-manager.nixosModules.home-manager inputs.lix-module.nixosModules.default inputs.nur.modules.nixos.default @@ -89,10 +87,9 @@ ./systems/fallaryn ./profiles/user2 config.nixosModules.fallaryn - config.nixosModules.personal - config.nixosModules.plasma - config.nixosModules.shared + config.nixosModules.core config.nixosModules.sops + config.nixosModules.system inputs.home-manager.nixosModules.home-manager inputs.lix-module.nixosModules.default inputs.sops-nix.nixosModules.sops @@ -101,9 +98,10 @@ ./systems/laptop ./profiles/user0 ./profiles/user1 - config.nixosModules.personal - config.nixosModules.shared + config.nixosModules.laptop + config.nixosModules.core config.nixosModules.sops + config.nixosModules.system inputs.home-manager.nixosModules.home-manager inputs.lix-module.nixosModules.default inputs.nur.modules.nixos.default @@ -112,9 +110,9 @@ bartholomew = inputs.self.lib.mkLinuxSystem [ ./systems/bartholomew ./profiles/user1 - config.nixosModules.gnome - config.nixosModules.personal - config.nixosModules.shared + config.nixosModules.laptop + config.nixosModules.core + config.nixosModules.system inputs.home-manager.nixosModules.home-manager inputs.lix-module.nixosModules.default ]; @@ -122,8 +120,9 @@ ./systems/server ./profiles/user0 config.nixosModules.server - config.nixosModules.shared + config.nixosModules.core config.nixosModules.sops + config.nixosModules.system inputs.home-manager.nixosModules.home-manager inputs.lix-module.nixosModules.default inputs.ngipkgs.nixosModules."services.peertube" diff --git a/nixos/default.nix b/nixos/default.nix old mode 100755 new mode 100644 index 2a73934..23c07fe --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,66 +1,38 @@ let - modulesPath = ./modules; - moduleImport = - path: nameTransform: + collectDirs = + path: + let + content = builtins.readDir path; + subdirs = builtins.filter (name: content.${name} == "directory") (builtins.attrNames content); + buildPath = name: path + "/${name}"; + + thisDirs = map buildPath subdirs; + subDirs = builtins.concatMap collectDirs thisDirs; + in + [ path ] ++ subDirs; + + directoryImport = + path: builtins.listToAttrs ( - map - (name: { - name = nameTransform name; - value = import (path + "/${name}"); - }) - ( - builtins.filter ( - name: (builtins.readDir path).${name} == "regular" && builtins.match ".*\\.nix$" name != null - ) (builtins.attrNames (builtins.readDir path)) - ) + map (dir: { + name = baseNameOf (toString dir); + value = import dir; + }) (collectDirs path) ); - modules = - moduleImport modulesPath (name: builtins.replaceStrings [ ".nix" ] [ "" ] name) - // ( - path: - builtins.listToAttrs ( - map - (name: { - name = name; - value = import (path + "/${name}"); - }) - ( - builtins.filter (name: (builtins.readDir path).${name} == "directory") ( - builtins.attrNames (builtins.readDir path) - ) - ) - ) - ) - modulesPath; + + modules = directoryImport ./.; in { flake.nixosModules = { - personal = { - imports = builtins.attrValues { - inherit (modules) - android - audio - bluetooth - corectrl - dconf - disks - firejail - flatpak - fonts - printing - steam - sysstat - virtualization - ; - }; - }; - desktop = { imports = builtins.attrValues { inherit (modules) + hypr + wayland mullvad syncthing ollama + xserver ; }; }; @@ -68,48 +40,18 @@ in fallaryn = { imports = builtins.attrValues { inherit (modules) + plasma + sddm tablet ; }; }; - plasma = { - imports = builtins.attrValues { - inherit (modules) - plasma - sddm - ; - }; - }; - - gnome = { + laptop = { imports = builtins.attrValues { inherit (modules) gnome - ; - }; - }; - - hyprland = { - imports = builtins.attrValues { - inherit (modules) - hyprland - ; - }; - }; - - river = { - imports = builtins.attrValues { - inherit (modules) - river - ; - }; - }; - - wayland = { - imports = builtins.attrValues { - inherit (modules) - wayland + xserver ; }; }; @@ -117,7 +59,18 @@ in server = { imports = builtins.attrValues { inherit (modules) - services + acme + caddy + jellyfin + logrotate + mastodon + minecraft + ollama + website + postgresql + samba + vaultwarden + forgejo ; }; }; @@ -130,20 +83,19 @@ in }; }; - shared = { + system = { imports = builtins.attrValues { inherit (modules) - accounts - doas - environment - gvfs - home-manager - locale - nh - nix - rsyncd - ssh - system + hardware + programs + ; + }; + }; + + core = { + imports = builtins.attrValues { + inherit (modules) + core xserver ; }; diff --git a/nixos/modules/accounts.nix b/nixos/modules/core/accounts/default.nix similarity index 100% rename from nixos/modules/accounts.nix rename to nixos/modules/core/accounts/default.nix diff --git a/nixos/modules/core/default.nix b/nixos/modules/core/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/core/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/doas.nix b/nixos/modules/core/doas/default.nix similarity index 100% rename from nixos/modules/doas.nix rename to nixos/modules/core/doas/default.nix diff --git a/nixos/modules/environment.nix b/nixos/modules/core/environment/default.nix similarity index 100% rename from nixos/modules/environment.nix rename to nixos/modules/core/environment/default.nix diff --git a/nixos/modules/flatpak.nix b/nixos/modules/core/flatpak/default.nix similarity index 100% rename from nixos/modules/flatpak.nix rename to nixos/modules/core/flatpak/default.nix diff --git a/nixos/modules/fonts.nix b/nixos/modules/core/fonts/default.nix similarity index 100% rename from nixos/modules/fonts.nix rename to nixos/modules/core/fonts/default.nix diff --git a/nixos/modules/home-manager.nix b/nixos/modules/core/homeManager/default.nix similarity index 91% rename from nixos/modules/home-manager.nix rename to nixos/modules/core/homeManager/default.nix index f0c3cda..4ac060a 100755 --- a/nixos/modules/home-manager.nix +++ b/nixos/modules/core/homeManager/default.nix @@ -1,4 +1,5 @@ -{flake, ...}: { +{ flake, ... }: +{ home-manager = { useGlobalPkgs = true; useUserPackages = true; diff --git a/nixos/modules/core/locale/default.nix b/nixos/modules/core/locale/default.nix new file mode 100755 index 0000000..2fcad5c --- /dev/null +++ b/nixos/modules/core/locale/default.nix @@ -0,0 +1,30 @@ +{ + time.timeZone = "America/Winnipeg"; + + i18n = + let + locale = "en_CA.UTF-8"; + in + { + defaultLocale = locale; + + extraLocaleSettings = builtins.listToAttrs ( + map + (option: { + name = option; + value = locale; + }) + [ + "LC_ADDRESS" + "LC_IDENTIFICATION" + "LC_MEASUREMENT" + "LC_MONETARY" + "LC_NAME" + "LC_NUMERIC" + "LC_PAPER" + "LC_TELEPHONE" + "LC_TIME" + ] + ); + }; +} diff --git a/nixos/modules/nh.nix b/nixos/modules/core/nh/default.nix similarity index 100% rename from nixos/modules/nh.nix rename to nixos/modules/core/nh/default.nix diff --git a/nixos/modules/nix.nix b/nixos/modules/core/nix/default.nix similarity index 100% rename from nixos/modules/nix.nix rename to nixos/modules/core/nix/default.nix diff --git a/nixos/modules/rsyncd.nix b/nixos/modules/core/rsync/default.nix similarity index 100% rename from nixos/modules/rsyncd.nix rename to nixos/modules/core/rsync/default.nix diff --git a/nixos/modules/ssh.nix b/nixos/modules/core/ssh/default.nix similarity index 100% rename from nixos/modules/ssh.nix rename to nixos/modules/core/ssh/default.nix diff --git a/nixos/modules/sysstat.nix b/nixos/modules/core/sysStat/default.nix similarity index 100% rename from nixos/modules/sysstat.nix rename to nixos/modules/core/sysStat/default.nix diff --git a/nixos/modules/core/system/default.nix b/nixos/modules/core/system/default.nix new file mode 100755 index 0000000..958608a --- /dev/null +++ b/nixos/modules/core/system/default.nix @@ -0,0 +1 @@ +_: { } diff --git a/nixos/modules/dconf.nix b/nixos/modules/dconf.nix deleted file mode 100755 index 5424db3..0000000 --- a/nixos/modules/dconf.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - programs.dconf.enable = true; -} diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/desktop/default.nix b/nixos/modules/desktop/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/desktop/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/gnome.nix b/nixos/modules/desktop/gnome/default.nix similarity index 95% rename from nixos/modules/gnome.nix rename to nixos/modules/desktop/gnome/default.nix index bece9b8..a91c293 100755 --- a/nixos/modules/gnome.nix +++ b/nixos/modules/desktop/gnome/default.nix @@ -20,6 +20,7 @@ gnome-settings-daemon ; }; + gvfs.enable = true; }; environment = { variables = { @@ -50,4 +51,5 @@ ; }; }; + programs.dconf.enable = true; } diff --git a/nixos/modules/desktop/hypr/default.nix b/nixos/modules/desktop/hypr/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/desktop/hypr/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/hyprland/hypridle.nix b/nixos/modules/desktop/hypr/idle/default.nix similarity index 100% rename from nixos/modules/hyprland/hypridle.nix rename to nixos/modules/desktop/hypr/idle/default.nix diff --git a/nixos/modules/hyprland/hyprland.nix b/nixos/modules/desktop/hypr/land/default.nix similarity index 100% rename from nixos/modules/hyprland/hyprland.nix rename to nixos/modules/desktop/hypr/land/default.nix diff --git a/nixos/modules/plasma.nix b/nixos/modules/desktop/plasma/default.nix similarity index 82% rename from nixos/modules/plasma.nix rename to nixos/modules/desktop/plasma/default.nix index dc86c87..fddd69a 100755 --- a/nixos/modules/plasma.nix +++ b/nixos/modules/desktop/plasma/default.nix @@ -1,10 +1,10 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ services = { desktopManager.plasma6.enable = true; }; environment.plasma6.excludePackages = builtins.attrValues { - inherit - (pkgs.kdePackages) + inherit (pkgs.kdePackages) plasma-browser-integration konsole kate diff --git a/nixos/modules/river.nix b/nixos/modules/desktop/river/default.nix similarity index 100% rename from nixos/modules/river.nix rename to nixos/modules/desktop/river/default.nix diff --git a/nixos/modules/sddm.nix b/nixos/modules/desktop/sddm/default.nix similarity index 100% rename from nixos/modules/sddm.nix rename to nixos/modules/desktop/sddm/default.nix diff --git a/nixos/modules/desktop/wayland/default.nix b/nixos/modules/desktop/wayland/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/desktop/wayland/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/wayland/geoclue2.nix b/nixos/modules/desktop/wayland/geoclue2/default.nix similarity index 100% rename from nixos/modules/wayland/geoclue2.nix rename to nixos/modules/desktop/wayland/geoclue2/default.nix diff --git a/nixos/modules/wayland/greetd.nix b/nixos/modules/desktop/wayland/greetd/default.nix similarity index 100% rename from nixos/modules/wayland/greetd.nix rename to nixos/modules/desktop/wayland/greetd/default.nix diff --git a/nixos/modules/wayland/network.nix b/nixos/modules/desktop/wayland/network/default.nix similarity index 100% rename from nixos/modules/wayland/network.nix rename to nixos/modules/desktop/wayland/network/default.nix diff --git a/nixos/modules/wayland/regreet.nix b/nixos/modules/desktop/wayland/regreet/default.nix similarity index 100% rename from nixos/modules/wayland/regreet.nix rename to nixos/modules/desktop/wayland/regreet/default.nix diff --git a/nixos/modules/wayland/swaylock.nix b/nixos/modules/desktop/wayland/swaylock/default.nix similarity index 100% rename from nixos/modules/wayland/swaylock.nix rename to nixos/modules/desktop/wayland/swaylock/default.nix diff --git a/nixos/modules/wayland/thunar.nix b/nixos/modules/desktop/wayland/thunar/default.nix similarity index 100% rename from nixos/modules/wayland/thunar.nix rename to nixos/modules/desktop/wayland/thunar/default.nix diff --git a/nixos/modules/wayland/wayland.nix b/nixos/modules/desktop/wayland/wayland/default.nix similarity index 100% rename from nixos/modules/wayland/wayland.nix rename to nixos/modules/desktop/wayland/wayland/default.nix diff --git a/nixos/modules/xserver.nix b/nixos/modules/desktop/xserver/default.nix similarity index 100% rename from nixos/modules/xserver.nix rename to nixos/modules/desktop/xserver/default.nix diff --git a/nixos/modules/gvfs.nix b/nixos/modules/gvfs.nix deleted file mode 100755 index b045ed2..0000000 --- a/nixos/modules/gvfs.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - services.gvfs.enable = true; -} diff --git a/nixos/modules/android.nix b/nixos/modules/hardware/android/default.nix similarity index 80% rename from nixos/modules/android.nix rename to nixos/modules/hardware/android/default.nix index 32c2d19..6384ddb 100755 --- a/nixos/modules/android.nix +++ b/nixos/modules/hardware/android/default.nix @@ -1,11 +1,11 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ programs = { adb.enable = true; droidcam.enable = true; }; services.udev.packages = builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) android-udev-rules ; }; diff --git a/nixos/modules/audio.nix b/nixos/modules/hardware/audio/default.nix similarity index 100% rename from nixos/modules/audio.nix rename to nixos/modules/hardware/audio/default.nix diff --git a/nixos/modules/bluetooth.nix b/nixos/modules/hardware/bluetooth/default.nix similarity index 100% rename from nixos/modules/bluetooth.nix rename to nixos/modules/hardware/bluetooth/default.nix diff --git a/nixos/modules/hardware/default.nix b/nixos/modules/hardware/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/hardware/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/printing.nix b/nixos/modules/hardware/printing/default.nix similarity index 100% rename from nixos/modules/printing.nix rename to nixos/modules/hardware/printing/default.nix diff --git a/nixos/modules/tablet.nix b/nixos/modules/hardware/tablet/default.nix similarity index 100% rename from nixos/modules/tablet.nix rename to nixos/modules/hardware/tablet/default.nix diff --git a/nixos/modules/hyprland/default.nix b/nixos/modules/hyprland/default.nix deleted file mode 100755 index 96acb58..0000000 --- a/nixos/modules/hyprland/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = map (file: ./${file}.nix) [ - "hypridle" - "hyprland" - ]; -} diff --git a/nixos/modules/locale.nix b/nixos/modules/locale.nix deleted file mode 100755 index 07b202f..0000000 --- a/nixos/modules/locale.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - time.timeZone = "America/Winnipeg"; - - i18n = let - locale = "en_CA.UTF-8"; - in { - defaultLocale = locale; - - extraLocaleSettings = - builtins.listToAttrs - (map (option: { - name = option; - value = locale; - }) - [ - "LC_ADDRESS" - "LC_IDENTIFICATION" - "LC_MEASUREMENT" - "LC_MONETARY" - "LC_NAME" - "LC_NUMERIC" - "LC_PAPER" - "LC_TELEPHONE" - "LC_TIME" - ]); - }; -} diff --git a/nixos/modules/ollama.nix b/nixos/modules/ollama.nix deleted file mode 100755 index 48eff9a..0000000 --- a/nixos/modules/ollama.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ - flake, - pkgs, - ... -}: -let - inherit (flake.config.services.instances) - ollama - web - ; - service = ollama; - localhost = web.localhost.address0; -in -{ - services = { - ollama = { - acceleration = "rocm"; - package = pkgs.ollama.override { - config = { - rocmSupport = true; - cudaSupport = false; - }; - }; - enable = true; - group = service.name; - host = "http://${localhost}"; - models = service.paths.path1; - user = service.name; - }; - open-webui = { - enable = true; - host = localhost; - port = service.ports.port0; - environment = { - ENABLE_OLLAMA_API = "True"; - ANONYMIZED_TELEMETRY = "False"; - DO_NOT_TRACK = "True"; - SCARF_NO_ANALYTICS = "True"; - OLLAMA_BASE_URL = "http://${localhost}:${toString service.ports.port1}"; - WEBUI_AUTH = "True"; - }; - }; - }; - - users.users.${service.name}.extraGroups = [ - "users" - ]; - - systemd.tmpfiles.rules = [ - "Z ${service.paths.path1} 0777 ${service.name} ${service.name} -" - ]; - - networking = { - firewall = { - allowedTCPPorts = [ - # 8080 - service.ports.port0 - service.ports.port1 - ]; - }; - }; -} diff --git a/nixos/modules/corectrl.nix b/nixos/modules/programs/coreCtrl/default.nix similarity index 90% rename from nixos/modules/corectrl.nix rename to nixos/modules/programs/coreCtrl/default.nix index 6150119..63fbcfb 100755 --- a/nixos/modules/corectrl.nix +++ b/nixos/modules/programs/coreCtrl/default.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ programs.corectrl = { enable = true; package = pkgs.corectrl; diff --git a/nixos/modules/programs/default.nix b/nixos/modules/programs/default.nix new file mode 100755 index 0000000..f106bc5 --- /dev/null +++ b/nixos/modules/programs/default.nix @@ -0,0 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in +{ + imports = importList; +} diff --git a/nixos/modules/disks.nix b/nixos/modules/programs/disks/default.nix similarity index 100% rename from nixos/modules/disks.nix rename to nixos/modules/programs/disks/default.nix diff --git a/nixos/modules/firejail.nix b/nixos/modules/programs/firejail/default.nix similarity index 100% rename from nixos/modules/firejail.nix rename to nixos/modules/programs/firejail/default.nix diff --git a/nixos/modules/steam.nix b/nixos/modules/programs/steam/default.nix similarity index 85% rename from nixos/modules/steam.nix rename to nixos/modules/programs/steam/default.nix index ffe6607..b3fee58 100755 --- a/nixos/modules/steam.nix +++ b/nixos/modules/programs/steam/default.nix @@ -1,12 +1,12 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ programs = { steam = { enable = true; remotePlay.openFirewall = true; dedicatedServer.openFirewall = true; extraPackages = builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) curl ; }; diff --git a/nixos/modules/virtualization.nix b/nixos/modules/programs/virtManager/default.nix similarity index 100% rename from nixos/modules/virtualization.nix rename to nixos/modules/programs/virtManager/default.nix diff --git a/nixos/modules/services/acme.nix b/nixos/modules/services/acme/default.nix similarity index 100% rename from nixos/modules/services/acme.nix rename to nixos/modules/services/acme/default.nix diff --git a/nixos/modules/services/caddy.nix b/nixos/modules/services/caddy/default.nix similarity index 88% rename from nixos/modules/services/caddy.nix rename to nixos/modules/services/caddy/default.nix index 97cd08c..00ac4a8 100755 --- a/nixos/modules/services/caddy.nix +++ b/nixos/modules/services/caddy/default.nix @@ -1,6 +1,6 @@ -{flake, ...}: let - inherit - (flake.config.services.instances) +{ flake, ... }: +let + inherit (flake.config.services.instances) caddy web ; @@ -8,7 +8,8 @@ domain0 = web.domains.url0; service = caddy; -in { +in +{ services.caddy = { enable = true; virtualHosts = { diff --git a/nixos/modules/services/default.nix b/nixos/modules/services/default.nix index aa0e1e8..f106bc5 100755 --- a/nixos/modules/services/default.nix +++ b/nixos/modules/services/default.nix @@ -1,22 +1,10 @@ +let + content = builtins.readDir ./.; + + dirContent = builtins.filter (n: content.${n} == "directory") (builtins.attrNames content); + + importList = map (name: ./. + "/${name}") dirContent; +in { - imports = - (map (folder: ./${folder}) [ - "mastodon" - ]) - ++ (map (file: ./${file}.nix) [ - "acme" - "caddy" - "jellyfin" - "logrotate" - "minecraft" - "ollama" - "upRootNutrition" - # "peertube" - "postgresql" - # "owncast" - "samba" - "vaultwarden" - "forgejo" - # "nextcloud" - ]); + imports = importList; } diff --git a/nixos/modules/services/forgejo.nix b/nixos/modules/services/forgejo/default.nix similarity index 100% rename from nixos/modules/services/forgejo.nix rename to nixos/modules/services/forgejo/default.nix diff --git a/nixos/modules/hledger.nix b/nixos/modules/services/hLedger/default.nix similarity index 100% rename from nixos/modules/hledger.nix rename to nixos/modules/services/hLedger/default.nix diff --git a/nixos/modules/services/jellyfin.nix b/nixos/modules/services/jellyfin/default.nix similarity index 71% rename from nixos/modules/services/jellyfin.nix rename to nixos/modules/services/jellyfin/default.nix index 8153d30..2cf6cb3 100755 --- a/nixos/modules/services/jellyfin.nix +++ b/nixos/modules/services/jellyfin/default.nix @@ -1,21 +1,20 @@ -{flake, ...}: let - inherit - (flake.config.people) +{ flake, ... }: +let + inherit (flake.config.people) user0 ; - inherit - (flake.config.machines.devices) + inherit (flake.config.machines.devices) server ; - inherit - (flake.config.services.instances) + inherit (flake.config.services.instances) jellyfin web ; service = jellyfin; localhost = web.localhost.address0; host = "${service.subdomain}.${web.domains.url0}"; -in { +in +{ services = { jellyfin = { enable = true; @@ -42,28 +41,26 @@ in { }; }; - fileSystems = let - settings = { - fsType = "none"; - options = [ - "bind" - ]; - depends = [ - server.storage0.mount - ]; - }; - in { - "/var/lib/${service.name}" = - { + fileSystems = + let + settings = { + fsType = "none"; + options = [ + "bind" + ]; + depends = [ + server.storage0.mount + ]; + }; + in + { + "/var/lib/${service.name}" = { device = service.paths.path0; - } - // settings; - "/var/cache/${service.name}" = - { + } // settings; + "/var/cache/${service.name}" = { device = "${service.paths.path0}/cache"; - } - // settings; - }; + } // settings; + }; systemd.tmpfiles.rules = [ "Z ${service.paths.path0} 0755 ${user0} ${service.name} -" diff --git a/nixos/modules/services/logrotate.nix b/nixos/modules/services/logrotate/default.nix similarity index 100% rename from nixos/modules/services/logrotate.nix rename to nixos/modules/services/logrotate/default.nix diff --git a/nixos/modules/services/mastodon/chars.patch b/nixos/modules/services/mastodon/config/chars.patch similarity index 100% rename from nixos/modules/services/mastodon/chars.patch rename to nixos/modules/services/mastodon/config/chars.patch diff --git a/nixos/modules/services/mastodon/twitter.txt b/nixos/modules/services/mastodon/config/twitter.txt similarity index 100% rename from nixos/modules/services/mastodon/twitter.txt rename to nixos/modules/services/mastodon/config/twitter.txt diff --git a/nixos/modules/services/minecraft.nix b/nixos/modules/services/minecraft/default.nix similarity index 79% rename from nixos/modules/services/minecraft.nix rename to nixos/modules/services/minecraft/default.nix index 462417a..9ce53bf 100755 --- a/nixos/modules/services/minecraft.nix +++ b/nixos/modules/services/minecraft/default.nix @@ -2,17 +2,17 @@ config, flake, ... -}: let - inherit - (flake.config.machines.devices) +}: +let + inherit (flake.config.machines.devices) server ; - inherit - (flake.config.services.instances) + inherit (flake.config.services.instances) minecraft ; service = minecraft; -in { +in +{ services = { minecraft-server = { enable = true; @@ -55,24 +55,26 @@ in { }; }; }; - sops = let - sopsPath = secret: { - path = "${service.sops.path0}/${service.name}-${secret}"; - owner = service.name; - mode = "600"; + sops = + let + sopsPath = secret: { + path = "${service.sops.path0}/${service.name}-${secret}"; + owner = service.name; + mode = "600"; + }; + in + { + secrets = builtins.listToAttrs ( + map + (secret: { + name = "${service.name}-${secret}"; + value = sopsPath secret; + }) + [ + "pass" + ] + ); }; - in { - secrets = builtins.listToAttrs ( - map - (secret: { - name = "${service.name}-${secret}"; - value = sopsPath secret; - }) - [ - "pass" - ] - ); - }; fileSystems."/var/lib/${service.name}" = { device = service.paths.path0; diff --git a/nixos/modules/mullvad.nix b/nixos/modules/services/mullvad/default.nix similarity index 100% rename from nixos/modules/mullvad.nix rename to nixos/modules/services/mullvad/default.nix diff --git a/nixos/modules/services/nextcloud.nix b/nixos/modules/services/nextcloud/default.nix similarity index 77% rename from nixos/modules/services/nextcloud.nix rename to nixos/modules/services/nextcloud/default.nix index dc9fa3d..4e82ba5 100755 --- a/nixos/modules/services/nextcloud.nix +++ b/nixos/modules/services/nextcloud/default.nix @@ -3,21 +3,18 @@ config, pkgs, ... -}: let - inherit - (flake.config.people) +}: +let + inherit (flake.config.people) user0 ; - inherit - (flake.config.people.users.${user0}) + inherit (flake.config.people.users.${user0}) name ; - inherit - (flake.config.machines.devices) + inherit (flake.config.machines.devices) server ; - inherit - (flake.config.services.instances) + inherit (flake.config.services.instances) nextcloud nginx web @@ -25,7 +22,8 @@ service = nextcloud; localhost = web.localhost.address0; host = "${service.subdomain}.${web.domains.url1}"; -in { +in +{ services = { nextcloud = { appstoreEnable = true; @@ -38,8 +36,7 @@ in { phpOptions."opcache.interned_strings_buffer" = "24"; extraAppsEnable = true; extraApps = { - inherit - (config.services.service.package.packages.apps) + inherit (config.services.service.package.packages.apps) contacts calendar ; @@ -88,24 +85,26 @@ in { }; }; - sops = let - sopsPath = secret: { - path = "${service.sops.path0}/${service.name}-${secret}"; - owner = service.name; - mode = "600"; + sops = + let + sopsPath = secret: { + path = "${service.sops.path0}/${service.name}-${secret}"; + owner = service.name; + mode = "600"; + }; + in + { + secrets = builtins.listToAttrs ( + map + (secret: { + name = "${service.name}-${secret}"; + value = sopsPath secret; + }) + [ + "pass" + ] + ); }; - in { - secrets = builtins.listToAttrs ( - map - (secret: { - name = "${service.name}-${secret}"; - value = sopsPath secret; - }) - [ - "pass" - ] - ); - }; fileSystems."/var/lib/${service.name}" = { device = service.paths.path0; diff --git a/nixos/modules/services/ollama.nix b/nixos/modules/services/ollama.nix deleted file mode 100755 index 48086c9..0000000 --- a/nixos/modules/services/ollama.nix +++ /dev/null @@ -1,75 +0,0 @@ -{flake, ...}: let - inherit - (flake.config.machines.devices) - server - ; - inherit - (flake.config.services.instances) - ollama - web - ; - service = ollama; - localhost = web.localhost.address0; - host = "${service.subdomain}.${web.domains.url0}"; -in { - services = { - ollama = { - acceleration = false; - enable = true; - group = service.name; - host = "http://${localhost}"; - port = service.ports.port1; - user = service.name; - }; - - open-webui = { - enable = true; - host = localhost; - port = service.ports.port0; - environment = { - ENABLE_OLLAMA_API = "True"; - ANONYMIZED_TELEMETRY = "False"; - DO_NOT_TRACK = "True"; - SCARF_NO_ANALYTICS = "True"; - OLLAMA_BASE_URL = "http://${localhost}:${toString service.ports.port1}"; - WEBUI_AUTH = "True"; - }; - }; - - caddy = { - virtualHosts = { - ${host} = { - extraConfig = '' - reverse_proxy ${localhost}:${toString service.ports.port0} - - tls ${service.ssl.cert} ${service.ssl.key} - ''; - }; - }; - }; - }; - - fileSystems."/var/lib/${service.name}" = { - device = service.paths.path0; - fsType = "none"; - options = [ - "bind" - ]; - depends = [ - server.storage0.mount - ]; - }; - - systemd.tmpfiles.rules = [ - "Z ${service.paths.path0} 0755 ${service.name} ${service.name} -" - ]; - - networking = { - firewall = { - allowedTCPPorts = [ - service.ports.port0 - service.ports.port1 - ]; - }; - }; -} diff --git a/nixos/modules/services/ollama/default.nix b/nixos/modules/services/ollama/default.nix new file mode 100755 index 0000000..3c4913a --- /dev/null +++ b/nixos/modules/services/ollama/default.nix @@ -0,0 +1,117 @@ +{ + flake, + config, + pkgs, + ... +}: +let + inherit (flake.config.machines.devices) + desktop + server + ; + inherit (flake.config.services.instances) + ollama + web + ; + service = ollama; + localhost = web.localhost.address0; + hostname = config.networking.hostName; + host = "${service.subdomain}.${web.domains.url0}"; + + caddyLogic = + if hostname == server.name then + { + caddy = { + virtualHosts = { + ${host} = { + extraConfig = '' + reverse_proxy ${localhost}:${toString service.ports.port0} + + tls ${service.ssl.cert} ${service.ssl.key} + ''; + }; + }; + }; + } + else + { }; + + mountLogic = + if hostname == server.name then + { + "/var/lib/${service.name}" = { + device = service.paths.path0; + fsType = "none"; + options = [ + "bind" + ]; + depends = [ + server.storage0.mount + ]; + }; + } + else + { }; +in +{ + services = { + ollama = + { + enable = true; + group = service.name; + host = "http://${localhost}"; + user = service.name; + } + // ( + if hostname == desktop.name then + { + acceleration = "rocm"; + package = pkgs.ollama.override { + config = { + rocmSupport = true; + cudaSupport = false; + }; + }; + } + else + { + port = service.ports.port1; + acceleration = false; + models = service.paths.path1; + } + ); + open-webui = { + enable = true; + host = localhost; + port = service.ports.port0; + environment = { + ENABLE_OLLAMA_API = "True"; + ANONYMIZED_TELEMETRY = "False"; + DO_NOT_TRACK = "True"; + SCARF_NO_ANALYTICS = "True"; + OLLAMA_BASE_URL = "http://${localhost}:${toString service.ports.port1}"; + WEBUI_AUTH = "True"; + }; + }; + } // caddyLogic; + + systemd.tmpfiles.rules = [ + ( + if hostname == desktop.name then + "Z ${service.paths.path1} 0777 ${service.name} ${service.name} -" + else + "Z ${service.paths.path0} 0755 ${service.name} ${service.name} -" + ) + ]; + + networking = { + firewall = { + allowedTCPPorts = [ + # 8080 + service.ports.port0 + service.ports.port1 + ]; + }; + }; + fileSystems = mountLogic; +} diff --git a/nixos/modules/services/owncast.nix b/nixos/modules/services/owncast/default.nix similarity index 91% rename from nixos/modules/services/owncast.nix rename to nixos/modules/services/owncast/default.nix index 95c15bf..b35ed40 100755 --- a/nixos/modules/services/owncast.nix +++ b/nixos/modules/services/owncast/default.nix @@ -1,13 +1,14 @@ -{flake, ...}: let - inherit - (flake.config.services.instances) +{ flake, ... }: +let + inherit (flake.config.services.instances) owncast web ; service = owncast; localhost = web.localhost.address1; host = "${service.subdomain}.${web.domains.url1}"; -in { +in +{ services = { owncast = { enable = true; diff --git a/nixos/modules/services/peertube.nix b/nixos/modules/services/peertube/default.nix similarity index 100% rename from nixos/modules/services/peertube.nix rename to nixos/modules/services/peertube/default.nix diff --git a/nixos/modules/services/postgresql.nix b/nixos/modules/services/postgresql/default.nix similarity index 100% rename from nixos/modules/services/postgresql.nix rename to nixos/modules/services/postgresql/default.nix diff --git a/nixos/modules/services/samba.nix b/nixos/modules/services/samba/default.nix similarity index 90% rename from nixos/modules/services/samba.nix rename to nixos/modules/services/samba/default.nix index c7a9a46..30463c6 100755 --- a/nixos/modules/services/samba.nix +++ b/nixos/modules/services/samba/default.nix @@ -2,14 +2,15 @@ pkgs, flake, ... -}: let - inherit - (flake.config.services.instances) +}: +let + inherit (flake.config.services.instances) samba jellyfin ; service = samba; -in { +in +{ # If you ever need to start fresh, you need to add yourself to the Samba users database: # sudo smbpasswd -a username services = { diff --git a/nixos/modules/syncthing.nix b/nixos/modules/services/syncthing/default.nix similarity index 100% rename from nixos/modules/syncthing.nix rename to nixos/modules/services/syncthing/default.nix diff --git a/nixos/modules/services/vaultwarden.nix b/nixos/modules/services/vaultwarden/default.nix similarity index 100% rename from nixos/modules/services/vaultwarden.nix rename to nixos/modules/services/vaultwarden/default.nix diff --git a/nixos/modules/services/upRootNutrition.nix b/nixos/modules/services/website/default.nix similarity index 87% rename from nixos/modules/services/upRootNutrition.nix rename to nixos/modules/services/website/default.nix index 18c373a..1974e89 100755 --- a/nixos/modules/services/upRootNutrition.nix +++ b/nixos/modules/services/website/default.nix @@ -1,12 +1,13 @@ -{flake, ...}: let - inherit - (flake.config.services.instances) +{ flake, ... }: +let + inherit (flake.config.services.instances) upRootNutrition web ; service = upRootNutrition; host = web.domains.url3; -in { +in +{ services = { caddy = { virtualHosts = { diff --git a/nixos/modules/sops.nix b/nixos/modules/sops/default.nix similarity index 96% rename from nixos/modules/sops.nix rename to nixos/modules/sops/default.nix index 04e1d1d..7742422 100755 --- a/nixos/modules/sops.nix +++ b/nixos/modules/sops/default.nix @@ -25,7 +25,7 @@ let in { sops = { - defaultSopsFile = ../../secrets/secrets.yaml; + defaultSopsFile = ../../../secrets/secrets.yaml; validateSopsFiles = false; age = { keyFile = "/var/lib/sops-nix/key.txt"; diff --git a/nixos/modules/system.nix b/nixos/modules/system.nix deleted file mode 100755 index eed7124..0000000 --- a/nixos/modules/system.nix +++ /dev/null @@ -1 +0,0 @@ -_: {} diff --git a/nixos/modules/wayland/default.nix b/nixos/modules/wayland/default.nix deleted file mode 100755 index e45833b..0000000 --- a/nixos/modules/wayland/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - imports = map (file: ./${file}.nix) [ - "geoclue2" - "greetd" - "network" - "regreet" - "swaylock" - "thunar" - "wayland" - ]; -} diff --git a/templates/elm/parts/config/devshells.nix b/templates/elm/parts/config/devshells.nix index 8ebc22b..165955c 100755 --- a/templates/elm/parts/config/devshells.nix +++ b/templates/elm/parts/config/devshells.nix @@ -2,18 +2,21 @@ pkgs, pkgs-stable, ... -}: { +}: +{ devShells = { default = pkgs.mkShell { packages = builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) + age just - nixd nil + nixd + sops + ssh-to-age + nixfmt-rfc-style ; - inherit - (pkgs-stable.elmPackages) + inherit (pkgs-stable.elmPackages) elm elm-format elm-land @@ -21,8 +24,7 @@ elm-review elm-test ; - inherit - (pkgs.haskellPackages) + inherit (pkgs.haskellPackages) nixfmt ; }; diff --git a/templates/haskell/parts/config/devshells.nix b/templates/haskell/parts/config/devshells.nix index f3c519c..020ccee 100755 --- a/templates/haskell/parts/config/devshells.nix +++ b/templates/haskell/parts/config/devshells.nix @@ -2,57 +2,38 @@ pkgs, config, ... -}: { +}: +{ haskellProjects.default = { devShell = { enable = true; tools = hp: { - inherit - (hp) + inherit (hp) cabal-fmt haskell-language-server ; - inherit - (pkgs) + inherit (pkgs) dhall dhall-json dhall-lsp-server helix-gpt - nixd + age just - libz - ngrep nil + nixd sops ssh-to-age + nixfmt-rfc-style + libz + ngrep stripe-cli vscode-langservers-extracted zlib ; - inherit - (pkgs.elmPackages) - elm - elm-format - elm-land - elm-language-server - elm-review - elm-test - ; - - inherit - (pkgs.nodePackages_latest) - "@commitlint/config-conventional" - dotenv-cli - forever - nodejs - npm - typescript-language-server - ; - inherit - (pkgs.haskellPackages) + inherit (pkgs.haskellPackages) nixfmt ; };