diff --git a/config/nixos/default.nix b/config/nixos/default.nix deleted file mode 100644 index f35bfde..0000000 --- a/config/nixos/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./services - ]; -} diff --git a/config/nixos/services/brightness.nix b/config/nixos/services/brightness.nix deleted file mode 100644 index 4cbef77..0000000 --- a/config/nixos/services/brightness.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - hardware.brillo.enable = true; -} diff --git a/config/nixos/services/default.nix b/config/nixos/services/default.nix deleted file mode 100644 index b12c274..0000000 --- a/config/nixos/services/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{pkgs, ...}: { - imports = [ - ./docker.nix - ./gnupg.nix - ./pipewire.nix - ./kmscon.nix - ]; - services.udev.packages = [pkgs.segger-jlink]; -} diff --git a/config/nixos/services/docker.nix b/config/nixos/services/docker.nix deleted file mode 100644 index 36e58a8..0000000 --- a/config/nixos/services/docker.nix +++ /dev/null @@ -1,8 +0,0 @@ -{pkgs, ...}: { - virtualisation.podman = { - enable = true; - dockerCompat = true; - }; - - environment.systemPackages = [pkgs.distrobox]; -} diff --git a/config/nixos/services/documentation.nix b/config/nixos/services/documentation.nix deleted file mode 100644 index 0919470..0000000 --- a/config/nixos/services/documentation.nix +++ /dev/null @@ -1,12 +0,0 @@ -_: { - documentation = { - enable = true; - - man = { - enable = true; - man-db.enable = false; - mandoc.enable = true; - generateCaches = true; - }; - }; -} diff --git a/config/nixos/services/flatpak.nix b/config/nixos/services/flatpak.nix deleted file mode 100644 index cf588bd..0000000 --- a/config/nixos/services/flatpak.nix +++ /dev/null @@ -1,3 +0,0 @@ -_: { - services.flatpak.enable = true; -} diff --git a/config/nixos/services/forgejo.nix b/config/nixos/services/forgejo.nix deleted file mode 100644 index 0f0f33d..0000000 --- a/config/nixos/services/forgejo.nix +++ /dev/null @@ -1,91 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib) mkAfter removePrefix removeSuffix; - srv = config.services.forgejo.settings.server; - - # https://github.com/isabelroses/dotfiles/blob/06f8f70914c8e672541a52563ee624ce2e62adfb/modules/nixos/services/selfhosted/forgejo.nix#L19-L23 - theme = pkgs.fetchzip { - url = "https://github.com/catppuccin/gitea/releases/download/v1.0.1/catppuccin-gitea.tar.gz"; - sha256 = "et5luA3SI7iOcEIQ3CVIu0+eiLs8C/8mOitYlWQa/uI="; - stripRoot = false; - }; -in { - services = { - forgejo = { - enable = true; - package = pkgs.forgejo; - lfs.enable = true; - database.type = "postgres"; - dump = { - enable = true; - type = "tar.xz"; - }; - settings = { - server = { - DOMAIN = "git.nezia.dev"; - HTTP_PORT = 1849; - ROOT_URL = "https://${srv.DOMAIN}/"; - HTTP_ADDR = "localhost"; - }; - service = { - DISABLE_REGISTRATION = true; - }; - federation = { - ENABLED = true; - }; - ui = { - DEFAULT_THEME = "catppuccin-mocha-lavender"; - THEMES = builtins.concatStringsSep "," ( - ["auto,forgejo-auto,forgejo-dark,forgejo-light,arc-gree,gitea"] - ++ (map (name: removePrefix "theme-" (removeSuffix ".css" name)) ( - builtins.attrNames (builtins.readDir theme) - )) - ); - }; - - actions = { - ENABLED = true; - DEFAULT_ACTIONS_URL = "https://code.forgejo.org"; - }; - }; - }; - - caddy = { - enable = true; - virtualHosts."git.nezia.dev".extraConfig = '' - reverse_proxy * localhost:${toString srv.HTTP_PORT} - ''; - }; - }; - - # https://github.com/isabelroses/dotfiles/blob/06f8f70914c8e672541a52563ee624ce2e62adfb/modules/nixos/services/selfhosted/forgejo.nix#L59-L71 - systemd.services = { - forgejo = { - preStart = let - inherit (config.services.forgejo) stateDir; - in - mkAfter '' - rm -rf ${stateDir}/custom/public/assets - mkdir -p ${stateDir}/custom/public/assets - ln -sf ${theme} ${stateDir}/custom/public/assets/css - ''; - }; - }; - - networking.firewall = { - enable = true; - allowedTCPPorts = [80 443]; - - # If you're using nftables (default in newer NixOS) - extraForwardRules = '' - ip6 saddr { ::/0 } accept - ''; - }; - - # Ensure IPv6 is enabled - networking.enableIPv6 = true; -} diff --git a/config/nixos/services/gnome.nix b/config/nixos/services/gnome.nix deleted file mode 100644 index 2b27167..0000000 --- a/config/nixos/services/gnome.nix +++ /dev/null @@ -1,12 +0,0 @@ -{pkgs, ...}: { - services = { - # needed for GNOME services outside of GNOME Desktop - dbus.packages = with pkgs; [ - gcr - gnome-settings-daemon - ]; - - gnome.gnome-keyring.enable = true; - gvfs.enable = true; - }; -} diff --git a/config/nixos/services/gnupg.nix b/config/nixos/services/gnupg.nix deleted file mode 100644 index 5785e22..0000000 --- a/config/nixos/services/gnupg.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - }; -} diff --git a/config/nixos/services/greetd.nix b/config/nixos/services/greetd.nix deleted file mode 100644 index 25e70da..0000000 --- a/config/nixos/services/greetd.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ - config, - inputs, - lib, - pkgs, - ... -}: -# thanks https://git.jacekpoz.pl/poz/niksos/src/commit/f8d5e7ccd9c769f7c0b564f10dff419285e75248/modules/services/greetd.nix -let - inherit (lib) getExe getExe'; - inherit (inputs.hyprland.packages.${pkgs.stdenv.system}) hyprland; - - hyprctl = getExe' hyprland "hyprctl"; - Hyprland = getExe' hyprland "Hyprland"; - - greeter = getExe pkgs.greetd.gtkgreet; - - hyprlandConfig = - pkgs.writeText "greetd-hyprland-config" - '' - misc { - force_default_wallpaper=0 - focus_on_activate=1 - } - - animations { - enabled=0 - first_launch_animation=0 - } - - workspace=1,default:true,gapsout:0,gapsin:0,border:false,decorate:false - - exec-once=[workspace 1;fullscreen;noanim] ${greeter} -l; ${hyprctl} dispatch exit - exec-once=${hyprctl} dispatch focuswindow ${greeter} - ''; -in { - services.greetd = { - enable = true; - settings = { - default_session = { - command = "${Hyprland} --config ${hyprlandConfig}"; - user = config.local.systemVars.username; - }; - }; - }; - - programs.regreet = { - enable = true; - }; - - security.pam.services = { - greetd.enableGnomeKeyring = true; - login.enableGnomeKeyring = true; - gdm-password.enableGnomeKeyring = true; - greetd.fprintAuth = false; - }; - - environment.etc."greetd/environments".text = let - environments = [ - { - name = "Hyprland"; - condition = with config.programs.hyprland; enable && !withUWSM; - } - { - name = "uwsm start -S hyprland-uwsm.desktop"; - condition = with config.programs.hyprland; enable && withUWSM; - } - { - name = "sway"; - condition = config.programs.sway.enable; - } - ]; - in - builtins.concatStringsSep "\n" (map (env: env.name) (builtins.filter (env: env.condition) environments)); -} diff --git a/config/nixos/services/keyd.nix b/config/nixos/services/keyd.nix deleted file mode 100644 index 27a47b5..0000000 --- a/config/nixos/services/keyd.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - services = { - keyd = { - enable = true; - keyboards = { - default = { - ids = ["*"]; - settings = { - main = { - capslock = "overload(control, esc)"; - }; - }; - }; - }; - }; - }; -} diff --git a/config/nixos/services/kmscon.nix b/config/nixos/services/kmscon.nix deleted file mode 100644 index 62930c9..0000000 --- a/config/nixos/services/kmscon.nix +++ /dev/null @@ -1,15 +0,0 @@ -{pkgs, ...}: { - services.kmscon = { - enable = true; - fonts = [ - { - name = "0xProto Nerd Font"; - package = pkgs.nerd-fonts._0xproto; - } - ]; - extraConfig = '' - font-size=13 - font-dpi=144 - ''; - }; -} diff --git a/config/nixos/services/location.nix b/config/nixos/services/location.nix deleted file mode 100644 index b5eb16d..0000000 --- a/config/nixos/services/location.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - location.provider = "geoclue2"; - - services.geoclue2 = { - enable = true; - geoProviderUrl = "https://beacondb.net/v1/geolocate"; - submissionUrl = "https://beacondb.net/v2/geosubmit"; - submissionNick = "geoclue"; - - appConfig.gammastep = { - isAllowed = true; - isSystem = false; - }; - }; -} diff --git a/config/nixos/services/logind.nix b/config/nixos/services/logind.nix deleted file mode 100644 index 44eb438..0000000 --- a/config/nixos/services/logind.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - services.logind = { - lidSwitch = "suspend"; - extraConfig = '' - HandlePowerKey=ignore - HandlePowerKeyLongPress=poweroff - ''; - }; -} diff --git a/config/nixos/services/mail.nix b/config/nixos/services/mail.nix deleted file mode 100644 index e1fc963..0000000 --- a/config/nixos/services/mail.nix +++ /dev/null @@ -1,6 +0,0 @@ -{pkgs, ...}: { - services.protonmail-bridge = { - enable = true; - package = pkgs.protonmail-bridge; - }; -} diff --git a/config/nixos/services/pipewire.nix b/config/nixos/services/pipewire.nix deleted file mode 100644 index c8055ca..0000000 --- a/config/nixos/services/pipewire.nix +++ /dev/null @@ -1,18 +0,0 @@ -{inputs, ...}: { - imports = [ - inputs.nix-gaming.nixosModules.pipewireLowLatency - ]; - services = { - pulseaudio.enable = false; - pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - lowLatency.enable = true; - }; - }; - # rtkit is optional but recommended - security.rtkit.enable = true; -} diff --git a/config/nixos/services/power.nix b/config/nixos/services/power.nix deleted file mode 100644 index a5094e9..0000000 --- a/config/nixos/services/power.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - services = { - power-profiles-daemon.enable = true; - - # battery info - upower.enable = true; - }; -} diff --git a/config/nixos/services/searx.nix b/config/nixos/services/searx.nix deleted file mode 100644 index 9c4efbb..0000000 --- a/config/nixos/services/searx.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ - config, - pkgs, - ... -}: { - age.secrets.searx-env-file.file = ../../../secrets/searx-env-file.age; - services = { - searx = { - enable = true; - package = pkgs.searxng; - environmentFile = config.age.secrets.searx-env-file.path; - settings = { - search = { - safe_search = 1; # 0 = None, 1 = Moderate, 2 = Strict - autocomplete = "google"; # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off by default - default_lang = "en"; - }; - server = { - secret_key = "@SEARX_SECRET_KEY@"; - port = 8888; # Internal port - bind_address = "localhost"; # Only listen locally - base_url = "https://search.nezia.dev/"; - image_proxy = true; - default_http_headers = { - X-Content-Type-Options = "nosniff"; - X-XSS-Protection = "1; mode=block"; - X-Download-Options = "noopen"; - X-Robots-Tag = "noindex, nofollow"; - Referrer-Policy = "no-referrer"; - }; - }; - engines = [ - { - name = "qwant"; - disabled = true; - } - ]; - }; - }; - - caddy = { - enable = true; - virtualHosts."search.nezia.dev" = { - extraConfig = '' - encode gzip - reverse_proxy localhost:8888 { - header_up Host {host} - header_up X-Real-IP {remote_addr} - header_up X-Forwarded-For {remote_addr} - header_up X-Forwarded-Proto {scheme} - } - ''; - }; - }; - }; - - # Open required ports - networking.firewall = { - allowedTCPPorts = [80 443]; # For Caddy - }; -} diff --git a/config/nixos/services/syncthing.nix b/config/nixos/services/syncthing.nix deleted file mode 100644 index 3922ad7..0000000 --- a/config/nixos/services/syncthing.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - services = { - syncthing = { - enable = true; - }; - }; - systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder -} diff --git a/config/nixos/services/website.nix b/config/nixos/services/website.nix deleted file mode 100644 index b8e4955..0000000 --- a/config/nixos/services/website.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - inputs, - pkgs, - ... -}: { - services.caddy.enable = true; - services.caddy.virtualHosts = { - "www.nezia.dev" = { - extraConfig = '' - redir https://nezia.dev{uri} - ''; - }; - "nezia.dev" = { - extraConfig = '' - root * ${inputs."nezia_dev".packages.${pkgs.system}.default} - file_server - encode gzip - ''; - }; - }; -} diff --git a/hosts/default.nix b/hosts/default.nix index 4e7f61d..6bd07b3 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -7,16 +7,10 @@ mkSystem = args: inputs.nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs lib';}; - modules = args.modules or []; + modules = (args.modules or []) ++ [../modules]; }; base = [ - ../modules - "${self}/config/nixos" - - "${self}/config/nixos/services/documentation.nix" - - "${self}/config/nixos/services/location.nix" ({ config, specialArgs, @@ -36,10 +30,6 @@ ]; graphical = [ - "${self}/config/nixos/services/logind.nix" - "${self}/config/nixos/services/greetd.nix" - - "${self}/config/nixos/services/gnome.nix" ({config, ...}: { home-manager.users.${config.local.systemVars.username}.imports = [ "${self}/config/home-manager/programs/waybar" @@ -56,7 +46,6 @@ ]; gaming = [ - ../config/nixos/services/flatpak.nix ({config, ...}: { home-manager.users.${config.local.systemVars.username}.imports = [ "${self}/config/home-manager/programs/games" @@ -64,12 +53,6 @@ ]; }) ]; - - laptop = [ - "${self}/config/nixos/services/kanata.nix" - "${self}/config/nixos/services/power.nix" - "${self}/config/nixos/services/brightness.nix" - ]; in { vamos = mkSystem { modules = @@ -78,8 +61,7 @@ in { inputs.nixos-hardware.nixosModules.framework-13-7040-amd ] ++ base - ++ graphical - ++ laptop; + ++ graphical; }; solaire = mkSystem { @@ -95,10 +77,6 @@ in { anastacia = mkSystem { modules = [ ./anastacia - - "${self}/config/nixos/services/forgejo.nix" - "${self}/config/nixos/services/searx.nix" - "${self}/config/nixos/services/website.nix" ]; }; } diff --git a/modules/nix/default.nix b/modules/nix/default.nix index c1e62b1..ab88cb6 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -2,6 +2,7 @@ imports = [ ./core ./programs + ./services ./style ]; } diff --git a/modules/nix/services/brightness.nix b/modules/nix/services/brightness.nix new file mode 100644 index 0000000..05da8b3 --- /dev/null +++ b/modules/nix/services/brightness.nix @@ -0,0 +1,9 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.laptop.enable { + hardware.brillo.enable = true; + }; +} diff --git a/modules/nix/services/default.nix b/modules/nix/services/default.nix new file mode 100644 index 0000000..e16a1d2 --- /dev/null +++ b/modules/nix/services/default.nix @@ -0,0 +1,21 @@ +{pkgs, ...}: { + imports = [ + ./brightness.nix + ./docker.nix + ./documentation.nix + ./flatpak.nix + ./forgejo.nix + ./gnome.nix + ./gnupg.nix + ./greetd.nix + ./kanata.nix + ./kmscon.nix + ./location.nix + ./logind.nix + ./pipewire.nix + ./power.nix + ./searx.nix + ./syncthing.nix + ./website.nix + ]; +} diff --git a/modules/nix/services/docker.nix b/modules/nix/services/docker.nix new file mode 100644 index 0000000..97ecd28 --- /dev/null +++ b/modules/nix/services/docker.nix @@ -0,0 +1,15 @@ +{ + lib, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + virtualisation.podman = { + enable = true; + dockerCompat = true; + }; + + environment.systemPackages = [pkgs.distrobox]; + }; +} diff --git a/modules/nix/services/documentation.nix b/modules/nix/services/documentation.nix new file mode 100644 index 0000000..c715c55 --- /dev/null +++ b/modules/nix/services/documentation.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + documentation = { + enable = true; + + man = { + enable = true; + man-db.enable = false; + mandoc.enable = true; + generateCaches = true; + }; + }; + }; +} diff --git a/modules/nix/services/flatpak.nix b/modules/nix/services/flatpak.nix new file mode 100644 index 0000000..bbf4f92 --- /dev/null +++ b/modules/nix/services/flatpak.nix @@ -0,0 +1,9 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + services.flatpak.enable = true; + }; +} diff --git a/modules/nix/services/forgejo.nix b/modules/nix/services/forgejo.nix new file mode 100644 index 0000000..904c276 --- /dev/null +++ b/modules/nix/services/forgejo.nix @@ -0,0 +1,93 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) mkAfter removePrefix removeSuffix; + srv = config.services.forgejo.settings.server; + + # https://github.com/isabelroses/dotfiles/blob/06f8f70914c8e672541a52563ee624ce2e62adfb/modules/nixos/services/selfhosted/forgejo.nix#L19-L23 + theme = pkgs.fetchzip { + url = "https://github.com/catppuccin/gitea/releases/download/v1.0.1/catppuccin-gitea.tar.gz"; + sha256 = "et5luA3SI7iOcEIQ3CVIu0+eiLs8C/8mOitYlWQa/uI="; + stripRoot = false; + }; +in { + config = lib.mkIf config.local.profiles.server.enable { + services = { + forgejo = { + enable = true; + package = pkgs.forgejo; + lfs.enable = true; + database.type = "postgres"; + dump = { + enable = true; + type = "tar.xz"; + }; + settings = { + server = { + DOMAIN = "git.nezia.dev"; + HTTP_PORT = 1849; + ROOT_URL = "https://${srv.DOMAIN}/"; + HTTP_ADDR = "localhost"; + }; + service = { + DISABLE_REGISTRATION = true; + }; + federation = { + ENABLED = true; + }; + ui = { + DEFAULT_THEME = "catppuccin-mocha-lavender"; + THEMES = builtins.concatStringsSep "," ( + ["auto,forgejo-auto,forgejo-dark,forgejo-light,arc-gree,gitea"] + ++ (map (name: removePrefix "theme-" (removeSuffix ".css" name)) ( + builtins.attrNames (builtins.readDir theme) + )) + ); + }; + + actions = { + ENABLED = true; + DEFAULT_ACTIONS_URL = "https://code.forgejo.org"; + }; + }; + }; + + caddy = { + enable = true; + virtualHosts."git.nezia.dev".extraConfig = '' + reverse_proxy * localhost:${toString srv.HTTP_PORT} + ''; + }; + }; + + # https://github.com/isabelroses/dotfiles/blob/06f8f70914c8e672541a52563ee624ce2e62adfb/modules/nixos/services/selfhosted/forgejo.nix#L59-L71 + systemd.services = { + forgejo = { + preStart = let + inherit (config.services.forgejo) stateDir; + in + mkAfter '' + rm -rf ${stateDir}/custom/public/assets + mkdir -p ${stateDir}/custom/public/assets + ln -sf ${theme} ${stateDir}/custom/public/assets/css + ''; + }; + }; + + networking.firewall = { + enable = true; + allowedTCPPorts = [80 443]; + + # if using nftables + extraForwardRules = '' + ip6 saddr { ::/0 } accept + ''; + }; + + # ensure IPv6 is enabled + networking.enableIPv6 = true; + }; +} diff --git a/modules/nix/services/gnome.nix b/modules/nix/services/gnome.nix new file mode 100644 index 0000000..5596fd2 --- /dev/null +++ b/modules/nix/services/gnome.nix @@ -0,0 +1,19 @@ +{ + lib, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + services = { + # needed for GNOME services outside of GNOME Desktop + dbus.packages = with pkgs; [ + gcr + gnome-settings-daemon + ]; + + gnome.gnome-keyring.enable = true; + gvfs.enable = true; + }; + }; +} diff --git a/modules/nix/services/gnupg.nix b/modules/nix/services/gnupg.nix new file mode 100644 index 0000000..a33cdb0 --- /dev/null +++ b/modules/nix/services/gnupg.nix @@ -0,0 +1,12 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + }; +} diff --git a/modules/nix/services/greetd.nix b/modules/nix/services/greetd.nix new file mode 100644 index 0000000..df70a0d --- /dev/null +++ b/modules/nix/services/greetd.nix @@ -0,0 +1,78 @@ +{ + config, + inputs, + lib, + pkgs, + ... +}: +# thanks https://git.jacekpoz.pl/poz/niksos/src/commit/f8d5e7ccd9c769f7c0b564f10dff419285e75248/modules/services/greetd.nix +let + inherit (lib) getExe getExe'; + inherit (inputs.hyprland.packages.${pkgs.stdenv.system}) hyprland; + + hyprctl = getExe' hyprland "hyprctl"; + Hyprland = getExe' hyprland "Hyprland"; + + greeter = getExe pkgs.greetd.gtkgreet; + + hyprlandConfig = + pkgs.writeText "greetd-hyprland-config" + '' + misc { + force_default_wallpaper=0 + focus_on_activate=1 + } + + animations { + enabled=0 + first_launch_animation=0 + } + + workspace=1,default:true,gapsout:0,gapsin:0,border:false,decorate:false + + exec-once=[workspace 1;fullscreen;noanim] ${greeter} -l; ${hyprctl} dispatch exit + exec-once=${hyprctl} dispatch focuswindow ${greeter} + ''; +in { + # TODO: perhaps turn this into a more generic module if we wanna use other wayland compositors + config = lib.mkIf config.local.modules.hyprland.enable { + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${Hyprland} --config ${hyprlandConfig}"; + user = config.local.systemVars.username; + }; + }; + }; + + programs.regreet = { + enable = true; + }; + + security.pam.services = { + greetd.enableGnomeKeyring = true; + login.enableGnomeKeyring = true; + gdm-password.enableGnomeKeyring = true; + greetd.fprintAuth = false; + }; + + environment.etc."greetd/environments".text = let + environments = [ + { + name = "Hyprland"; + condition = with config.programs.hyprland; enable && !withUWSM; + } + { + name = "uwsm start -S hyprland-uwsm.desktop"; + condition = with config.programs.hyprland; enable && withUWSM; + } + { + name = "sway"; + condition = config.programs.sway.enable; + } + ]; + in + builtins.concatStringsSep "\n" (map (env: env.name) (builtins.filter (env: env.condition) environments)); + }; +} diff --git a/config/nixos/services/kanata.nix b/modules/nix/services/kanata.nix similarity index 89% rename from config/nixos/services/kanata.nix rename to modules/nix/services/kanata.nix index 35b84e2..a19af1c 100644 --- a/config/nixos/services/kanata.nix +++ b/modules/nix/services/kanata.nix @@ -1,5 +1,9 @@ { - services.kanata = { + lib, + config, + ... +}: { + services.kanata = lib.mkIf config.local.profiles.desktop.enable { enable = true; keyboards.default = { extraDefCfg = "process-unmapped-keys yes"; diff --git a/modules/nix/services/kmscon.nix b/modules/nix/services/kmscon.nix new file mode 100644 index 0000000..758df65 --- /dev/null +++ b/modules/nix/services/kmscon.nix @@ -0,0 +1,22 @@ +{ + lib, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + services.kmscon = { + enable = true; + fonts = [ + { + name = "0xProto Nerd Font"; + package = pkgs.nerd-fonts._0xproto; + } + ]; + extraConfig = '' + font-size=13 + font-dpi=144 + ''; + }; + }; +} diff --git a/modules/nix/services/location.nix b/modules/nix/services/location.nix new file mode 100644 index 0000000..ac22b89 --- /dev/null +++ b/modules/nix/services/location.nix @@ -0,0 +1,21 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.modules.hyprland.enable { + location.provider = "geoclue2"; + + services.geoclue2 = { + enable = true; + geoProviderUrl = "https://beacondb.net/v1/geolocate"; + submissionUrl = "https://beacondb.net/v2/geosubmit"; + submissionNick = "geoclue"; + + appConfig.gammastep = { + isAllowed = true; + isSystem = false; + }; + }; + }; +} diff --git a/modules/nix/services/logind.nix b/modules/nix/services/logind.nix new file mode 100644 index 0000000..11b55b8 --- /dev/null +++ b/modules/nix/services/logind.nix @@ -0,0 +1,15 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.laptop.enable { + services.logind = { + lidSwitch = "suspend"; + extraConfig = '' + HandlePowerKey=ignore + HandlePowerKeyLongPress=poweroff + ''; + }; + }; +} diff --git a/modules/nix/services/pipewire.nix b/modules/nix/services/pipewire.nix new file mode 100644 index 0000000..25cc868 --- /dev/null +++ b/modules/nix/services/pipewire.nix @@ -0,0 +1,26 @@ +{ + lib, + inputs, + config, + ... +}: { + imports = [ + inputs.nix-gaming.nixosModules.pipewireLowLatency + ]; + + config = lib.mkIf config.local.profiles.desktop.enable { + services = { + pulseaudio.enable = false; + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + lowLatency.enable = true; + }; + }; + # rtkit is optional but recommended + security.rtkit.enable = true; + }; +} diff --git a/modules/nix/services/power.nix b/modules/nix/services/power.nix new file mode 100644 index 0000000..952a629 --- /dev/null +++ b/modules/nix/services/power.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.laptop.enable { + services = { + power-profiles-daemon.enable = true; + + # battery info + upower.enable = true; + }; + }; +} diff --git a/modules/nix/services/searx.nix b/modules/nix/services/searx.nix new file mode 100644 index 0000000..fe3f097 --- /dev/null +++ b/modules/nix/services/searx.nix @@ -0,0 +1,69 @@ +{ + inputs, + lib, + pkgs, + config, + ... +}: { + imports = [ + inputs.agenix.nixosModules.default + ]; + + config = lib.mkIf config.local.profiles.server.enable { + age.secrets.searx-env-file.file = ../../../secrets/searx-env-file.age; + services = { + searx = { + enable = true; + package = pkgs.searxng; + environmentFile = config.age.secrets.searx-env-file.path; + settings = { + search = { + safe_search = 1; # 0 = None, 1 = Moderate, 2 = Strict + autocomplete = "google"; # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off by default + default_lang = "en"; + }; + server = { + secret_key = "@SEARX_SECRET_KEY@"; + port = 8888; # Internal port + bind_address = "localhost"; # Only listen locally + base_url = "https://search.nezia.dev/"; + image_proxy = true; + default_http_headers = { + X-Content-Type-Options = "nosniff"; + X-XSS-Protection = "1; mode=block"; + X-Download-Options = "noopen"; + X-Robots-Tag = "noindex, nofollow"; + Referrer-Policy = "no-referrer"; + }; + }; + engines = [ + { + name = "qwant"; + disabled = true; + } + ]; + }; + }; + + caddy = { + enable = true; + virtualHosts."search.nezia.dev" = { + extraConfig = '' + encode gzip + reverse_proxy localhost:8888 { + header_up Host {host} + header_up X-Real-IP {remote_addr} + header_up X-Forwarded-For {remote_addr} + header_up X-Forwarded-Proto {scheme} + } + ''; + }; + }; + }; + + # Open required ports + networking.firewall = { + allowedTCPPorts = [80 443]; # For Caddy + }; + }; +} diff --git a/modules/nix/services/syncthing.nix b/modules/nix/services/syncthing.nix new file mode 100644 index 0000000..258af23 --- /dev/null +++ b/modules/nix/services/syncthing.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + services = { + syncthing = { + enable = true; + }; + }; + systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder + }; +} diff --git a/modules/nix/services/website.nix b/modules/nix/services/website.nix new file mode 100644 index 0000000..4eb573c --- /dev/null +++ b/modules/nix/services/website.nix @@ -0,0 +1,25 @@ +{ + lib, + inputs, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.server.enable { + services.caddy.enable = true; + services.caddy.virtualHosts = { + "www.nezia.dev" = { + extraConfig = '' + redir https://nezia.dev{uri} + ''; + }; + "nezia.dev" = { + extraConfig = '' + root * ${inputs."nezia_dev".packages.${pkgs.system}.default} + file_server + encode gzip + ''; + }; + }; + }; +}