From 5c7007912c63114f91ecbcf6edfd6cfe5be96c43 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 6 Jul 2026 16:25:44 -0700 Subject: [PATCH] Reduce jay-lenovo switch source builds --- nix-shared/system/essential.nix | 124 +++++++------ nixos/code.nix | 294 +++++++++++++++--------------- nixos/machines/jay-lenovo.nix | 10 + nixos/notifications-tray-icon.nix | 163 +++++++++-------- nixos/xmonad.nix | 30 +-- 5 files changed, 326 insertions(+), 295 deletions(-) diff --git a/nix-shared/system/essential.nix b/nix-shared/system/essential.nix index 11f57133..acc4061c 100644 --- a/nix-shared/system/essential.nix +++ b/nix-shared/system/essential.nix @@ -2,20 +2,32 @@ pkgs, lib, inputs, + config ? {}, ... }: let system = pkgs.stdenv.hostPlatform.system; + isJayLenovo = (config.networking.hostName or null) == "jay-lenovo"; inputPackageOrNull = inputName: packageName: let input = inputs.${inputName} or null; - packages = if input == null then null else input.packages or null; - systemPackages = if packages == null then null else packages.${system} or null; + packages = + if input == null + then null + else input.packages or null; + systemPackages = + if packages == null + then null + else packages.${system} or null; in - if systemPackages == null then null else systemPackages.${packageName} or null; + if systemPackages == null + then null + else systemPackages.${packageName} or null; git-blame-rank = inputs.git-blame-rank.packages.${system}.default.overrideAttrs (old: { - env = (old.env or {}) // { - CARGO_BUILD_JOBS = "1"; - }; + env = + (old.env or {}) + // { + CARGO_BUILD_JOBS = "1"; + }; }); coquiTtsStreamer = inputPackageOrNull "coqui-tts-streamer" "default"; keepbook = inputs.keepbook.packages.${system}.keepbook.overrideAttrs (_: { @@ -24,56 +36,56 @@ }); commonPkgs = lib.filter (pkg: lib.meta.availableOn pkgs.stdenv.hostPlatform pkg) ((with pkgs; [ - automake - bazel - bento4 - bind - binutils - cachix - bubblewrap - cmake - dex - direnv - fd - ffmpeg - file - gawk - gcc - gh - git-fame - git-blame-rank - git-lfs - git-sync - git - gnumake - home-manager - htop - ispell - jq - just - keepbook - lsof - magic-wormhole-rs - ncdu - fastfetch - neovim - nix-index - nix-search-cli - pass - patchelf - pstree - rclone - ripgrep - skim - tmux - zellij - unzip - wget - xkcdpass - yubikey-manager - ]) - ++ lib.optionals (coquiTtsStreamer != null) [coquiTtsStreamer] - ++ lib.optionals (builtins.hasAttr "git-sync-rs" pkgs) [pkgs.git-sync-rs]); + automake + bento4 + bind + binutils + cachix + bubblewrap + cmake + dex + direnv + fd + ffmpeg + file + gawk + gcc + gh + git-fame + git-blame-rank + git-lfs + git-sync + git + gnumake + home-manager + htop + ispell + jq + just + keepbook + lsof + magic-wormhole-rs + ncdu + fastfetch + neovim + nix-index + nix-search-cli + pass + patchelf + pstree + rclone + ripgrep + skim + tmux + zellij + unzip + wget + xkcdpass + yubikey-manager + ]) + ++ lib.optionals (!isJayLenovo) [pkgs.bazel] + ++ lib.optionals (coquiTtsStreamer != null) [coquiTtsStreamer] + ++ lib.optionals (builtins.hasAttr "git-sync-rs" pkgs) [pkgs.git-sync-rs]); linuxOnly = with pkgs; [ dex diff --git a/nixos/code.nix b/nixos/code.nix index 2639051f..8d167f21 100644 --- a/nixos/code.nix +++ b/nixos/code.nix @@ -5,184 +5,184 @@ lib, makeEnable, ... -}: -let +}: let codexDesktopLinuxSource = pkgs.applyPatches { name = "codex-desktop-linux-patched"; src = inputs.codex-desktop-linux; - patches = [ ./patches/codex-desktop-linux-gsettings-schemas.patch ]; + patches = [./patches/codex-desktop-linux-gsettings-schemas.patch]; }; claudeDesktopSource = inputs.claude-desktop; claudeDesktop = pkgs.callPackage "${claudeDesktopSource}/nix/claude-desktop.nix" {}; claudeDesktopFhs = pkgs.callPackage "${claudeDesktopSource}/nix/fhs.nix" { claude-desktop = claudeDesktop; }; - codexDesktopLinux = - let - flake = import "${codexDesktopLinuxSource}/flake.nix"; - self' = - (flake.outputs { - self = self'; - nixpkgs = inputs.nixpkgs; - flake-utils = inputs.flake-utils; - }) - // { - outPath = "${codexDesktopLinuxSource}"; - rev = inputs.codex-desktop-linux.rev or ""; - lastModified = inputs.codex-desktop-linux.lastModified or 1; - }; - in - self'; + codexDesktopLinux = let + flake = import "${codexDesktopLinuxSource}/flake.nix"; + self' = + (flake.outputs { + self = self'; + nixpkgs = inputs.nixpkgs; + flake-utils = inputs.flake-utils; + }) + // { + outPath = "${codexDesktopLinuxSource}"; + rev = inputs.codex-desktop-linux.rev or ""; + lastModified = inputs.codex-desktop-linux.lastModified or 1; + }; + in + self'; in -makeEnable config "myModules.code" true { - programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; - - hardware.uinput.enable = lib.mkIf config.myModules.desktop.enable true; - - programs.ydotool = lib.mkIf config.myModules.desktop.enable { - enable = true; - group = "input"; - }; - - home-manager.sharedModules = lib.mkIf config.myModules.desktop.enable [ - codexDesktopLinux.homeManagerModules.default - { - home.sessionVariables.YDOTOOL_SOCKET = "/run/ydotoold/socket"; - systemd.user.sessionVariables.YDOTOOL_SOCKET = "/run/ydotoold/socket"; - - xdg.configFile."codex-desktop/settings.json".text = - (builtins.toJSON { - "codex-linux-computer-use-ui-enabled" = true; - }) - + "\n"; - } - ]; - - home-manager.users.imalison = lib.mkIf config.myModules.desktop.enable { - programs.codex = { + makeEnable config "myModules.code" true { + programs.direnv = { enable = true; - package = pkgs.codex; + nix-direnv.enable = true; }; - programs.codexDesktopLinux = { + hardware.uinput.enable = lib.mkIf config.myModules.desktop.enable true; + + programs.ydotool = lib.mkIf config.myModules.desktop.enable { enable = true; - # Bake CODEX_CLI_PATH into the launcher so Codex Desktop always finds this - # CLI, regardless of how it is started (GUI autostart, app launcher, - # terminal, or warm-start handoff) and without needing a re-login. - cliPackage = pkgs.codex; - computerUseUi.enable = true; - remoteMobileControl.enable = true; - remoteControl = { + group = "input"; + }; + + home-manager.sharedModules = lib.mkIf config.myModules.desktop.enable [ + codexDesktopLinux.homeManagerModules.default + { + home.sessionVariables.YDOTOOL_SOCKET = "/run/ydotoold/socket"; + systemd.user.sessionVariables.YDOTOOL_SOCKET = "/run/ydotoold/socket"; + + xdg.configFile."codex-desktop/settings.json".text = + (builtins.toJSON { + "codex-linux-computer-use-ui-enabled" = true; + }) + + "\n"; + } + ]; + + home-manager.users.imalison = lib.mkIf config.myModules.desktop.enable { + programs.codex = { enable = true; package = pkgs.codex; - extraPackages = with pkgs; [ - bash - coreutils - findutils - git - gnugrep - gnused - nix - nodejs - openssh - ripgrep - zsh - ]; - listen = "unix://"; + }; + + programs.codexDesktopLinux = { + enable = true; + # Bake CODEX_CLI_PATH into the launcher so Codex Desktop always finds this + # CLI, regardless of how it is started (GUI autostart, app launcher, + # terminal, or warm-start handoff) and without needing a re-login. + cliPackage = pkgs.codex; + computerUseUi.enable = true; + remoteMobileControl.enable = true; + remoteControl = { + enable = true; + package = pkgs.codex; + extraPackages = with pkgs; [ + bash + coreutils + findutils + git + gnugrep + gnused + nix + nodejs + openssh + ripgrep + zsh + ]; + listen = "unix://"; + }; }; }; - }; - environment.systemPackages = with pkgs; - [ - # LLM Tools - # antigravity - claude-code - claudeDesktopFhs - codex - gemini-cli - opencode - t3code + environment.systemPackages = with pkgs; + [ + # LLM Tools + # antigravity + claude-code + codex + gemini-cli + opencode + t3code - # MCP - github-mcp-server - gitea-mcp-server - gws - playwright-mcp - playwright-cli + # MCP + github-mcp-server + gitea-mcp-server + gws + playwright-mcp + playwright-cli - # C - clang + # C + clang - # Haskell - cabal-install - cabal2nix - ghc - haskellPackages.hpack - haskellPackages.hasktags - haskellPackages.hoogle + # Haskell + cabal-install + ghc + haskellPackages.hpack + haskellPackages.hasktags + haskellPackages.hoogle - # Scala - sbt - scala + # Scala + sbt + scala - # Node - nodejs - yarn - prettier + # Node + nodejs + yarn + prettier - # Typescript - typescript - typescript-language-server + # Typescript + typescript + typescript-language-server - # golang - go + # golang + go - # Rust - rustup - cargo-sweep + # Rust + rustup + cargo-sweep - # Clojure - boot - leiningen + # Clojure + boot + leiningen - # Ruby - ruby + # Ruby + ruby - # python - black - poetry - uv + # python + black + poetry + uv - # kotlin - kotlin - kotlin-language-server + # kotlin + kotlin + kotlin-language-server - # dhall - haskellPackages.dhall - haskellPackages.dhall-json + # dhall + haskellPackages.dhall + haskellPackages.dhall-json - # misc - perf-tools - protobuf + # misc + perf-tools + protobuf - # nix - nixd - nil - alejandra - ] - ++ ( - if pkgs.stdenv.hostPlatform.system == "x86_64-linux" - then - with pkgs; [ - # purescript - purescript - # Broken - # spago - ] - else [] - ); -} + # nix + nixd + nil + alejandra + ] + ++ lib.optionals (config.networking.hostName != "jay-lenovo") [ + claudeDesktopFhs + cabal2nix + ] + ++ ( + if pkgs.stdenv.hostPlatform.system == "x86_64-linux" + then + with pkgs; [ + # purescript + purescript + # Broken + # spago + ] + else [] + ); + } diff --git a/nixos/machines/jay-lenovo.nix b/nixos/machines/jay-lenovo.nix index b35ce068..b6245967 100644 --- a/nixos/machines/jay-lenovo.nix +++ b/nixos/machines/jay-lenovo.nix @@ -1,5 +1,6 @@ { config, + inputs, lib, pkgs, ... @@ -11,6 +12,15 @@ myModules.wyoming.enable = false; features.full.enable = true; + nixpkgs.overlays = [ + (_final: prev: let + stablePkgs = inputs.nixpkgs-stable.legacyPackages.${prev.stdenv.hostPlatform.system}; + in { + shellcheck = stablePkgs.shellcheck; + shellcheck-minimal = stablePkgs.shellcheck-minimal or stablePkgs.shellcheck; + }) + ]; + environment.systemPackages = with pkgs; [ android-studio perf diff --git a/nixos/notifications-tray-icon.nix b/nixos/notifications-tray-icon.nix index a468be1a..4f5d2469 100644 --- a/nixos/notifications-tray-icon.nix +++ b/nixos/notifications-tray-icon.nix @@ -5,83 +5,88 @@ lib, makeEnable, ... -}: -makeEnable config "myModules.notifications-tray-icon" true { - nixpkgs.overlays = [ - inputs.notifications-tray-icon.overlays.default - (final: prev: { - haskellPackages = prev.haskellPackages.override (old: { - overrides = - final.lib.composeExtensions (old.overrides or (_: _: {})) - (hself: hsuper: { - notifications-tray-icon = - final.haskell.lib.overrideCabal - hsuper.notifications-tray-icon - (oldAttrs: { - patches = - (oldAttrs.patches or []) - ++ [ - ./patches/notifications-tray-icon-gmail-oauth-detached-browser.patch - ./patches/notifications-tray-icon-github-menu-item-id.patch - ./patches/notifications-tray-icon-open-url-systemd-run.patch - ]; - }); - }); - }); - }) - ]; - - home-manager.users.imalison = {config, ...}: let - notificationsTrayIcon = pkgs.haskellPackages.notifications-tray-icon; - gmailExecStart = pkgs.writeShellScript "notifications-tray-icon-gmail" '' - creds_file="${config.xdg.configHome}/gws/client_secret.json" - client_id=$(${pkgs.jq}/bin/jq -r '.installed.client_id // .web.client_id // empty' "$creds_file") - client_secret=$(${pkgs.jq}/bin/jq -r '.installed.client_secret // .web.client_secret // empty' "$creds_file") - - if [ -z "$client_id" ] || [ -z "$client_secret" ]; then - echo "Failed to read Gmail OAuth client credentials from $creds_file" >&2 - exit 1 - fi - - exec ${notificationsTrayIcon}/bin/notifications-tray-icon gmail \ - --client-id "$client_id" \ - --client-secret "$client_secret" - ''; - mkService = description: execStart: { - Unit = { - Description = description; - After = ["graphical-session.target" "tray.target"]; - PartOf = ["graphical-session.target"]; - Requires = ["tray.target"]; - }; - Service = { - ExecStart = execStart; - # URL handlers can outlive the tray process. Keep restarts from killing - # unrelated GUI apps if a handler ever leaks into this service cgroup. - KillMode = "process"; - Restart = "always"; - RestartSec = 3; - }; - Install = { - WantedBy = ["graphical-session.target"]; - }; - }; - in { - systemd.user.services = { - notifications-tray-icon-github = - mkService - "GitHub notifications tray icon" - "${notificationsTrayIcon}/bin/notifications-tray-icon github --token-pass github-token"; - - notifications-tray-icon-gitea = - mkService - "Gitea notifications tray icon" - "${notificationsTrayIcon}/bin/notifications-tray-icon gitea --url https://dev.railbird.ai --token-pass gitea-omni-token"; - - notifications-tray-icon-gmail = - mkService - "Gmail notifications tray icon" - "${gmailExecStart}"; - }; +}: let + system = pkgs.stdenv.hostPlatform.system; + notificationsTrayIconPkgs = import pkgs.path { + inherit system; + config = pkgs.config or {}; + overlays = [ + inputs.notifications-tray-icon.overlays.default + (final: prev: { + haskellPackages = prev.haskellPackages.override (old: { + overrides = + final.lib.composeExtensions (old.overrides or (_: _: {})) + (hself: hsuper: { + notifications-tray-icon = + final.haskell.lib.overrideCabal + hsuper.notifications-tray-icon + (oldAttrs: { + patches = + (oldAttrs.patches or []) + ++ [ + ./patches/notifications-tray-icon-gmail-oauth-detached-browser.patch + ./patches/notifications-tray-icon-github-menu-item-id.patch + ./patches/notifications-tray-icon-open-url-systemd-run.patch + ]; + }); + }); + }); + }) + ]; }; -} +in + makeEnable config "myModules.notifications-tray-icon" true { + home-manager.users.imalison = {config, ...}: let + notificationsTrayIcon = notificationsTrayIconPkgs.haskellPackages.notifications-tray-icon; + gmailExecStart = pkgs.writeShellScript "notifications-tray-icon-gmail" '' + creds_file="${config.xdg.configHome}/gws/client_secret.json" + client_id=$(${pkgs.jq}/bin/jq -r '.installed.client_id // .web.client_id // empty' "$creds_file") + client_secret=$(${pkgs.jq}/bin/jq -r '.installed.client_secret // .web.client_secret // empty' "$creds_file") + + if [ -z "$client_id" ] || [ -z "$client_secret" ]; then + echo "Failed to read Gmail OAuth client credentials from $creds_file" >&2 + exit 1 + fi + + exec ${notificationsTrayIcon}/bin/notifications-tray-icon gmail \ + --client-id "$client_id" \ + --client-secret "$client_secret" + ''; + mkService = description: execStart: { + Unit = { + Description = description; + After = ["graphical-session.target" "tray.target"]; + PartOf = ["graphical-session.target"]; + Requires = ["tray.target"]; + }; + Service = { + ExecStart = execStart; + # URL handlers can outlive the tray process. Keep restarts from killing + # unrelated GUI apps if a handler ever leaks into this service cgroup. + KillMode = "process"; + Restart = "always"; + RestartSec = 3; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + in { + systemd.user.services = { + notifications-tray-icon-github = + mkService + "GitHub notifications tray icon" + "${notificationsTrayIcon}/bin/notifications-tray-icon github --token-pass github-token"; + + notifications-tray-icon-gitea = + mkService + "Gitea notifications tray icon" + "${notificationsTrayIcon}/bin/notifications-tray-icon gitea --url https://dev.railbird.ai --token-pass gitea-omni-token"; + + notifications-tray-icon-gmail = + mkService + "Gmail notifications tray icon" + "${gmailExecStart}"; + }; + }; + } diff --git a/nixos/xmonad.nix b/nixos/xmonad.nix index c3f9b19b..a5278066 100644 --- a/nixos/xmonad.nix +++ b/nixos/xmonad.nix @@ -7,13 +7,13 @@ ... }: let session = import ./session-variables.nix; -in - makeEnable config "myModules.xmonad" true { - myModules.taffybar.enable = lib.mkDefault (config.myModules.desktop.shellUi == "taffybar"); - - nixpkgs.overlays = with inputs; [ - xmonad.overlay - xmonad-contrib.overlay + system = pkgs.stdenv.hostPlatform.system; + xmonadPkgs = import pkgs.path { + inherit system; + config = pkgs.config or {}; + overlays = [ + inputs.xmonad.overlay + inputs.xmonad-contrib.overlay (final: prev: { haskellPackages = prev.haskellPackages.override (old: { overrides = @@ -31,6 +31,10 @@ in }) (import ../dotfiles/config/xmonad/overlay.nix) ]; + }; +in + makeEnable config "myModules.xmonad" true { + myModules.taffybar.enable = lib.mkDefault (config.myModules.desktop.shellUi == "taffybar"); services.rumno.enable = true; @@ -48,13 +52,13 @@ in }; }; - environment.systemPackages = with pkgs; [ + environment.systemPackages = [ # Haskell Desktop - haskellPackages.xmonad - haskellPackages.imalison-xmonad - # haskellPackages.notifications-tray-icon - # haskellPackages.gtk-sni-tray - haskellPackages.dbus-hslogger + xmonadPkgs.haskellPackages.xmonad + xmonadPkgs.haskellPackages.imalison-xmonad + # xmonadPkgs.haskellPackages.notifications-tray-icon + # xmonadPkgs.haskellPackages.gtk-sni-tray + xmonadPkgs.haskellPackages.dbus-hslogger ]; home-manager.sharedModules = [