diff --git a/home/programs/default.nix b/home/programs/default.nix index 0ca7760..b0b0cec 100644 --- a/home/programs/default.nix +++ b/home/programs/default.nix @@ -5,6 +5,7 @@ ./mpv.nix ./neovim.nix ./nixcord.nix + ./kodi.nix ./other.nix ]; } diff --git a/home/programs/kodi.nix b/home/programs/kodi.nix new file mode 100644 index 0000000..b956d0c --- /dev/null +++ b/home/programs/kodi.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: { + home.packages = [ + (pkgs.kodi-wayland.withPackages (exts: [exts.inputstream-adaptive exts.inputstreamhelper])) + ]; +} diff --git a/home/programs/neovim.nix b/home/programs/neovim.nix index 780994c..12f2780 100644 --- a/home/programs/neovim.nix +++ b/home/programs/neovim.nix @@ -41,11 +41,12 @@ providers.wl-copy.enable = true; registers = "unnamedplus"; }; + + options.shiftwidth = 2; binds = { whichKey.enable = true; cheatsheet.enable = true; }; - options.shiftwidth = 2; languages = { enableFormat = true; #You can also manually overwrite each language. enableTreesitter = true; @@ -120,7 +121,16 @@ colorizer.enable = true; smartcolumn. enable = true; }; - utility.vim-wakatime.enable = true; + utility = { + vim-wakatime.enable = true; + motion.leap = { + enable = true; + mappings = { + leapForwardTo = "f"; + leapBackwardTo = "F"; + }; + }; + }; visuals = { nvim-web-devicons.enable = true; nvim-cursorline.enable = true; diff --git a/home/shell/default.nix b/home/shell/default.nix index e301aab..4c4c4f6 100644 --- a/home/shell/default.nix +++ b/home/shell/default.nix @@ -2,11 +2,12 @@ imports = [ ./direnv.nix ./fish.nix + ./git.nix ./other.nix ./repl ./starship.nix + ./transfer.nix ./yazi.nix ./zoxide.nix - ./transfer.nix ]; } diff --git a/home/shell/git.nix b/home/shell/git.nix new file mode 100644 index 0000000..ac2f019 --- /dev/null +++ b/home/shell/git.nix @@ -0,0 +1,11 @@ +{ + programs = { + git = { + enable = true; + userEmail = "jurnwubben@gmail.com"; + userName = "Jurn Wubben"; + extraConfig.push.autoSetupRemote = true; + }; + git-credential-oauth = true; + }; +} diff --git a/home/shell/other.nix b/home/shell/other.nix index 029dc2b..f90f855 100644 --- a/home/shell/other.nix +++ b/home/shell/other.nix @@ -7,7 +7,6 @@ }: { home.packages = [ - pkgs.gh pkgs.ripgrep pkgs.p7zip pkgs.usbutils @@ -23,7 +22,7 @@ ++ lib.optionals osConfig.niksos.bluetooth [ pkgs.ear2ctl ] - ++ lib.optionals osConfig.niksos.portable [ + ++ lib.optionals osConfig.niksos.portable.enable [ inputs.somcli.defaultPackage.${pkgs.system} ]; } diff --git a/home/style/background.png b/home/style/background.png index 65736a4..91b0e96 100644 Binary files a/home/style/background.png and b/home/style/background.png differ diff --git a/home/wayland/hyprland/binds.nix b/home/wayland/hyprland/binds.nix index 10c3fa0..69d0e0c 100644 --- a/home/wayland/hyprland/binds.nix +++ b/home/wayland/hyprland/binds.nix @@ -115,8 +115,9 @@ in { "Super, s, exec, ${torzu}" "Super, d, exec, ${dolphin}" ]) - ++ lib.optionals portable [ + ++ lib.optionals portable.enable [ "$m Shift, S, exec, ${somcli}" + ", XF86AudioMedia, exec, powermode toggle" ]; bindl = [ diff --git a/home/wayland/hyprland/default.nix b/home/wayland/hyprland/default.nix index 6baaa62..98d05ad 100644 --- a/home/wayland/hyprland/default.nix +++ b/home/wayland/hyprland/default.nix @@ -21,10 +21,12 @@ in { "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" "NIXOS_OZONE_WL,1" ]; - exec-once = [ - "${uwsm} finalize" - "${hyprlock}" # Lock screen - ]; + exec-once = + [ + "${uwsm} finalize" + "${hyprlock}" # Lock screen + ] + ++ lib.optional osConfig.niksos.portable.enable "powermode sync"; }; }; } diff --git a/hosts/laptop/default.nix b/hosts/laptop/default.nix index 9028eee..3b8f8aa 100644 --- a/hosts/laptop/default.nix +++ b/hosts/laptop/default.nix @@ -1,46 +1,57 @@ { - pkgs, - lib, - inputs, - ... -}: let - uwsm = lib.getExe pkgs.uwsm; - foot = lib.getExe pkgs.foot; -in { imports = [ ./hardware-configuration.nix ./virt.nix + ./wluma.nix ]; + services.printing = { + enable = true; + startWhenNeeded = true; + }; + hardware.printers = { + ensureDefaultPrinter = "Broeder"; + ensurePrinters = [ + { + deviceUri = "ipp://192.168.1.33/ipp"; + location = "home"; + name = "Broeder"; + model = "everywhere"; + } + ]; + }; + + # programs.evolution.enable = true; # FIXME: move to appropiate place. niksos = { + joycond = false; #NOTE: enable when game night lol fingerprint = true; bluetooth = true; - portable = true; + portable = { + enable = true; + hyprland = { + powerSaver = '' + hyprctl keyword monitor eDP-1,2880x1920@60,0x0,1.5,vrr,1 + ''; + performance = '' + hyprctl keyword monitor eDP-1,2880x1920@120,0x0,1.5,vrr,1 + ''; + }; + }; neovim = true; games = true; desktop = { enable = true; hyprland = true; - kde = false; + kde = true; }; }; home-manager.users.jsw.wayland.windowManager.hyprland.settings.monitor = ["eDP-1,2880x1920@120,0x0,1.5,vrr,1"]; - services = { - usbmuxd.enable = true; - joycond.enable = true; - udev.extraRules = '' - # Ethernet expansion card support - ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20" - ''; - logind.extraConfig = '' - # don’t shutdown when power button is short-pressed - HandlePowerKey=ignore - ''; - }; - hardware.sensor.iio.enable = true; # brightness sensor - + services.udev.extraRules = '' + # Ethernet expansion card support + ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20" + ''; boot.kernelParams = [ # There seems to be an issue with panel self-refresh (PSR) that # causes hangs for users. diff --git a/hosts/laptop/wluma.nix b/hosts/laptop/wluma.nix new file mode 100644 index 0000000..593c1c1 --- /dev/null +++ b/hosts/laptop/wluma.nix @@ -0,0 +1,31 @@ +{ + hardware.sensor.iio.enable = true; # brightness sensor + home-manager.users.jsw.services.wluma = { + enable = true; + settings = { + als.iio = { + path = "/sys/bus/iio/devices"; + thresholds = { + "0" = "night"; + "10" = "dark"; + "100" = "normal"; + "20" = "dim"; + "200" = "bright"; + "500" = "outdoors"; + }; + }; + output.backlight = [ + { + capturer = "none"; + name = "eDP-1"; + path = "/sys/class/backlight/amdgpu_bl1"; + } + { + capturer = "none"; + name = "keyboard"; + path = "/sys/bus/platform/devices/cros-keyboard-leds.5.auto/leds/chromeos::kbd_backlight"; + } + ]; + }; + }; +} diff --git a/hosts/minimal/default.nix b/hosts/minimal/default.nix index 408b1d2..4d05acd 100644 --- a/hosts/minimal/default.nix +++ b/hosts/minimal/default.nix @@ -23,7 +23,13 @@ nvidia = false; }; neovim = false; - portable = false; + portable = { + enable = false; + hyprland = { + powerSaver = ""; + performance = ""; + }; + }; server = false; }; diff --git a/secrets/default.nix b/secrets/default.nix index 20be83e..12e4986 100644 --- a/secrets/default.nix +++ b/secrets/default.nix @@ -1,4 +1,6 @@ -{config, ...}: { +{config, ...}: let + serviceUser = x: config.systemd.services.${x}.serviceConfig.User; +in { age.secrets = { transferSh = { file = ./transfer-sh.age; @@ -8,7 +10,7 @@ file = ./dcbot.age; owner = if config.niksos.server - then "dcbot" # "dcbot" doesn't exist on e.g laptop. + then serviceUser "dcbot" # "dcbot" doesn't exist on e.g laptop. else "root"; }; password.file = ./password.age; @@ -21,10 +23,10 @@ }; cloudflare-acme.file = ./cloudflare-acme.age; mail-admin = { - owner = - if config.niksos.server - then "stalwart-mail" - else "root"; + # owner = #FIXME: revert when stopped using docker for stalwart. + # if config.niksos.server + # then serviceUser "stalwart-mail" + # else "root"; file = ./mail-admin.age; }; }; diff --git a/secrets/mail-admin.age b/secrets/mail-admin.age index 457b7cd..494156f 100644 Binary files a/secrets/mail-admin.age and b/secrets/mail-admin.age differ diff --git a/system/desktop/greetd.nix b/system/desktop/greetd.nix index 1350659..5cb4982 100644 --- a/system/desktop/greetd.nix +++ b/system/desktop/greetd.nix @@ -2,14 +2,12 @@ config, lib, ... -}: let - cfg = config.niksos.desktop.enable && config.niksos.desktop.hyprland; -in { - config = lib.mkIf cfg { +}: { + config = lib.mkIf config.niksos.desktop.enable { # greetd display manager services.greetd = let session = { - command = "${lib.getExe config.programs.uwsm.package} start hyprland-uwsm.desktop"; + command = lib.mkDefault "${lib.getExe config.programs.uwsm.package} start hyprland-uwsm.desktop"; user = "jsw"; }; in { @@ -22,6 +20,6 @@ in { }; }; - programs.uwsm.enable = true; + programs.uwsm.enable = config.niksos.desktop.hyprland; }; } diff --git a/system/desktop/plasma6.nix b/system/desktop/plasma6.nix index 8f36529..cca4cce 100644 --- a/system/desktop/plasma6.nix +++ b/system/desktop/plasma6.nix @@ -6,28 +6,23 @@ }: let cfg = config.niksos.desktop.enable && config.niksos.desktop.kde; in { - config = lib.mkIf cfg { + specialisation.de.configuration = lib.mkIf cfg { niksos.desktop.hyprland = lib.mkForce false; - specialisation.de.configuration = { - services = { - greetd = let - session = { - command = "${pkgs.kdePackages.plasma-workspace}/bin/startplasma-wayland"; - user = "jsw"; - }; - in { - enable = true; - settings = { - terminal.vt = 1; - default_session = session; - initial_session = session; - }; + services = { + greetd = let + session.command = "${pkgs.kdePackages.plasma-workspace}/bin/startplasma-wayland"; + in { + enable = true; + settings = { + terminal.vt = 1; + default_session = session; + initial_session = session; }; - - desktopManager.plasma6.enable = true; }; - home-manager.users.jsw.stylix.autoEnable = false; + desktopManager.plasma6.enable = true; }; + + home-manager.users.jsw.stylix.autoEnable = false; }; } diff --git a/system/hardware/default.nix b/system/hardware/default.nix index 36678f4..f513c91 100644 --- a/system/hardware/default.nix +++ b/system/hardware/default.nix @@ -3,8 +3,10 @@ imports = [ ./bluetooth.nix - ./graphics.nix ./fingerprint.nix ./fwupd.nix + ./graphics.nix + ./joycond.nix + ./power.nix ]; } diff --git a/system/hardware/fingerprint.nix b/system/hardware/fingerprint.nix index 69b18ed..f3a16fc 100644 --- a/system/hardware/fingerprint.nix +++ b/system/hardware/fingerprint.nix @@ -11,10 +11,16 @@ in { options.niksos.fingerprint = mkEnableOption "fingerprint support."; config = mkIf fingerprint { - services.fprintd.enable = true; + services = { + fprintd.enable = true; + logind.extraConfig = mkIf desktop.hyprland '' + # don’t shutdown when power button is short-pressed + HandlePowerKey=ignore + ''; + }; home-manager.users.jsw.wayland.windowManager.hyprland.settings = mkIf desktop.hyprland { - bind = mkIf fingerprint [ + bind = [ ", XF86PowerOff, exec, ${uwsm} app -- pgrep fprintd-verify && exit 0 || ${foot} -a 'foot-fprintd' sh -c 'fprintd-verify && systemctl sleep'" ]; windowrule = [ diff --git a/system/hardware/joycond.nix b/system/hardware/joycond.nix new file mode 100644 index 0000000..a87d760 --- /dev/null +++ b/system/hardware/joycond.nix @@ -0,0 +1,12 @@ +{ + config, + lib, + ... +}: { + options.niksos.joycond = lib.mkEnableOption "support for nintendo switch controllers."; + + config.services = lib.mkIf config.niksos.joycond { + usbmuxd.enable = true; + joycond.enable = true; + }; +} diff --git a/system/hardware/power.nix b/system/hardware/power.nix new file mode 100644 index 0000000..0f22c63 --- /dev/null +++ b/system/hardware/power.nix @@ -0,0 +1,87 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (config) niksos; + cfg = niksos.portable; +in { + options.niksos.portable = { + enable = lib.mkEnableOption "battery optimisers"; + hyprland = let + gen = mode: + lib.mkOption { + default = ""; + description = "Shell commands to run when switching to ${mode} mode."; + type = lib.types.lines; + }; + in { + powerSaver = gen "power-saver"; + performance = gen "performance"; + }; + }; + config = { + services = lib.mkIf cfg.enable { + logind = { + powerKey = "suspend-then-hibernate"; + powerKeyLongPress = "poweroff"; + }; + upower.enable = true; + power-profiles-daemon.enable = true; + }; + + environment.systemPackages = lib.mkIf niksos.desktop.hyprland [ + (pkgs.writeScriptBin "powermode" '' + #!/usr/bin/env bash + + function sync() { + if [ "$(powerprofilesctl get)" = "power-saver" ]; then + hyprctl --batch "\ + keyword animations:enabled 0;\ + keyword decoration:shadow:enabled 0;\ + keyword decoration:blur:enabled 0;\ + keyword general:gaps_in 0;\ + keyword general:gaps_out 0;\ + keyword general:border_size 1;\ + keyword decoration:rounding 0" + + ${cfg.hyprland.powerSaver} + else + ${cfg.hyprland.performance} + hyprctl reload + fi + + } + function toggle() { + if [ "$(powerprofilesctl get)" = "power-saver" ]; then + powerprofilesctl set performance + else + powerprofilesctl set power-saver + fi + + sync + } + + if [ "$#" -ne 1 ]; then + echo "Usage: $0 {toggle|sync}" + exit 1 + fi + + case "$1" in + toggle) + toggle + ;; + sync) + sync + ;; + *) + echo "Invalid option: $1" + echo "Usage: $0 {toggle|sync}" + exit 1 + ;; + esac + '') + ]; + }; +} diff --git a/system/nix/substituters.nix b/system/nix/substituters.nix index 69845fa..17ac1a8 100644 --- a/system/nix/substituters.nix +++ b/system/nix/substituters.nix @@ -3,7 +3,7 @@ substituters = [ # high priority since it's almost always used "https://cache.nixos.org?priority=10" - "https://cache.garnix.io" + # "https://cache.garnix.io" # "https://anyrun.cachix.org" # "https://fufexan.cachix.org" @@ -16,7 +16,7 @@ trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= " + # "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= " # "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" # "fufexan.cachix.org-1:LwCDjCJNJQf5XD2BV+yamQIMZfcKWR9ISIFy5curUsY=" diff --git a/system/server/default.nix b/system/server/default.nix index e04a03e..5cd7cdd 100644 --- a/system/server/default.nix +++ b/system/server/default.nix @@ -1,4 +1,4 @@ {lib, ...}: { - imports = [./caddy.nix ./transfer-sh.nix ./seafile.nix ./bot.nix ./immich.nix ./matrix.nix ./mail.nix]; + imports = [./caddy.nix ./index ./seafile.nix ./bot.nix ./immich.nix ./matrix.nix ./mail.nix]; options.niksos.server = lib.mkEnableOption "server servcies (such as caddy)."; #TODO: per service option. } diff --git a/system/server/index/default.nix b/system/server/index/default.nix new file mode 100644 index 0000000..2cfd6f7 --- /dev/null +++ b/system/server/index/default.nix @@ -0,0 +1,14 @@ +{ + config, + lib, + ... +}: { + services.caddy.virtualHosts."jsw.tf" = lib.mkIf config.niksos.server { + extraConfig = '' + header Content-Type text/html + respond < + + + + + + + Under Construction + + + +

🚧🚧 This Site is Under Construction 🚧🚧

+

Hello! I'm jsw, a frontend web developer with experience in Svelte + TS, Nix(OS) and currently learning Rust. This site is still under development, so please bear with me. In the meantime, feel free to reach out via email or explore my projects on GitHub.

+
+

πŸ“§ info@jsw.tf

+

πŸ™ GitHub

+
+ + + + diff --git a/system/server/mail.nix b/system/server/mail.nix index b4b51ca..85e67e8 100644 --- a/system/server/mail.nix +++ b/system/server/mail.nix @@ -1,93 +1,29 @@ -{config, ...}: { - services.stalwart-mail = { - enable = true; - openFirewall = false; # Don't want to open port 8080, will leave that for caddy. - credentials = { - user_admin_password = config.age.secrets.mail-admin.path; - }; - settings = { - authentication = { - fallback-admin = { - secret = "%{file:/run/credentials/stalwart-mail.service/user_admin_password}%"; - user = "admin"; - }; - }; - server = { - tracer."log" = { - ansi = false; - enable = true; - level = "info"; - path = "./stalwart/logs"; - prefix = "stalwart.log"; - rotate = "daily"; - type = "log"; - }; - listener = { - http = { - bind = "127.0.0.1:9003"; - protocol = "http"; - }; - imaptls = { - bind = "[::]:993"; - protocol = "imap"; - tls.implicit = true; - }; - smtp = { - bind = "[::]:25"; - protocol = "smtp"; - }; - submissions = { - bind = "[::]:465"; - protocol = "smtp"; - tls.implicit = true; - }; - }; - }; +{ + config, + lib, + ... +}: { + #FIXME: revert when stopped using docker for stalwart. https://github.com/NixOS/nixpkgs/issues/416091 (look at older commits for previous code.) - hostname = "mx1.jsw.tf"; - lookup.default = { - hostname = "mx1.jsw.tf"; - domain = "jsw.tf"; + config = lib.mkIf config.niksos.server { + virtualisation.oci-containers.containers.stalwart = { + image = "docker.io/stalwartlabs/stalwart:latest"; + labels = { + "io.containers.autoupdate" = "registry"; }; - acme."letsencrypt" = { - directory = "https://acme-v02.api.letsencrypt.org/directory"; - challenge = "tls-alpn-01"; - contact = ["jurnwubben@gmail.com"]; - domains = ["jsw.tf" "mx1.jsw.tf"]; - cache = "%{BASE_PATH}%/etc/acme"; - renew-before = "30d"; - }; - directory."imap".lookup.domains = ["jsw.tf"]; - # directory."in-memory" = { - # type = "memory"; - # principals = [ - # { - # class = "individual"; - # name = "User 1"; - # secret = "%{file:/etc/stalwart/mail-pw1}%"; - # email = [""]; - # } - # ]; - # }; - }; - }; - networking.firewall.allowedTCPPorts = [ - 993 - 25 - 465 - ]; - - services.caddy.virtualHosts = { - "webadmin.jsw.tf" = { - extraConfig = '' - reverse_proxy http://127.0.0.1:9003 - ''; - serverAliases = [ - "mta-sts.jsw.tf" - "autoconfig.jsw.tf" - "autodiscover.jsw.tf" - "mail.jsw.tf" + ports = ["25:25" "465:465" "993:993" "9003:8080"]; + volumes = [ + "/opt/stalwart:/opt/stalwart" ]; }; + networking.firewall.allowedTCPPorts = [ + 993 + 25 + 465 + ]; + + services.caddy.virtualHosts."mail.jsw.tf".extraConfig = '' + reverse_proxy http://127.0.0.1:9003 + ''; }; } diff --git a/system/server/transfer-sh.nix b/system/server/transfer-sh.nix deleted file mode 100644 index b282ee2..0000000 --- a/system/server/transfer-sh.nix +++ /dev/null @@ -1,25 +0,0 @@ -{config, ...}: { - services.transfer-sh = { - enable = config.niksos.server; - settings = { - PURGE_DAYS = 7; - MAX_UPLOAD_SIZE = 4 * 1000 * 1000; # 4gb - # CORS_DOMAINS = "transfer.jsw.tf"; #FIXME: open it to the world wide web. - BASEDIR = "/var/lib/transfer.sh"; - LISTENER = ":9000"; - HTTP_AUTH_USER = "jsw"; - EMAIL_CONTACT = "jurnwubben@gmail.com"; - }; - secretFile = config.age.secrets.transferSh.path; - }; - systemd.services.transfer-sh.serviceConfig = { - StateDirectory = "transfer.sh"; - StateDirectoryMode = "0750"; - }; - - services.caddy.virtualHosts."share.jsw.tf" = { - extraConfig = '' - reverse_proxy :9000 - ''; - }; -} diff --git a/system/services/default.nix b/system/services/default.nix index faf6a2f..55f0218 100644 --- a/system/services/default.nix +++ b/system/services/default.nix @@ -3,7 +3,6 @@ ./tailscale.nix ./avahi.nix ./kanata.nix - ./power.nix ./ssh.nix ]; } diff --git a/system/services/power.nix b/system/services/power.nix deleted file mode 100644 index 087f1e0..0000000 --- a/system/services/power.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - config, - lib, - ... -}: { - options.niksos.portable = lib.mkEnableOption "battery optimisers"; - config.services = lib.mkIf config.niksos.portable { - logind = { - powerKey = "suspend-then-hibernate"; - powerKeyLongPress = "poweroff"; - }; - upower.enable = true; - power-profiles-daemon.enable = true; - }; -} diff --git a/system/services/ssh.nix b/system/services/ssh.nix index 574d769..fddd575 100644 --- a/system/services/ssh.nix +++ b/system/services/ssh.nix @@ -1,7 +1,7 @@ {config, ...}: { services.openssh = { enable = true; - openFirewall = !config.niksos.portable; + openFirewall = !config.niksos.portable.enable; settings.UseDns = true; }; }