From d2aecd69c17fa64305c07333686576152432993d Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Wed, 15 Jul 2026 12:03:58 -0500 Subject: changes. --- AGENTS.md | 149 --------------------- flake.lock | 16 ++- flake.nix | 2 +- hosts.toml | 10 +- hosts/ganymede/caddy.nix | 15 ++- hosts/ganymede/config.nix | 9 ++ hosts/ganymede/iwlwifi.nix | 23 ---- hosts/ganymede/nixos.nix | 14 +- .../ganymede/secrets/collin-copyparty-password.age | 7 - hosts/ganymede/secrets/collin-forgejo-password.age | 7 - hosts/ganymede/secrets/copilot-token.age | 11 -- hosts/ganymede/secrets/ganymede-wg-key.age | 5 - hosts/ganymede/secrets/tsnsrv-authkey.age | 7 - hosts/ganymede/secrets/wg-privkey.age | 12 ++ hosts/ganymede/secrets/wireguard-privkey.age | 8 -- hosts/ganymede/wireguard.nix | 57 ++++++++ hosts/mercury/config.nix | 24 ++-- hosts/mercury/hjem.nix | 2 +- hosts/mercury/nixos.nix | 64 +-------- hosts/mercury/secrets/wg-privkey.age | 9 ++ hosts/mercury/wireguard.nix | 54 ++++++++ modules/desktop/nixos/fonts.nix | 2 +- modules/desktop/nixos/programs/firefox.nix | 19 ++- modules/services/nixos/default.nix | 1 + modules/services/nixos/glance.nix | 145 ++++++++++++++++++++ modules/services/nixos/openssh.nix | 96 ++++--------- modules/services/nixos/qbittorrent.nix | 2 +- modules/services/options.nix | 6 + modules/system/nixos/boot.nix | 3 +- modules/system/nixos/networking/resolved.nix | 36 +---- modules/user/nixos/default.nix | 2 +- pkgs/obsidian.nix | 24 ---- secrets.nix | 5 +- tmux-tsunami/flake.lock | 42 ------ tmux-tsunami/flake.nix | 18 --- tmux-tsunami/modules/common/bar.nix | 69 ---------- tmux-tsunami/modules/common/defaultGlobalKeys.nix | 66 --------- tmux-tsunami/modules/common/defaultLeaderMenu.nix | 51 ------- tmux-tsunami/modules/common/findFile.nix | 66 --------- tmux-tsunami/modules/common/fzfExec.nix | 55 -------- tmux-tsunami/modules/common/keys.nix | 66 --------- tmux-tsunami/modules/common/main.nix | 23 ---- tmux-tsunami/modules/common/sessionizer.nix | 92 ------------- tmux-tsunami/modules/common/sessionizer2.nix | 50 ------- tmux-tsunami/modules/hjem.nix | 58 -------- tmux-tsunami/modules/installer.nix | 38 ------ tmux-tsunami/planning.md | 56 -------- 47 files changed, 396 insertions(+), 1200 deletions(-) delete mode 100644 AGENTS.md delete mode 100644 hosts/ganymede/iwlwifi.nix delete mode 100644 hosts/ganymede/secrets/collin-copyparty-password.age delete mode 100644 hosts/ganymede/secrets/collin-forgejo-password.age delete mode 100644 hosts/ganymede/secrets/copilot-token.age delete mode 100644 hosts/ganymede/secrets/ganymede-wg-key.age delete mode 100644 hosts/ganymede/secrets/tsnsrv-authkey.age create mode 100644 hosts/ganymede/secrets/wg-privkey.age delete mode 100644 hosts/ganymede/secrets/wireguard-privkey.age create mode 100644 hosts/ganymede/wireguard.nix create mode 100644 hosts/mercury/secrets/wg-privkey.age create mode 100644 hosts/mercury/wireguard.nix create mode 100644 modules/services/nixos/glance.nix delete mode 100644 pkgs/obsidian.nix delete mode 100644 tmux-tsunami/flake.lock delete mode 100644 tmux-tsunami/flake.nix delete mode 100644 tmux-tsunami/modules/common/bar.nix delete mode 100644 tmux-tsunami/modules/common/defaultGlobalKeys.nix delete mode 100644 tmux-tsunami/modules/common/defaultLeaderMenu.nix delete mode 100644 tmux-tsunami/modules/common/findFile.nix delete mode 100644 tmux-tsunami/modules/common/fzfExec.nix delete mode 100644 tmux-tsunami/modules/common/keys.nix delete mode 100644 tmux-tsunami/modules/common/main.nix delete mode 100644 tmux-tsunami/modules/common/sessionizer.nix delete mode 100644 tmux-tsunami/modules/common/sessionizer2.nix delete mode 100644 tmux-tsunami/modules/hjem.nix delete mode 100644 tmux-tsunami/modules/installer.nix delete mode 100644 tmux-tsunami/planning.md diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 3b8f4e5..0000000 --- a/AGENTS.md +++ /dev/null @@ -1,149 +0,0 @@ -# AGENTS.md - -Guidance for coding agents working in this repository. - -## 1) Repository Purpose -- NixOS flake repo with host configs, reusable modules, and local packages. -- Most edits happen in `hosts/`, `modules/`, `lib/`, and `pkgs/`. -- Includes a standalone Go project at `pkgs/jta/`. -- Make focused changes; avoid unrelated refactors. - -## 2) AI Rule Files (Cursor/Copilot) -- `.cursor/rules/`: not found. -- `.cursorrules`: not found. -- `.github/copilot-instructions.md`: not found. -- There are no repository-specific Cursor/Copilot instruction files to apply. - -## 3) Key Paths -- `flake.nix`: flake inputs/outputs and host definitions. -- `hosts//config.nix`: host-level entrypoints. -- `modules/`: homogenous module tree. -- `lib/nix-furnace/mkSystem.nix`: system composition. -- `lib/lib.nix`: shared helpers (`my-lib`). -- `pkgs/yo/`: Ruby deployment/build helper. -- `pkgs/jta/`: Go module. -- `justfile`: command shortcuts. - -## 4) Build Commands -Run from `/home/collin/nixos` unless noted. - -NixOS commands: -- `yo build` -- `yo build ` -- `yo switch` or `yo sw` -- `yo boot` -- `yo test` -- `yo deploy ` or `yo dep ` - -Direct Nix commands: -- `nix build .#nixosConfigurations..config.system.build.toplevel` -- `nix build .#docs` -- `nix build` - -Just shortcuts: -- `just build` -- `just switch` -- `just deploy` - -Go project (`pkgs/jta`): -- `go build ./...` -- `go run .` - -## 5) Lint and Formatting -Nix: -- `nix run nixpkgs#alejandra -- .` -- Prefer formatting only touched files. - -Go (`pkgs/jta`): -- `gofmt -w .` -- `go vet ./...` - -Validation defaults: -- After Nix changes, run a host build. -- After Go changes, run build and tests. - -## 6) Test Commands -Repository-wide: -- No single root test harness is configured. -- Nix host builds are primary verification. - -Nix checks: -- `yo build ` -- `nix build .#nixosConfigurations..config.system.build.toplevel` - -Go tests (`pkgs/jta`): -- Run all tests: `go test ./...` -- Run single test name: `go test ./... -run '^TestName$'` -- Run single test in current package: `go test . -run '^TestName$'` - -## 7) Architectural Conventions -- Preserve homogenous module layout: - - `options.nix` for option definitions. - - `nixos/default.nix` for NixOS implementation. - - `hjem/default.nix` for hjem implementation. -- Keep custom options under `collinux.*`. -- Keep host configs declarative. -- Reuse existing helper patterns before creating new abstractions. - -## 8) Code Style -General: -- Match style of the touched file. -- Keep diffs minimal and intentional. -- Prefer explicit naming over abbreviations. -- Add comments only for non-obvious logic. - -Nix style: -- 2-space indentation; no tabs. -- Common arg pattern: `{ lib, config, pkgs, ... }:`. -- Use `cfg = config.collinux.;` when it improves clarity. -- Use `lib.mkIf` for option-gated config. -- Prefer typed options (`types.port`, `types.nullOr`, submodules). -- Keep imports stable and readable (usually one per line). -- Use `inherit (lib) ...` where idiomatic. - -Imports/dependencies: -- Prefer relative imports in module trees (`./foo.nix`). -- Avoid circular dependencies. -- Reuse `my-lib` helpers from `lib/lib.nix` when possible. - -Go style (`pkgs/jta`): -- Keep code gofmt-clean. -- Preserve gofmt import ordering/grouping. -- Prefer early error returns. -- Use standard `net/http` helpers consistently. - -Ruby style (`pkgs/yo`): -- snake_case for methods/locals; CamelCase for classes/modules. -- Validate CLI args and fail fast (`abort` with clear message). -- Do not hide command failures. - -Lua style (`pkgs/yossh`, `pkgs/util`): -- Follow local naming conventions (mostly snake_case). -- Keep helpers small and composable. -- Raise clear errors instead of ambiguous nil behavior. - -## 9) Types, Naming, and Error Handling -- Use explicit Nix option types whenever practical. -- Option naming: lower camelCase segments under `collinux`. -- File naming: lowercase; hyphenate when local pattern uses it. -- Fail early with actionable error messages. -- Do not swallow build/deploy/switch failures. - -## 10) Secrets and Safety -- Never commit plaintext secrets. -- Preserve agenix and `.age` workflows. -- Treat `hosts/*/secrets/*` and `*.age` as sensitive. -- Do not weaken security defaults without explicit intent. - -## 11) Workflow for Agents -- Read adjacent files before editing. -- Follow established patterns first. -- Validate the smallest meaningful scope. -- Update docs when command behavior changes. - -## 12) Definition of Done -- Affected targets build/evaluate successfully. -- Formatting and style are consistent. -- New options are typed appropriately. -- No plaintext secrets introduced. -- This AGENTS guide remains accurate. diff --git a/flake.lock b/flake.lock index 01631b4..b644039 100644 --- a/flake.lock +++ b/flake.lock @@ -468,14 +468,18 @@ ] }, "locked": { - "path": "./tmux-tsunami", - "type": "path" + "lastModified": 1784116563, + "narHash": "sha256-D4WE/Lq6DDTCRIcvaV8ea288wZa7nc1uSst4uXgOnM8=", + "ref": "refs/heads/main", + "rev": "3e15502bcb48f2ab010a4f5d0a13771474b06f28", + "revCount": 2, + "type": "git", + "url": "https://git.ganymede/tmux-tsunami" }, "original": { - "path": "./tmux-tsunami", - "type": "path" - }, - "parent": [] + "type": "git", + "url": "https://git.ganymede/tmux-tsunami" + } }, "uc-css-js": { "flake": false, diff --git a/flake.nix b/flake.nix index d753b56..1da093b 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,7 @@ }; tmux-tsunami = { - url = "./tmux-tsunami"; + url = "git+https://git.ganymede/tmux-tsunami"; inputs.nixpkgs.follows = "nixpkgs"; }; diff --git a/hosts.toml b/hosts.toml index 3f660a9..31153fd 100644 --- a/hosts.toml +++ b/hosts.toml @@ -2,20 +2,22 @@ user_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAvxtKW0rmRBi8J67gLrLv8Zv338AcmZ3P20DePiUfnX collin@mercury" host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIQtMAgPdWwrOzlZT/lEIRQZ+ajhafG9AEJCrF2/bsmN" -wg_pubkey = "merTd71QvuMVQiRix/0NPAjVDvwRyLor20t+N9dDSEU=" +wg_pubkey = "JOeHQM6y6znsyze55jjLLMPWAbAyD8rbe04UBL45GiQ=" +wg_ip = "10.100.0.5" [hosts.ganymede] hostnames = ["ganymede", "192.168.50.2", "williamsfam.us.com"] user_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFeAsRh11Jyv+7Fm4WhzV4XN0LMYQS1/yMbvT+pvFDcd collin@ganymede" host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINlr+53UmlGVP1blkdNl6NFqn1w2umFJyjH1EVUPKIy9" -wg_pubkey = "ganyuu2I5DY1VQm3fPvQGBI2veW43Rgs3lAVzckWR2I=" +wg_pubkey = "7BdBTJ/FQUOPjSU+Q1Ieg9VqMd2y8BCMqk61I5rMAnY=" +wg_ip = "10.100.0.1" [hosts.terra] user_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINKwMBLWWxpf4jZN3R3iQ7XEAOMq0KAOE/6YN4iTBuJx collin@terra" -wg_pubkey = "ter/93FM8jf5b73+psVuU5cVNaoy00Z/wB6XGrvH1G8=" -wg_privkey = "yBiEnhSZZInc+irnVhZNHF5y7Z7tsR/IS6j32F4tPWc=" +wg_pubkey = "CWsD6IJYAbbAX756zb5TlChjEJEm0Q3KpeakfuaZIyA=" +wg_ip = "10.100.0.24" [hosts.io] hostnames = ["io", "192.168.50.3"] diff --git a/hosts/ganymede/caddy.nix b/hosts/ganymede/caddy.nix index a03fcdc..3a805f4 100644 --- a/hosts/ganymede/caddy.nix +++ b/hosts/ganymede/caddy.nix @@ -19,8 +19,21 @@ } ''; + virtualHosts."lindsey.williamsfam.us.com".extraConfig = '' + redir https://williams-ryan-lindsey.blogspot.com permanent + ''; + + virtualHosts."daniel.williamsfam.us.com".extraConfig = '' + root * /media/public/www/daniel + file_server + ''; + + # virtualHosts."collin.williamsfam.us.com".extraConfig = '' + # root * /med + # ''; + virtualHosts."williamsfam.us.com".extraConfig = '' - root * /media/public/www + root * /media/public/www/root file_server ''; }; diff --git a/hosts/ganymede/config.nix b/hosts/ganymede/config.nix index 8150e14..0858106 100644 --- a/hosts/ganymede/config.nix +++ b/hosts/ganymede/config.nix @@ -9,6 +9,11 @@ }; "caddy-env".file = ./secrets/caddy-env.age; + + "wireguard-privkey" = { + file = ./secrets/wg-privkey.age; + owner = "systemd-network"; + }; }; terminal = { @@ -84,6 +89,10 @@ enable = true; privateUrl = "git.ganymede"; }; + glance = { + enable = true; + port = 8081; + }; caddy = { enable = true; diff --git a/hosts/ganymede/iwlwifi.nix b/hosts/ganymede/iwlwifi.nix deleted file mode 100644 index 729034f..0000000 --- a/hosts/ganymede/iwlwifi.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - # Append Kernel modules - boot.kernelModules = [ - "brcmfmac" - "brcmutil" - "iwlmvm" - "iwlwifi" - "mmc_core" - "mt76_usb" - "mt76" - "mt76x0_common" - "mt76x02_lib" - "mt76x02_usb" - "mt76x0u" - "r8188eu" - "rtl_usb" - "rtl8192c_common" - "rtl8192cu" - "rtlwifi" - ]; - hardware.enableAllFirmware = true; - hardware.enableRedistributableFirmware = true; -} diff --git a/hosts/ganymede/nixos.nix b/hosts/ganymede/nixos.nix index 77e3ad5..d913df7 100644 --- a/hosts/ganymede/nixos.nix +++ b/hosts/ganymede/nixos.nix @@ -9,24 +9,12 @@ inputs.disko.nixosModules.disko inputs.nixos-facter-modules.nixosModules.facter ./disks.nix - - ./iwlwifi.nix ./caddy.nix + ./wireguard.nix ]; facter.reportPath = ./facter.json; - environment.systemPackages = [ - pkgs.python313 - pkgs.net-tools - ]; - - # backup usb teather configuration - systemd.network.networks."80-usb-teather" = { - name = "enp0s20f0u2"; - networkConfig.DHCP = "yes"; - }; - systemd.services."disable-wifi-powersave" = { description = "Disable wifi powersaving using iw"; after = ["network.target"]; diff --git a/hosts/ganymede/secrets/collin-copyparty-password.age b/hosts/ganymede/secrets/collin-copyparty-password.age deleted file mode 100644 index af3ae6c..0000000 --- a/hosts/ganymede/secrets/collin-copyparty-password.age +++ /dev/null @@ -1,7 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 azBilg hZH7PIwhHf7XWaPmri/OvgvJtlPEip5lqfFf77NKCVE -gbqmQLIN9edp8Om4VXD6wkI0+OymOcbBiKnunUXgqM0 --> ssh-ed25519 Jg4yWQ 0DeQ/sVqXTYjTBZS+lXVZWLDHYSYz836nbfNXejEdmQ -/b4pRvTK2+42G4Vp3WKun99pxGxYzAE3PzSD86Q5lVw ---- rXCPzVmtD1TorsW0ZV17ciC5y4rq5ZJDSm+1ssu+uVw -ygp]r͗|f)܊~ ssh-ed25519 azBilg vmw/nKIBoQoNUFX5L/30ll21pT0pC2aj/w2qjTc2nSM -x4udezFrc1+YG2ejgSVL6iIdPUgkiUeYxl0nijurqmE --> ssh-ed25519 Jg4yWQ X6KPKYcqIzzllcP96/VdMH+SHzvwy5L2Yf8VIjL7GRg -ZREY05ecsxqutY2VEktNqwX8pXvmXnVL8M9FnlIkQy4 ---- MGA/XzVEB308uJE/c/bLe0GKrLDVSxciKxTV54S4oDM -#;brLܐ&̓]WD5m ЃG`B6b \ No newline at end of file diff --git a/hosts/ganymede/secrets/copilot-token.age b/hosts/ganymede/secrets/copilot-token.age deleted file mode 100644 index 7dd6e51..0000000 --- a/hosts/ganymede/secrets/copilot-token.age +++ /dev/null @@ -1,11 +0,0 @@ ------BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IEpnNHlXUSBDSlBB -cXJaNHU0V3VjVnB5czdya0lYMjBTdFFWRlhvWE5lVTRJenBhL3hRCmREcnJwUEo4 -UDVXQTFxdkk3ZXJrVE05cGZWT040U282bldhcm5QVkdSWW8KLT4gUCl4fUBGLWdy -ZWFzZSB4LHJZRVt7ICVYIjVGdlVbICR6fCBkdAp4T0pZM1hBRm9WcmFFQjJqaW9Y -Z2x5cE9mQk83U0pDRzdMUXozTkxjUC9FaW5MOUM4NjM3SlhTTnJvVldjK01KCm03 -TTBFdGtEWkZHVmc4RDVMc1QrNndNR2FHOXRreW5FZEhYdG9BdWZpYVBBb0ZSSFl2 -bFN1UUFWCi0tLSBVaUpmVjhibW5jWW9nS2pJV1JXVjJaZ2JYZ0VHQkY0emwrd1NL -QXFpNmN3Cv69mt8dZSWNQqM8qDledKrYS7PBZDoIXy+FivL42kaUxF0jXjHXefED -DsjubBCEK0OiAh6nyvuEn9wbSkaALmpqjMARM32QyAOiam2skY0LB8E= ------END AGE ENCRYPTED FILE----- diff --git a/hosts/ganymede/secrets/ganymede-wg-key.age b/hosts/ganymede/secrets/ganymede-wg-key.age deleted file mode 100644 index 2ef8256..0000000 --- a/hosts/ganymede/secrets/ganymede-wg-key.age +++ /dev/null @@ -1,5 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 Jg4yWQ PMAfdBRZ9mLnral4UdHEtr3QWmk8j9lKek6XH8L6QCk -B342qgV/kGHvIt3hm8Yyd0yw7nHJ1kqV3UGLREhWbKA ---- mOBS3t1P5ZAIV8llDldbGC+F855Xy3Jd5V8tVrwisig -L\đg5w\̃9 A:= bLnOc" ssh-ed25519 Jg4yWQ NYO6CUksU6appmdib7CER3YYbcKoyn0wmB4YGTCeTE0 -tizx14UdvQftYrkDa3iXQYDp6JPWHfjDmFwjr11FBxQ --> ssh-ed25519 azBilg 3PYXHVdB2y2Y42ijOiv8LJ9c4WmeB5ivEPcehfS3Wns -tP/xCHzd31DydF5aCn1tJGudanXLl+DIPod7KFtglXQ ---- nbch7DRt1CYKBqzE9CeUIJgTMKIUCEA/CXVQZjkywfI -~}H <42)U{QK3%G^FW3GJy 1 \ No newline at end of file diff --git a/hosts/ganymede/secrets/wg-privkey.age b/hosts/ganymede/secrets/wg-privkey.age new file mode 100644 index 0000000..398a4b2 --- /dev/null +++ b/hosts/ganymede/secrets/wg-privkey.age @@ -0,0 +1,12 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IGF6QmlsZyBQS20w +cEVsZkNQN3pkNm5mLzhIbEQ0ejVmcG9Md1d5YWd4WXBKa0tON3lZCk80a2lmQ3Zw +ZGlCRjZwdG5GY25RWFZrMktZYVZoWHZMeHFHUnJXSUlFa2sKLT4gc3NoLWVkMjU1 +MTkgSmc0eVdRIEIvcGNuVDVJWHV5UHpNMklXME1Sd2drNDYrTVk5aFUrbUN5SVVT +dVhSVEUKRG92b2NxZ0oxT3h0UGttZmhHb3gxT1VIMFVzOUQvSCt5RGEyL2NSRmp5 +SQotPiB2fGhLSSQuLWdyZWFzZQo5WlBvV1pWRkkvaTRHS0lha0R5R3A0cFFJbm04 +cTNGamZMNnlFMkZndy9QTlFlckZBd2J2eWt6R3l6MTVER0RQCkdrbG10bTRyMTZi +cQotLS0gazNldzNoSU1VOFdCTklsRFhjNVF6a2d5YlA2Q3gxdUVNbFFwU0dRSGhK +WQosSz+PG1ZS0BTINC2BVnJLFApgLIpos8pYgQz7MYdtcVrOSbhRA1VKxGT1zy3p +7o4Eu4MYzC9a7qmq547UKN0sjHhDRlmi9aH7zshN2A== +-----END AGE ENCRYPTED FILE----- diff --git a/hosts/ganymede/secrets/wireguard-privkey.age b/hosts/ganymede/secrets/wireguard-privkey.age deleted file mode 100644 index ee9130d..0000000 --- a/hosts/ganymede/secrets/wireguard-privkey.age +++ /dev/null @@ -1,8 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 azBilg tvscfH96l4w2AkLjaczmtAJ3CKeU1mEPJWT82tR2HiY -F83pJqPj+qlFw4nb+ANCMJ7lOufSMluDIeWbaYvJkEU --> ssh-ed25519 Jg4yWQ SXz2kA4FODscXLqsNsCjuqKqBUXSkEx5SIpSdjGKpQU -mVg50RgaBauKlTCyHUYDTPZYnDJkppOthhMC+MAsiiE ---- dlTzxZODPVxlkdRP3HRJSK6BU3yEHrs1fo/sudC6EKo -dEV!Axr?z(YKمSukst]Mjzψ\D\Bs./2= \ No newline at end of file diff --git a/hosts/ganymede/wireguard.nix b/hosts/ganymede/wireguard.nix new file mode 100644 index 0000000..a1be5f7 --- /dev/null +++ b/hosts/ganymede/wireguard.nix @@ -0,0 +1,57 @@ +{ + config, + hosts, + pkgs, + ... +}: { + environment.systemPackages = [pkgs.wireguard-tools]; + + services.dnsmasq = { + enable = true; + settings = { + port = 5353; + local = "/ganymede/"; + address = "/.ganymede/10.100.0.1"; + listen-address = ["127.0.0.1" "10.100.0.1"]; + }; + }; + + boot.kernel.sysctl."net.ipv4.ip_forward" = 1; + + networking.firewall.allowedUDPPorts = [51820 5353]; + systemd.network.netdevs."50-wg0" = { + netdevConfig = { + Kind = "wireguard"; + Name = "wg0"; + MTUBytes = "1300"; + }; + wireguardConfig = { + PrivateKeyFile = config.collinux.secrets."wireguard-privkey".path; + ListenPort = 51820; + }; + wireguardPeers = [ + { + PublicKey = hosts.mercury.wg_pubkey; + AllowedIPs = ["${hosts.mercury.wg_ip}/32"]; + } + { + PublicKey = hosts.terra.wg_pubkey; + AllowedIPs = ["${hosts.terra.wg_ip}/32"]; + } + ]; + }; + systemd.network.networks."wg0" = { + matchConfig.Name = "wg0"; + address = ["${hosts.ganymede.wg_ip}/24"]; + dns = ["127.0.0.1:5353"]; + domains = ["~ganymede"]; + networkConfig = { + IPMasquerade = "ipv4"; + IPv4Forwarding = true; + }; + extraConfig = '' + DNSOverTLS=no + DNSSEC=no + ''; + }; +} diff --git a/hosts/mercury/config.nix b/hosts/mercury/config.nix index a1faded..ef383d7 100644 --- a/hosts/mercury/config.nix +++ b/hosts/mercury/config.nix @@ -2,7 +2,12 @@ collinux = { theme = "catppuccin"; - secrets = {}; + secrets = { + "wireguard-privkey" = { + file = ./secrets/wg-privkey.age; + owner = "systemd-network"; + }; + }; user.useRun0 = true; @@ -17,32 +22,28 @@ greetd = { enable = true; autologin.enable = true; + # cosmic-greeter.enable = true; }; wm = { niri.enable = true; - # sway.enable = true; kdeDesktopPortal.enable = true; - components = { - fuzzel.enable = true; - }; + components.fuzzel.enable = true; # noctalia launcher SUCKS }; programs = { - firefox = { - enable = true; - extensions.foxyproxy.enable = true; - }; - foot.enable = true; - + firefox.enable = true; research.enable = true; + + foot.enable = true; }; }; system = { boot = { systemd-boot.enable = true; + plymouth.enable = true; secureBoot.enable = true; }; @@ -65,7 +66,6 @@ bat.enable = true; eza.enable = true; broot.enable = true; - tmux.enable = true; helix = { enable = true; hardMode = true; diff --git a/hosts/mercury/hjem.nix b/hosts/mercury/hjem.nix index b1ca4d9..75784d4 100644 --- a/hosts/mercury/hjem.nix +++ b/hosts/mercury/hjem.nix @@ -3,7 +3,7 @@ anki libreoffice-qt musescore - (pkgs.callPackage ../../pkgs/obsidian.nix {}) + obsidian noctalia-shell diff --git a/hosts/mercury/nixos.nix b/hosts/mercury/nixos.nix index 764f6f5..5937aeb 100644 --- a/hosts/mercury/nixos.nix +++ b/hosts/mercury/nixos.nix @@ -1,76 +1,25 @@ -{ - lib, - inputs, - pkgs, - ... -}: { +{inputs, ...}: { imports = [ ./disks.nix ./battery.nix + ./wireguard.nix + inputs.nixos-facter-modules.nixosModules.facter inputs.lanzaboote.nixosModules.lanzaboote ]; facter.reportPath = ./facter.json; - services.dbus.implementation = "broker"; services.upower.enable = true; - environment.defaultPackages = lib.mkForce []; # im not a noob - programs.ssh.extraConfig = '' Host ganymede - HostName williamsfam.us.com + HostName 10.100.0.1 Port 22 ''; - virtualisation.podman = { - enable = true; - dockerCompat = true; - }; - users.users.collin = { - extraGroups = ["podman"]; - subGidRanges = [ - { - count = 65536; - startGid = 100000; - } - ]; - subUidRanges = [ - { - count = 65536; - startUid = 100000; - } - ]; - }; - virtualisation.waydroid = { - package = pkgs.waydroid-nftables; - enable = true; - }; - programs.kdeconnect.enable = true; - services.autossh.sessions = [ - { - name = "ganymede"; - user = "collin"; - monitoringPort = 20000; - extraArguments = "-N -D 9090 collin@ganymede"; - } - ]; - boot.supportedFilesystems."fuse.sshfs" = true; - fileSystems."/home/collin/ganymede" = { - device = "collin@ganymede:/media"; - fsType = "fuse.sshfs"; - options = [ - "identityfile=/home/collin/.ssh/id_ed25519" - "idmap=user" - "x-systemd.automount" # mount the filesystem automatically on first access - "allow_other" # don't restrict access to only the user which `mount`s it (because that's probably systemd who mounts it, not you) - "user" # allow manual `mount`ing, as ordinary user. - ]; - }; - security.pki.certificates = [ '' -----BEGIN CERTIFICATE----- @@ -87,7 +36,6 @@ '' ]; - virtualisation.vmVariant = { - virtualisation.diskSize = 8192; - }; + # required for vm testing + virtualisation.vmVariant.virtualisation.diskSize = 8192; } diff --git a/hosts/mercury/secrets/wg-privkey.age b/hosts/mercury/secrets/wg-privkey.age new file mode 100644 index 0000000..767692f --- /dev/null +++ b/hosts/mercury/secrets/wg-privkey.age @@ -0,0 +1,9 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IGF6QmlsZyA0L2Ry +ZXZFOUxvL25CemdScnhEc3Ewb0NVUnBCNHZ5WjlNaDgwMVQxL0VzCmFoWTlQM0N6 +aFBSK05qZ3pKazF1a1BhRDBudkUwQmVpOHNsemUzazV4REkKLT4gbTtrJiw4Qy1n +cmVhc2UKazJ3UW9zQmh6RlBlTmpmekduUlpMSHl4TGgvcUJKTnB6aE43YTJDR2Vm +SHZVMGsKLS0tIFpnV21lOE9ZYUtwUFBVeGFWRDVMNFpkSStsSmpIaWZ3MHJVL29G +dzA2SXMKuuAvweyyyuIFVJftn6tNANBkHp0NGxJZ0LXTj+daziYleOUFn3R1KTVu +0UMQIZM/WsfesWXkvN1E4+LZKTdNdJOsEJv9ahYnk8btBgU= +-----END AGE ENCRYPTED FILE----- diff --git a/hosts/mercury/wireguard.nix b/hosts/mercury/wireguard.nix new file mode 100644 index 0000000..268cdc6 --- /dev/null +++ b/hosts/mercury/wireguard.nix @@ -0,0 +1,54 @@ +{ + config, + hosts, + pkgs, + ... +}: { + environment.systemPackages = [pkgs.wireguard-tools]; + + networking.firewall.interfaces."wg0" = { + allowedTCPPortRanges = [ + { + from = 1714; + to = 1764; + } + ]; + allowedUDPPortRanges = [ + { + from = 1714; + to = 1764; + } + ]; + }; + + systemd.network.netdevs."10-wg" = { + netdevConfig = { + Kind = "wireguard"; + Name = "wg0"; + MTUBytes = "1300"; + }; + wireguardConfig = { + PrivateKeyFile = config.collinux.secrets."wireguard-privkey".path; + ListenPort = 9918; + }; + wireguardPeers = [ + { + PublicKey = hosts.ganymede.wg_pubkey; + AllowedIPs = ["10.100.0.0/24"]; + Endpoint = "williamsfam.us.com:51820"; + } + ]; + }; + systemd.network.networks."wg0" = { + matchConfig.Name = "wg0"; + address = ["${hosts.mercury.wg_ip}/24"]; + DHCP = "no"; + dns = ["${hosts.ganymede.wg_ip}:5353"]; + domains = ["~ganymede"]; + networkConfig.IPv6AcceptRA = false; + extraConfig = '' + DNSOverTLS=no + DNSSEC=no + ''; + }; +} diff --git a/modules/desktop/nixos/fonts.nix b/modules/desktop/nixos/fonts.nix index d2e8ba9..e740bf1 100644 --- a/modules/desktop/nixos/fonts.nix +++ b/modules/desktop/nixos/fonts.nix @@ -2,6 +2,6 @@ fonts = { enableDefaultPackages = false; fontconfig.enable = true; - packages = [pkgs.nerd-fonts.iosevka pkgs.ibm-plex pkgs.liberation_ttf]; # for terminal (blackbox or foot or ghostty) + packages = [pkgs.nerd-fonts.iosevka pkgs.ibm-plex pkgs.liberation_ttf pkgs.rubik]; # for terminal (blackbox or foot or ghostty) }; } diff --git a/modules/desktop/nixos/programs/firefox.nix b/modules/desktop/nixos/programs/firefox.nix index 9e2b8ca..8267857 100644 --- a/modules/desktop/nixos/programs/firefox.nix +++ b/modules/desktop/nixos/programs/firefox.nix @@ -23,9 +23,23 @@ in OverrideFirstRunPage = ""; OverridePostUpdatePage = ""; - NewTabPage = false; - SearchEngines.Default = "DuckDuckGo"; + Homepage = { + URL = "https://home.ganymede"; + Locked = true; + StartPage = "homepage-locked"; + }; + + AIControls = { + Default = { + Value = "blocked"; + Locked = true; + }; + Translations = { + Value = "available"; + Locked = true; + }; + }; Preferences = let opt = Value: { @@ -97,7 +111,6 @@ in "media.webspeech.synth.dont_notify_on_error" = opt true; "datareporting.policy.dataSubmissionPolicyBypassNotification" = opt true; - "browser.startup.homepage" = opt "about:blank"; "browser.compactmode.show" = opt true; "browser.uidensity" = opt 1; diff --git a/modules/services/nixos/default.nix b/modules/services/nixos/default.nix index 68ed3ee..65315cf 100644 --- a/modules/services/nixos/default.nix +++ b/modules/services/nixos/default.nix @@ -8,6 +8,7 @@ ./cgit ./ganyupload ./jta + ./glance.nix ./minecraft.nix ./ngircd.nix diff --git a/modules/services/nixos/glance.nix b/modules/services/nixos/glance.nix new file mode 100644 index 0000000..1396562 --- /dev/null +++ b/modules/services/nixos/glance.nix @@ -0,0 +1,145 @@ +{ + pkgs, + config, + lib, + ... +}: let + cfg = config.collinux.services.glance; + + pure = x: [x]; + + settings = { + server = { + inherit (cfg) port; + proxied = true; + host = "127.0.0.1"; + assets-path = "/var/lib/glance"; + }; + + branding.hide-footer = true; + pages = pure { + name = "Dashboard"; + width = "slim"; + hide-desktop-navigation = true; + center-vertically = true; + columns = pure { + size = "full"; + widgets = [ + { + type = "search"; + autofocus = true; + search-engine = "duckduckgo"; + bangs = [ + { + title = "GitHub"; + shortcut = "gh"; + url = "https://github.com/search?q={QUERY}&type=repositories"; + } + { + title = "I'm Feeling Lucky"; + shortcut = "!"; + url = "https://www.google.com/search?q={QUERY}&btnI=&sourceid=navclient&gfns=1"; + } + { + title = "YouTube Music"; + shortcut = "ytm"; + url = "https://music.youtube.com/search?q={QUERY}"; + } + { + title = "Google AI Mode"; + shortcut = "ai"; + url = "https://www.google.com/search?udm=50&q={QUERY}"; + } + ]; + } + { + type = "server-stats"; + servers = pure { + type = "local"; + name = "Ganymede"; + hide-mountpoints-by-default = true; + mountpoints = { + "/".hide = false; + "/media".hide = false; + }; + }; + } + { + type = "monitor"; + cache = "1m"; + title = "Services"; + sites = [ + { + title = "stats"; + url = "https://stats.ganymede"; + icon = "mdi:poll"; + } + { + title = "btop"; + url = "https://btop.ganymede"; + icon = "si:htop"; + } + { + title = "git"; + url = "https://git.ganymede"; + icon = "si:git"; + } + { + title = "bittorrent"; + url = "https://bittorrent.ganymede"; + icon = "si:qbittorrent"; + } + { + title = "website"; + url = "https://williamsfam.us.com"; + icon = "mdi:web"; + } + ]; + } + ]; + }; + }; + }; + + settingsFile = (pkgs.formats.yaml {}).generate "config.yml" settings; +in { + config = lib.mkIf cfg.enable { + users.groups."glance" = {}; + users.users."glance" = { + isSystemUser = true; + group = "glance"; + + home = "/var/lib/glance"; + createHome = true; + }; + + systemd.services."glance" = { + restartIfChanged = true; + wants = ["network-online.target"]; + after = ["network-online.target"]; + + serviceConfig = { + User = "glance"; + Type = "simple"; + + ReadWritePaths = "/var/lib/glance"; + WorkingDirectory = "/var/lib/glance"; + ExecStart = "${pkgs.glance}/bin/glance -config ${settingsFile}"; + + NoNewPrivileges = true; + PrivateTmp = true; + ProtectSystem = "strict"; + ProtectHome = true; + ProtectKernelTunables = true; + ProtectKernelModules = true; + ProtectControlGroups = true; + }; + }; + + services.caddy.virtualHosts."home.ganymede".extraConfig = '' + tls internal + + reverse_proxy 127.0.0.1:${toString cfg.port} + ''; + }; +} diff --git a/modules/services/nixos/openssh.nix b/modules/services/nixos/openssh.nix index 98f8b87..1d7834b 100644 --- a/modules/services/nixos/openssh.nix +++ b/modules/services/nixos/openssh.nix @@ -1,94 +1,54 @@ { config, lib, - pkgs, hosts, ... }: let cfg = config.collinux.services.sshd; + + pure = x: [x]; + + authorizedKeys = + hosts + |> builtins.mapAttrs (_: data: data.user_pubkey or null) + |> builtins.attrValues + |> builtins.filter (x: x != null); in { config = lib.mkIf cfg.enable { - networking.firewall.allowedTCPPorts = lib.optional cfg.public cfg.port; - services.openssh = { enable = true; allowSFTP = true; - hostKeys = [ - { - path = "/etc/ssh/ssh_host_ed25519_key"; - type = "ed25519"; - } - ]; + hostKeys = pure { + path = "/etc/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + }; - listenAddresses = [ - { - addr = - if cfg.public - then "0.0.0.0" - else "127.0.0.1"; - port = cfg.port; - } - ]; + listenAddresses = pure { + addr = "0.0.0.0"; + port = cfg.port; + }; - # Lock down everything by default settings = { - PermitRootLogin = "no"; + PermitRootLogin = + if cfg.conf.rootLogin + then "yes" + else "no"; + PasswordAuthentication = false; - PubkeyAuthentication = false; KbdInteractiveAuthentication = false; - AllowAgentForwarding = false; + PubkeyAuthentication = true; }; - - extraConfig = lib.concatStringsSep "\n" [ - "Match LocalPort ${toString cfg.port}" - ( - if cfg.conf.otp - then '' - ChallengeResponseAuthentication yes - PubkeyAuthentication yes - KbdInteractiveAuthentication yes - AuthenticationMethods publickey,keyboard-interactive:pam - '' - else '' - PubkeyAuthentication yes - AuthenticationMethods publickey - '' - ) - (lib.optionalString cfg.conf.rootLogin "PermitRootLogin yes") - ]; - }; - - security.pam.services = lib.optionalAttrs cfg.conf.otp { - login.googleAuthenticator.enable = true; - - sshd.text = '' - account required pam_unix.so - - auth required ${pkgs.google-authenticator}/lib/security/pam_google_authenticator.so nullok no_increment_hotp - auth sufficient pam_permit.so - - session required pam_env.so conffile=/etc/pam/environment readenv=0 - session required pam_unix.so - session required pam_loginuid.so - session optional ${pkgs.systemd}/lib/security/pam_systemd.so - ''; }; - users.users = let - k.openssh.authorizedKeys.keys = - hosts - |> builtins.mapAttrs (_: data: data.user_pubkey or null) - |> builtins.attrValues - |> builtins.filter (x: x != null); - in { - ${config.collinux.user.name} = k; - "root" = lib.mkIf cfg.conf.rootLogin k; + users.users = { + ${config.collinux.user.name}.openssh.authorizedKeys.keys = authorizedKeys; + root.openssh.authorizedKeys.keys = lib.mkIf cfg.conf.rootLogin authorizedKeys; }; - systemd.services."openssh" = { - after = lib.mkAfter ["network-online.target"]; - wants = lib.mkAfter ["network-online.target"]; + systemd.services.openssh = { + after = ["network-online.target"]; + wants = ["network-online.target"]; }; }; } diff --git a/modules/services/nixos/qbittorrent.nix b/modules/services/nixos/qbittorrent.nix index bb0fab7..cc147b1 100644 --- a/modules/services/nixos/qbittorrent.nix +++ b/modules/services/nixos/qbittorrent.nix @@ -23,7 +23,7 @@ in { services.caddy.virtualHosts."bittorrent.ganymede".extraConfig = '' tls internal - reverse_proxy ${toString cfg.port} + reverse_proxy 127.0.0.1:${toString cfg.port} ''; }; } diff --git a/modules/services/options.nix b/modules/services/options.nix index 1cb1019..7dbaa2c 100644 --- a/modules/services/options.nix +++ b/modules/services/options.nix @@ -100,6 +100,12 @@ in { goaccess = webserviceOptions { service_name = "goaccess"; }; + glance = { + enable = mkEnableOption "Glance homepage"; + port = lib.mkOption { + type = lib.types.port; + }; + }; cgit = webserviceOptions { service_name = "cgit"; reverse_proxy = false; diff --git a/modules/system/nixos/boot.nix b/modules/system/nixos/boot.nix index 71bac70..50d66fe 100644 --- a/modules/system/nixos/boot.nix +++ b/modules/system/nixos/boot.nix @@ -8,6 +8,7 @@ in { boot = { + kernelParams = ["quiet"]; bcache.enable = false; # why is this default on? I DON'T CARE ABOUT bcachefs initrd = { verbose = false; @@ -77,7 +78,7 @@ in { enable = true; mutable = true; # necessary for installing secrets into etc }; - # system.nixos-init.enable = true; + system.nixos-init.enable = true; # store journald logs in memory services.journald.extraConfig = '' diff --git a/modules/system/nixos/networking/resolved.nix b/modules/system/nixos/networking/resolved.nix index 161471f..e49e004 100644 --- a/modules/system/nixos/networking/resolved.nix +++ b/modules/system/nixos/networking/resolved.nix @@ -1,40 +1,6 @@ -{config, ...}: let - hostname = config.networking.hostName; - netname = "${hostname}net0"; -in { +{config, ...}: { networking.resolvconf.enable = false; - services.dnsmasq = { - enable = true; - settings = { - port = 5353; - address = "/.${hostname}/127.0.0.1"; - bind-interfaces = true; - }; - }; - - systemd.network.netdevs."19-localnet" = { - netdevConfig = { - Name = netname; - Kind = "dummy"; - }; - }; - - systemd.network.networks."19-localnet" = { - matchConfig = { - Name = netname; - }; - address = ["192.0.2.1/32"]; # BUG(?): a dummy network must have an address for systemd-networkd to attempt to use it to resolve dns queries (that took forever to debug) - dns = ["127.0.0.1:5353"]; - domains = ["~${hostname}"]; - extraConfig = '' - LinkLocalAddressing=no - ConfigureWithoutCarrier=yes - DNSSEC=no - DNSOverTLS=no - ''; - }; - networking.nameservers = [ "9.9.9.9#dns.quad9.net" "149.112.112.112#dns.quad9.net" diff --git a/modules/user/nixos/default.nix b/modules/user/nixos/default.nix index fbc6001..68238d6 100644 --- a/modules/user/nixos/default.nix +++ b/modules/user/nixos/default.nix @@ -15,7 +15,7 @@ in { extraGroups = ["networkmanager" "disks" "input" "video" "dialout" "kvm"] ++ (lib.optional cfg.isAdmin "wheel"); }; }; - # services.userborn.enable = true; + services.userborn.enable = true; # sudo security = { diff --git a/pkgs/obsidian.nix b/pkgs/obsidian.nix deleted file mode 100644 index b54f6a7..0000000 --- a/pkgs/obsidian.nix +++ /dev/null @@ -1,24 +0,0 @@ -{pkgs, ...}: let - version = "1.10.3"; -in - pkgs.stdenv.mkDerivation { - pname = "obsidian"; - inherit version; - - src = pkgs.fetchurl { - url = "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/obsidian-${version}.tar.gz"; - hash = "sha256-zI8CEhHt6VIGfh4kj4YxdfxJPJaf7mhMVnM45TmaoI0="; - }; - nativeBuildInputs = [pkgs.makeWrapper]; - - installPhase = '' - runHook preInstall - mkdir -p $out/bin - makeWrapper ${pkgs.electron_39}/bin/electron $out/bin/obsidian \ - --add-flags $out/share/obsidian/app.asar \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland --enable-wayland-ime=true --wayland-text-input-version=3}}" - install -m 444 -D resources/app.asar $out/share/obsidian/app.asar - install -m 444 -D resources/obsidian.asar $out/share/obsidian/obsidian.asar - runHook postInstall - ''; - } diff --git a/secrets.nix b/secrets.nix index e8a737c..e900b8c 100644 --- a/secrets.nix +++ b/secrets.nix @@ -5,8 +5,7 @@ in { "hosts/ganymede/secrets/caddy-env.age".publicKeys = [ganymede.host_pubkey]; "hosts/ganymede/secrets/williams-psk.age".publicKeys = [ganymede.host_pubkey]; - "hosts/ganymede/secrets/collin-copyparty-password.age".publicKeys = [mercury.host_pubkey ganymede.host_pubkey]; - "hosts/ganymede/secrets/collin-forgejo-password.age".publicKeys = [mercury.host_pubkey ganymede.host_pubkey]; - "hosts/mercury/secrets/ts-key.age".publicKeys = [mercury.host_pubkey]; + "hosts/mercury/secrets/wg-privkey.age".publicKeys = [mercury.host_pubkey]; + "hosts/ganymede/secrets/wg-privkey.age".publicKeys = [mercury.host_pubkey ganymede.host_pubkey]; } diff --git a/tmux-tsunami/flake.lock b/tmux-tsunami/flake.lock deleted file mode 100644 index 63066a7..0000000 --- a/tmux-tsunami/flake.lock +++ /dev/null @@ -1,42 +0,0 @@ -{ - "nodes": { - "nix-std": { - "locked": { - "lastModified": 1710870712, - "narHash": "sha256-e+7MJF2gsgTBuOWv4mCimSP0D9+naeFSw9a7N3yEmv4=", - "owner": "chessai", - "repo": "nix-std", - "rev": "31bbc925750cc9d8f828fe55cee1a2bd985e0c00", - "type": "github" - }, - "original": { - "owner": "chessai", - "repo": "nix-std", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1759578544, - "narHash": "sha256-GFvucgx8PDytuftANATwu7IQMydblpMDWNZwjg2Oyb4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b0bb1a55163139b0b24228143567f0c1c8c178f4", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nix-std": "nix-std", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/tmux-tsunami/flake.nix b/tmux-tsunami/flake.nix deleted file mode 100644 index e74feb7..0000000 --- a/tmux-tsunami/flake.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs"; - nix-std.url = "github:chessai/nix-std"; - }; - outputs = inputs: { - hjemModules.tsunami = import ./modules/hjem.nix { - std = inputs.nix-std.lib; - }; - - packages."x86_64-linux".tsunamiInstaller = let - installer = import ./modules/installer.nix { - pkgs = import inputs.nixpkgs {system = "x86_64-linux";}; - }; - in - installer.mkInstaller; - }; -} diff --git a/tmux-tsunami/modules/common/bar.nix b/tmux-tsunami/modules/common/bar.nix deleted file mode 100644 index cbb162a..0000000 --- a/tmux-tsunami/modules/common/bar.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - config, - lib, - tsunamiLib, - ... -}: let - inherit (tsunamiLib) scriptPath; -in { - options = let - hexColor = lib.types.strMatching "^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$"; - in { - tsunami.theme = { - bg = lib.mkOption { - type = hexColor; - default = "#fff"; - }; - bg_dark = lib.mkOption { - type = hexColor; - default = "#000"; - }; - }; - }; - config = { - tsunami = { - scripts = { - "battery" = '' - energy_now=$(cat /sys/class/power_supply/BAT0/energy_now) - energy_full=$(cat /sys/class/power_supply/BAT0/energy_full) - percentage=$((energy_now * 100 / energy_full)) - printf "%.0f%%" "$percentage" - ''; - - "bar" = '' - tmux set -g status on - - tmux set -g status-position bottom - tmux set -g status-justify absolute-centre - tmux set -g status-bg "${config.tsunami.theme.bg}" - - tmux set -g status-left-style fg=green,bold - tmux set -g status-left " #{client_session}" - - tmux set -g window-status-style fg=color243 - tmux set -g window-status-format " #I " - tmux set -g window-status-current-style fg=color12,bold - tmux set -g window-status-current-format " #I " - tmux set -g window-status-separator "" - - tmux set -g status-right "#[fg=color243]%l:%M #[fg=red]#(${scriptPath "battery"}) " - - ## pane borders - tmux set -g pane-border-style fg=${config.tsunami.theme.bg_dark},bg=${config.tsunami.theme.bg_dark} - tmux set -g pane-active-border-style fg=${config.tsunami.theme.bg_dark},bg=${config.tsunami.theme.bg_dark} - - ## pane backgrounds - # Set the foreground/background color for the active window - tmux set -g window-active-style bg=${config.tsunami.theme.bg} - - # Set the foreground/background color for all other windows - tmux set -g window-style bg=${config.tsunami.theme.bg_dark} - ''; - }; - - confs."bar" = '' - run-shell ${scriptPath "bar"} - ''; - }; - }; -} diff --git a/tmux-tsunami/modules/common/defaultGlobalKeys.nix b/tmux-tsunami/modules/common/defaultGlobalKeys.nix deleted file mode 100644 index fc3c669..0000000 --- a/tmux-tsunami/modules/common/defaultGlobalKeys.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - pkgs, - tsunamiLib, - ... -}: let - inherit (tsunamiLib) scriptPath; -in { - tsunami.scripts."split" = '' - width=$(tmux display -p "#{pane_width}") - height=$(tmux display -p "#{pane_height}") - - if (( $(echo "$width / $height > 2.5" | ${pkgs.bc}/bin/bc -l) )); then - tmux split-window -h "$@" - else - tmux split-window -v "$@" - fi - ''; - - tsunami.scripts."clean-sessions" = '' - current="$(tmux display -p '#{session_name}')" - - tmux list-sessions -F '#{session_name}' | while read -r line; do - if [[ "$line" != "$current" && "$line" =~ ^[[:digit:]]+$ ]]; then - tmux kill-session -t "$line" - fi - done - ''; - - tsunami.keys.global = [ - { - key = "C-w"; - exec = "kill-pane"; - } - { - key = "M-z"; - exec = "resize-pane -Z"; - } - { - key = "C-Enter"; - exec = ''run-shell "${scriptPath "split"} -c '#{?@default-path,#{@default-path},#{pane_current_path}}'"''; - } - { - key = "C-t"; - exec = "new-window -c '#{?@default-path,#{@default-path},#{pane_current_path}}'"; - } - { - key = "C-Tab"; - exec = "next-window"; - } - { - key = "C-S-Tab"; - exec = "previous-window"; - } - ]; - - tsunami.confs."windows" = '' - unbind -n MouseDown3Pane - set -g allow-rename on - set -g automatic-rename off - set -g renumber-windows on - set -g base-index 1 - - set-hook -ag client-detached 'run-shell ${scriptPath "clean-sessions"}' - set-hook -ag client-session-changed 'run-shell ${scriptPath "clean-sessions"}' - ''; -} diff --git a/tmux-tsunami/modules/common/defaultLeaderMenu.nix b/tmux-tsunami/modules/common/defaultLeaderMenu.nix deleted file mode 100644 index 71489e7..0000000 --- a/tmux-tsunami/modules/common/defaultLeaderMenu.nix +++ /dev/null @@ -1,51 +0,0 @@ -{tsunamiLib, ...}: let - inherit (tsunamiLib) scriptPath; -in { - tsunami.scripts = { - "find-pane" = '' - display_format="#{window_name} #{pane_title} #{pane_current_path} #{pane_current_command}" - hidden_format="#{session_name}:#{window_id}:#{pane_id}" - - # select pane - selected=$(tmux list-panes -a -F "$hidden_format:$display_format" | fzf --delimiter=: --with-nth 4 --color=hl:2) - [ -z "$selected" ] || exit - - # switch to selected - args=(''\${selected//:/ }) - tmux select-pane -t ''\${args[2]} && tmux select-window -t ''\${args[1]} && tmux switch-client -t ''\${args[0]} - ''; - - "search-pane" = '' - trap 'rm -f -- "''\${scrollback:-}"' EXIT - scrollback="$(mktemp)" - - tmux capture-pane -e -p -S - > "$scrollback" - cat "$scrollback" | fzf --ansi - - exit 0 - ''; - }; - - tsunami.keys.leader = [ - { - name = "Find Pane"; - key = "C-w"; - exec = ''run-shell "${scriptPath "minibuffer"} '${scriptPath "find-pane"}'"''; - } - { - name = "Search Pane"; - key = "C-/"; - exec = ''run-shell "${scriptPath "minibuffer"} '${scriptPath "search-pane"}'"''; - } - { - name = "Detach"; - key = "C-d"; - exec = "detach"; - } - { - name = "Reload"; - key = "C-r"; - exec = "source-file ~/.config/tmux/tmux.conf"; - } - ]; -} diff --git a/tmux-tsunami/modules/common/findFile.nix b/tmux-tsunami/modules/common/findFile.nix deleted file mode 100644 index 3d08603..0000000 --- a/tmux-tsunami/modules/common/findFile.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - pkgs, - config, - lib, - tsunamiLib, - std, - ... -}: let - inherit (tsunamiLib) scriptPath filePath; - cfg = config.tsunami.findFile; -in { - options = { - tsunami.findFile = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; - }; - }; - - config = lib.mkIf cfg.enable { - tsunami.keys.leader = [ - { - name = "Find File"; - key = "C-f"; - exec = ''run-shell "${scriptPath "minibuffer"} -d '#{?@default-path,#{@default-path},#{pane_current_path}}' '${scriptPath "find-file"}'"''; - } - ]; - tsunami.scripts = { - "minibuffer" = '' - window_height="$(tmux display -p '#{window_height}')" - tmux display-popup -EB \ - -w 100% -h 16 \ - -x 0 -y "$(($window_height + 1))" \ - "$@" - ''; - - "find-file" = ''${pkgs.broot}/bin/broot --conf ${filePath "broot_find_file.toml"}''; - }; - - tsunami.files."broot_find_file.toml" = std.serde.toTOML { - imports = ["~/.config/broot/conf.hjson"]; - quit_on_last_cancel = true; - verbs = [ - { - invocation = "tmux-split"; - external = ["bash" "-c" ''${scriptPath "split"} -c "#{?@default-path,#{@default-path},#{pane_current_path}}" "$EDITOR '{file}'"'']; - key = "ctrl-s"; - apply_to = "file"; - leave_broot = true; - } - { - invocation = "tmux-window"; - external = ["tmux" "new-window" "-c" "#{?@default-path,#{@default-path},#{pane_current_path}}" "$EDITOR '{file}'"]; - key = "ctrl-w"; - apply_to = "file"; - leave_broot = true; - } - { - key = "enter"; - cmd = ":tmux-window"; - } - ]; - }; - }; -} diff --git a/tmux-tsunami/modules/common/fzfExec.nix b/tmux-tsunami/modules/common/fzfExec.nix deleted file mode 100644 index 2de3741..0000000 --- a/tmux-tsunami/modules/common/fzfExec.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ - tsunamiLib, - lib, - pkgs, - config, - ... -}: let - inherit (tsunamiLib) scriptPath; - cfg = config.tsunami.fzfExec; -in { - options = { - tsunami.fzfExec = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - }; - }; - }; - - config = lib.mkIf cfg.enable { - tsunami.scripts = { - # this is buggy af; it only works half the time. - # But it's the only way I know of to get docs on a specific tmux command - "tmux-doc" = '' - usage=$(tmux list-commands -F "#{command_list_name} #{command_list_usage}" "$1") - - man tmux | ${pkgs.gawk}/bin/awk -v usage="$usage" ' - index($0, usage) > 0 { found=1 } - found { - print - if ($0 == "") exit - } - ' - ''; - - "fzf-exec" = '' - all_cmds() { - tmux list-commands -F $'#{command_list_name}#{?command_list_alias,\n#{command_list_alias},}' - } - - selected_cmd=$(all_cmds | ${pkgs.fzf}/bin/fzf --bind 'enter:accept-or-print-query,tab:replace-query,alt-backspace:clear-query' --prompt : --preview "~/.config/tmux/scripts/tmux-doc.sh $(printf '{}' | cut -d' ' -f1)") - test -z "$selected_cmd" && exit - - tmux $(echo "$selected_cmd" | sed "s@~@$HOME@g") - ''; - }; - - tsunami.keys.global = [ - { - key = "M-x"; - exec = "run-shell '${scriptPath "minibuffer"} -h 10 ${scriptPath "fzf-exec"}'"; - } - ]; - }; -} diff --git a/tmux-tsunami/modules/common/keys.nix b/tmux-tsunami/modules/common/keys.nix deleted file mode 100644 index 9e3c1a2..0000000 --- a/tmux-tsunami/modules/common/keys.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - lib, - config, - tsunamiLib, - ... -}: let - inherit (tsunamiLib) scriptPath; - inherit (lib.strings) escapeShellArg; - cfg = config.tsunami.keys; -in { - options = let - tmuxKey = lib.types.strMatching "^((C|M|S)-)*(.|Enter|Escape|Tab|Up|Down|Left|Right)$"; - inherit (lib) mkOption; - in { - tsunami.keys = { - leader = mkOption { - type = with lib.types; - listOf (submodule { - options = { - name = mkOption {type = str;}; - key = mkOption {type = tmuxKey;}; - exec = mkOption {type = str;}; - }; - }); - }; - - global = mkOption { - type = with lib.types; - listOf (submodule { - options = { - key = mkOption {type = tmuxKey;}; - exec = mkOption {type = str;}; - }; - }); - }; - }; - }; - - config = { - tsunami.scripts = { - "menu" = '' - tmux display-menu \ - -x "#{window_width}" -y S \ - -b none \ - -s "bg=#313244,fg=#9399b2" \ - -S "bg=#313244" \ - -H "bg=#45475a fg=#b4befe" \ - "$@" - ''; - - "leader-menu" = let - args = lib.concatStringsSep " " (builtins.map (f: "${escapeShellArg f.name} ${f.key} ${escapeShellArg f.exec}") cfg.leader); - in '' - ${scriptPath "menu"} ${args} - ''; - }; - tsunami.keys.global = [ - { - key = "C-x"; - exec = "run-shell ${scriptPath "leader-menu"}"; - } - ]; - - tsunami.confs."global-keys" = cfg.global |> builtins.map (f: "bind-key -n ${f.key} ${escapeShellArg f.exec}") |> lib.concatStringsSep "\n"; - }; -} diff --git a/tmux-tsunami/modules/common/main.nix b/tmux-tsunami/modules/common/main.nix deleted file mode 100644 index 25366d9..0000000 --- a/tmux-tsunami/modules/common/main.nix +++ /dev/null @@ -1,23 +0,0 @@ -{lib, ...}: let - inherit (lib) mkOption mkEnableOption; -in { - options = { - tsunami = { - enable = mkEnableOption "tsunami tmux distro"; - scripts = mkOption { - type = lib.types.attrsOf (lib.types.str); - default = []; - }; - - files = mkOption { - type = lib.types.attrsOf (lib.types.str); - default = []; - }; - - confs = mkOption { - type = lib.types.attrsOf (lib.types.str); - default = []; - }; - }; - }; -} diff --git a/tmux-tsunami/modules/common/sessionizer.nix b/tmux-tsunami/modules/common/sessionizer.nix deleted file mode 100644 index 09aa65a..0000000 --- a/tmux-tsunami/modules/common/sessionizer.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ - pkgs, - config, - lib, - tsunamiLib, - std, - ... -}: let - inherit (tsunamiLib) scriptPath filePath; - cfg = config.tsunami.sessionizer; -in { - options = { - tsunami.sessionizer = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; - }; - }; - - config = lib.mkIf cfg.enable { - tsunami.keys.leader = [ - { - name = "Sessions+"; - key = "C-s"; - exec = "run-shell ${scriptPath "sessions-menu"}"; - } - ]; - - tsunami.scripts = { - "sessionizer" = - # bash - '' - [ -z "$1" ] && exit - - selected="$1" - session_name="$(basename "$selected" | tr '.' '_')" - - # if the session doesn't exist, create it - if ! tmux has-session -t "$session_name"; then - tmux new-session -ds "$session_name" -c "$selected" - tmux set-option -t "$session_name" @default-path "$selected" - fi - - # switch to it - tmux switch -t "$session_name" - ''; - "launch-sessionizer" = ''${pkgs.broot}/bin/broot --only-folders --conf ${filePath "broot_sessionizer.toml"}''; - "new-session" = ''tmux switch-client -t "$(tmux new-session -dP)"''; - "sessions-menu" = - # bash - '' - menu_items=( - "Switch Session" s "run-shell '${scriptPath "minibuffer"} -d $HOME ${scriptPath "launch-sessionizer"}'" - "New Unnamed Session" n "run-shell ${scriptPath "new-session"}" - ) - - # put tmux session names into a list - mapfile -t sessions < <(tmux list-sessions -F "#{session_name}") - - # ...but limit at 9 sessions - for i in "''\${!sessions[@]}"; do - (( i >= 9 )) && break # Stop after 9 sessions - - session="''\${sessions[$i]}" - key=$((i + 1)) # 1-based key - - # and put those 9 in the list of menu items - menu_items+=("$session" "$key" "switch-client -t $session") - done - - # Display the menu - ${scriptPath "menu"} -T "#[align=centre]Sessions" "''\${menu_items[@]}" - ''; - }; - tsunami.files = { - "broot_sessionizer.toml" = std.serde.toTOML { - imports = ["~/.config/broot/conf.hjson"]; # inherit from user's config - quit_on_cancel = true; - verbs = [ - { - invocation = "session"; - external = ''bash -c -- "${scriptPath "sessionizer"} '{file}'"''; - key = "enter"; - apply_to = "directory"; - leave_broot = true; - } - ]; - }; - }; - }; -} diff --git a/tmux-tsunami/modules/common/sessionizer2.nix b/tmux-tsunami/modules/common/sessionizer2.nix deleted file mode 100644 index 5f159df..0000000 --- a/tmux-tsunami/modules/common/sessionizer2.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ - pkgs, - config, - lib, - tsunamiLib, - std, - ... -}: let - inherit (tsunamiLib) scriptPath filePath; - cfg = config.tsunami.sessionizer2; -in { - options.tsunami.sessionizer2 = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - }; - }; - - config = lib.mkIf cfg.enable { - tsunami.keys.leader = [ - { - name = "New Session"; - key = "C-n"; - exec = "run-shell ${scriptPath "sessions-menu"}"; - } - ]; - - tsunami.files = { - "broot_sessionizer2_launcher" = std.serde.toTOML { - imports = ["~/.config/broot/conf.hjson"]; # inherit from user's config - verbs = [ - { - invocation = "tmux-window"; - external = ["tmux" "new-window" "-c" "#{?@default-path,#{@default-path},#{pane_current_path}}" "$EDITOR '{file}'"]; - key = "enter"; - apply_to = "file"; - leave_broot = false; - } - { - invocation = "tmux-window"; - external = ["tmux" "new-window" "-c" "#{?@default-path,#{@default-path},#{pane_current_path}}" "$EDITOR '{file}'"]; - key = "enter"; - apply_to = "file"; - leave_broot = false; - } - ]; - }; - }; - }; -} diff --git a/tmux-tsunami/modules/hjem.nix b/tmux-tsunami/modules/hjem.nix deleted file mode 100644 index 019eada..0000000 --- a/tmux-tsunami/modules/hjem.nix +++ /dev/null @@ -1,58 +0,0 @@ -{std, ...}: { - pkgs, - lib, - config, - ... -}: let - cfg = config.tsunami; -in { - imports = lib.filesystem.listFilesRecursive ./common; - - _module.args = { - inherit std; - tsunamiLib = { - scriptPath = f: "~/.config/tmux/scripts/${f}.sh"; - filePath = f: "~/.config/tmux/files/${f}"; - }; - }; - - files = lib.mkIf cfg.enable (lib.mkMerge [ - ( - cfg.scripts - |> builtins.mapAttrs (name: value: { - name = ".config/tmux/scripts/${name}.sh"; - value = { - text = value; - executable = true; - }; - }) - |> lib.attrValues - |> builtins.listToAttrs - ) - ( - cfg.files - |> builtins.mapAttrs (name: value: { - name = ".config/tmux/files/${name}"; - value.text = value; - }) - |> lib.attrValues - |> builtins.listToAttrs - ) - ( - cfg.confs - |> builtins.mapAttrs (name: value: { - name = ".config/tmux/conf.d/${name}.conf"; - value.text = value; - }) - |> lib.attrValues - |> builtins.listToAttrs - ) - { - ".config/tmux/tmux.conf".text = '' - run-shell "find ~/.config/tmux/conf.d -print0 | xargs -0 -n1 tmux source-file" - ''; - } - ]); - - packages = lib.optional cfg.enable pkgs.tmux; -} diff --git a/tmux-tsunami/modules/installer.nix b/tmux-tsunami/modules/installer.nix deleted file mode 100644 index 9cff811..0000000 --- a/tmux-tsunami/modules/installer.nix +++ /dev/null @@ -1,38 +0,0 @@ -{pkgs, ...}: let - tsunamiLib = { - scriptPath = f: "$HOME/.config/tmux/scripts/${f}.sh"; - filePath = f: "$HOME/.config/tmux/files/${f}"; - }; - config = pkgs.lib.evalModules { - modules = - [ - {_module.args = {inherit pkgs tsunamiLib;};} - ] - ++ (pkgs.lib.filesystem.listFilesRecursive ./common); - }; - - moduleConfig = pkgs.writeText "tsunami-installer-config.json" (builtins.toJSON { - inherit (config.config.tsunami) scripts files confs; - }); -in { - mkInstaller = - pkgs.runCommand "tsunami-installer" { - buildInputs = [pkgs.jq]; - } '' - mkdir -p $out - { - cat ${moduleConfig} | jq -r ' - (.scripts | to_entries[] | "cat <<\"EOF\" > $HOME/.config/tmux/scripts/\(.key).sh\n\(.value)\nEOF\n"), - (.files | to_entries[] | "cat <<\"EOF\" > $HOME/.config/tmux/files/\(.key)\n\(.value)\nEOF\n"), - (.confs | to_entries[] | "cat <<\"EOF\" > $HOME/.config/tmux/conf.d/\(.key).conf\n\(.value)\nEOF\n") - ' - printf ' - cat < $HOME/.config/tmux/tmux.conf - run-shell "find $out/conf.d -print0 | xargs -0 -n1 tmux source-file" - EOF - ' - } > $out/tsunami-installer - - chmod +x $out/tsunami-installer - ''; -} diff --git a/tmux-tsunami/planning.md b/tmux-tsunami/planning.md deleted file mode 100644 index 872bbb5..0000000 --- a/tmux-tsunami/planning.md +++ /dev/null @@ -1,56 +0,0 @@ -## Pieces: -sessionizer -- leaderkey keybinding C-p+ -- script launch-sessionizer -- script clean-sessions -- script new-session -- script projects-menu -- extrafile broot_sessionizer - -```nix -{pkgs, tsunamiLib, ...}: let - inherit (tsunamiLib) scriptPath filePath; -in { - tsunami.keys.leader = [{ - name = "Projects+"; - key = "C-p"; - exec = "run-shell ${scriptPath "projects-menu"}"; - }]; - - tsunami.scripts = { - "launch-sessionizer" = ''${pkgs.broot}/bin/broot --conf ${filePath "broot_sessionizer.toml"}''; - "clean-sessions" = ''...''; - "new-session" = ''...''; - }; - tsunami.files = { - "broot_sessionizer.toml" = (pkgs.formats.toml {}).generate "file.toml" { - ... - }; - }; -} -``` - -find-file -- leaderkey keybinding C-f -- script find-file -- extrafile broot_find_file -fzf-exec -- keybinding M-x -- script tmux-doc -- script fzf-exec -search-buffer -- leaderkey keybinding C-/ -- script search-buffer -find-window -- leaderkey keybinding C-w -- script find-buffer -leader-key -- keybinding C-x -- script leader-menu -bar -- script bar -- script battery -main config -- script minibuffer -- script split -- -- cgit v1.3.1