Skip to content

fix switch - #404

Merged
shunkakinoki merged 14 commits into
mainfrom
fix-switch
Dec 10, 2025
Merged

fix switch#404
shunkakinoki merged 14 commits into
mainfrom
fix-switch

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Dec 10, 2025

Copy link
Copy Markdown
Owner
  • fix(Makefile): remove unnecessary target from switch command
  • feat(k3s): add configuration files and SSH function for Kyber server
  • feat(kyber): add Tailscale configuration and setup scripts for Ubuntu server
  • feat(default.nix): add doppler to package list
  • feat(config.yaml): enable remote management access
  • feat(tailscale): enhance service installation with elevated command handling
  • chore: update
  • chore: update
  • chore: update
  • chore: update
  • feat: add git fetch command to Bash hooks
  • feat: add example configuration for cliproxyapi and shell alias

Summary by cubic

Fixes the Makefile switch command and adds a full Kyber (Ubuntu) host setup with Tailscale and k3s config sync. Also enables remote management for cliproxyapi and updates tooling.

  • New Features

    • Kyber host support: flake target, home-manager config, agenix secrets scaffold, setup script, and Fish SSH helper (kyber).
    • Tailscale module: installs and manages a system tailscaled service on non-NixOS with sudo/doas fallback, plus a one-shot tailscale up service.
    • k3s: home-managed config that syncs to /etc/rancher/k3s and disables Traefik.
    • cliproxyapi: remote management enabled, example config added, and a Fish alias for quick usage.
    • Dependencies: add doppler, @beads/bd, and Homebrew sshpass.
  • Bug Fixes

    • Makefile switch no longer restarts launchd, and nix-switch supports named homeConfigurations via HOST for targeted switches.

Written for commit 3cd48e9. Summary will update automatically on new commits.

Copilot AI review requested due to automatic review settings December 10, 2025 13:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Dec 10, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added K3s Kubernetes configuration with Traefik disabled by default
    • Integrated Tailscale VPN with automatic service installation and configuration
    • Introduced new "kyber" Ubuntu server host configuration with Tailscale and passwordless SSH setup
  • Enhancements

    • Simplified build system switch command
    • Added shell shortcuts for remote server access and CLI proxy management
    • Enabled remote management support for CLI Proxy API
  • Chores

    • Added package dependencies and system tools for improved functionality

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This pull request introduces a new Kyber host configuration for Ubuntu Linux with Tailscale VPN integration, removes launchctl dependency from the Makefile, adds k3s configuration module, introduces comprehensive Tailscale Home Manager module with systemd services and activation scripts, expands package management with Linux-specific tools, and adds supporting shell utilities and configuration files.

Changes

Cohort / File(s) Summary
Build system
Makefile
Removed include directive for rules/Makefile; simplified switch target to depend only on nix-switch; enhanced nix-switch to support HOST variable for selecting named homeConfigurations on both CI and non-CI paths
Configuration management
config/claude/settings.json, config/cliproxyapi/config.yaml, config/cliproxyapi/default.nix, config/default.nix
Added Bash git fetch permission to Claude settings; enabled remote access in CLIProxyAPI by default; added example config symlink for cliproxyapi; added k3s module to configuration list
K3s module
config/k3s/config.yaml, config/k3s/default.nix
Introduced new K3s Kubernetes module with Traefik disabled by default; added Linux-specific home file and activation script to manage K3s configuration deployment
Tailscale module
home-manager/modules/tailscale/default.nix, home-manager/modules/default.nix
Introduced comprehensive Tailscale VPN module with configurable user and system-level systemd services, state/run directory management, optional system service installation, and sudoers configuration for privilege escalation
Package management
home-manager/packages/default.nix, nix-darwin/config/homebrew.nix, package.json
Added doppler and platform-specific packages (Linux: tailscale, docker, codex, signal-desktop, etc.); added sshpass to Homebrew brews; added @beads/bd npm dependency
Shell programs
home-manager/programs/fish/default.nix, home-manager/programs/fish/functions/_kyber_function.fish
Added cliproxyapi shell alias and kyber abbreviation; introduced _kyber_function for SSH access to Kyber server with Keychain-based password retrieval fallback
Kyber host configuration
named-hosts/kyber/default.nix, named-hosts/kyber/secrets.nix, named-hosts/kyber/setup.sh, named-hosts/kyber/README.md
Added complete Ubuntu host configuration with Home Manager integration, agenix secrets management, Tailscale system service setup, bootstrap script for initial Tailscale setup, and documentation
Flake configuration
flake.nix
Added kyber homeConfiguration with ubuntu username and x86_64-linux system, importing named-hosts/kyber module

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas requiring extra attention:

  • home-manager/modules/tailscale/default.nix — Complex module with dual user/system-level service management, activation scripts for directory creation and system service installation, privilege escalation handling via sudoers, and multi-service orchestration (tailscaled daemon + tailscale-up oneshot)
  • Makefile HOST variable logic — Verify conditional behavior for both CI and non-CI paths, HOST variable precedence, and fallback to existing NIX_CONFIG_TYPE/username/system pattern
  • named-hosts/kyber/default.nix — Home Manager configuration composition with agenix integration, overlays application, and activation script for bash file backup migration
  • home-manager/programs/fish/functions/_kyber_function.fish — Keychain integration and sshpass password-based SSH fallback logic across platforms

Possibly related PRs

  • chore: sync chore-v2 branch with main #397 — Makefile switch and launchctl target changes; this PR removes launchctl from switch dependencies while adjusting HOST-based configuration switching logic
  • Nvim revamp #376 — Home Manager packages and tailscale additions; overlaps with tailscale module introduction and Linux-specific package list expansion
  • nvim revamp #360 — Makefile nix-switch/switch targets and homeConfigurations logic; related to HOST variable handling and configuration selection flow

Poem

🐰 A Kyber burrow now awaits, with Tailscale's trusty net,
Home Manager tends the warren, no secrets are a threat,
K3s runs in shadows deep, while fish scripts hop about,
The switch flicks swift and cleaner now—launchctl's cast out! 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-switch

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3d9f07b and 3cd48e9.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • Makefile (2 hunks)
  • config/claude/settings.json (1 hunks)
  • config/cliproxyapi/config.yaml (1 hunks)
  • config/cliproxyapi/default.nix (1 hunks)
  • config/default.nix (1 hunks)
  • config/k3s/config.yaml (1 hunks)
  • config/k3s/default.nix (1 hunks)
  • flake.nix (1 hunks)
  • home-manager/modules/default.nix (1 hunks)
  • home-manager/modules/tailscale/default.nix (1 hunks)
  • home-manager/packages/default.nix (1 hunks)
  • home-manager/programs/fish/default.nix (3 hunks)
  • home-manager/programs/fish/functions/_kyber_function.fish (1 hunks)
  • named-hosts/kyber/README.md (1 hunks)
  • named-hosts/kyber/default.nix (1 hunks)
  • named-hosts/kyber/secrets.nix (1 hunks)
  • named-hosts/kyber/setup.sh (1 hunks)
  • nix-darwin/config/homebrew.nix (1 hunks)
  • package.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the dotfiles' capabilities by integrating a new 'Kyber' server configuration, complete with Tailscale VPN setup and robust secret management. It also introduces a dedicated Tailscale Home Manager module for flexible deployment across different systems. Additionally, the changes refine existing Nix configurations, enhance the CLI proxy API's accessibility, and update various development dependencies and shell aliases to streamline workflows.

Highlights

  • Kyber Server Integration: Introduced comprehensive configuration and setup scripts for a new 'Kyber' Ubuntu Linux server, including Tailscale VPN integration, SSH access, and secret management via agenix.
  • Tailscale Module: Added a new Home Manager module for Tailscale, enabling declarative configuration of the VPN service, including system-level service installation with elevated command handling.
  • Nix Configuration Enhancements: Refined the Makefile's switch command to support named Home Manager configurations and removed an unnecessary launchctl target. Also added the k3s module to the default Nix configuration.
  • CLI Proxy API Updates: Enabled remote management access for the cliproxyapi service and added an example configuration file and a shell alias for easier interaction.
  • Dependency and Tooling Additions: Integrated doppler into the Home Manager package list, added @beads/bd as a Bun dependency, and included sshpass in Homebrew packages for improved scripting capabilities.
  • Git Workflow Improvement: Added the git fetch command to Bash hooks, enhancing the available Git operations within the configured environment.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mesa-dot-dev

mesa-dot-dev Bot commented Dec 10, 2025

Copy link
Copy Markdown

Mesa Description

TL;DR

This PR introduces new server configurations for Kyber (k3s, Tailscale), adds several system utilities and packages (doppler, enhanced Tailscale service, git fetch), enables remote management, and includes a minor Makefile fix.

What changed?

  • fix(Makefile): remove unnecessary target from switch command
  • feat(k3s): add configuration files and SSH function for Kyber server
  • feat(kyber): add Tailscale configuration and setup scripts for Ubuntu server
  • feat(default.nix): add doppler to package list
  • feat(config.yaml): enable remote management access
  • feat(tailscale): enhance service installation with elevated command handling
  • feat: add git fetch command to Bash hooks
  • feat: add example configuration for cliproxyapi and shell alias

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki merged commit b0ce88f into main Dec 10, 2025
28 of 29 checks passed
@shunkakinoki
shunkakinoki deleted the fix-switch branch December 10, 2025 13:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new host configuration for 'Kyber', including K3s and Tailscale setup, along with several dependency updates and new shell aliases. Key changes involve enabling remote management for cliproxyapi and integrating sshpass for SSH access to the Kyber server. While the new host configuration is well-structured, there are a few areas related to security and consistency that warrant attention.

# Whether to allow remote (non-localhost) management access.
# When false, only localhost can access management endpoints (a key is still required).
allow-remote: false
allow-remote: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Changing allow-remote to true enables remote management access for cliproxyapi. This is a security-sensitive change that could expose the management API to external networks. Please ensure this is intentional and that appropriate network-level access controls (e.g., firewall rules) are in place to restrict access to trusted sources only. If this is for development or specific internal use, consider adding a prominent warning or making it configurable via environment variables rather than a static true in the default config.

Comment on lines +219 to +274
SERVICE_FILE="/etc/systemd/system/tailscaled.service"
NIX_SERVICE="${tailscaledServiceFile}"
SUDOERS_FILE="/etc/sudoers.d/nix-tailscale"

# Resolve an elevated command helper
SUDO_CMD=""
if command -v sudo >/dev/null 2>&1; then
SUDO_CMD="sudo"
elif [ -x /usr/bin/sudo ]; then
SUDO_CMD="/usr/bin/sudo"
elif command -v doas >/dev/null 2>&1; then
SUDO_CMD="doas"
elif [ -x /usr/bin/doas ]; then
SUDO_CMD="/usr/bin/doas"
elif [ "$(id -u)" -ne 0 ]; then
echo "Tailscale system service installation requires root privileges, but sudo/doas is not available." >&2
echo "Either install sudo, configure doas, or run home-manager as root." >&2
exit 1
fi

run_root_cmd() {
if [ -n "$SUDO_CMD" ]; then
''${DRY_RUN_CMD:-} "$SUDO_CMD" "$@"
else
''${DRY_RUN_CMD:-} "$@"
fi
}

# Only install if service file differs from nix-generated one
if ! cmp -s "$NIX_SERVICE" "$SERVICE_FILE" 2>/dev/null; then
echo "Installing tailscaled systemd service (requires root)..."
run_root_cmd cp "$NIX_SERVICE" "$SERVICE_FILE"
run_root_cmd systemctl daemon-reload
run_root_cmd systemctl enable tailscaled
echo "Tailscaled service installed."
fi

# Configure sudo to include Nix profile paths
echo "Configuring sudo PATH for Nix packages..."
SUDOERS_CONTENT="# Added by home-manager for Nix Tailscale
Defaults secure_path=\"${config.home.homeDirectory}/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"
"

# Create temporary file with correct content
TEMP_SUDOERS=$(mktemp)
echo "$SUDOERS_CONTENT" > "$TEMP_SUDOERS"

# Only update if different or doesn't exist
if ! cmp -s "$TEMP_SUDOERS" "$SUDOERS_FILE" 2>/dev/null; then
run_root_cmd cp "$TEMP_SUDOERS" "$SUDOERS_FILE"
run_root_cmd chmod 0440 "$SUDOERS_FILE"
echo "Sudo PATH configured. You can now use: sudo tailscale login"
fi

rm -f "$TEMP_SUDOERS"
''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

This activation script performs significant system-level modifications, including copying service files to /etc/systemd/system and modifying /etc/sudoers.d. While DRY_RUN_CMD is used, direct manipulation of /etc by a home-manager module is a powerful operation. It's crucial to ensure these operations are thoroughly tested and that the sudoers file modification is strictly necessary and correctly configured to prevent unintended privilege escalation or system misconfiguration. Consider if there's a more declarative NixOS-native way to manage systemd services and sudoers entries if this configuration is intended for NixOS systems, or if this is strictly for non-NixOS Linux where home-manager acts more like a script runner.

Comment on lines +2 to +8
set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w"
ssh ubuntu@$KYBER_IP_ADDR
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

This function retrieves an SSH password from the macOS Keychain and uses sshpass for SSH authentication. While convenient, using sshpass can be less secure than SSH agent forwarding or key-based authentication without a passphrase, as it can expose the password in process lists or history. Additionally, the IP address 91.242.214.231 is hardcoded. It would be more robust and secure to use an SSH configuration file (~/.ssh/config) with IdentityFile and ProxyJump (if applicable) or to make the IP address a configurable variable. If a password is truly necessary, consider using a more secure method than sshpass if available, or at least ensure the Keychain is strongly protected.

Comment on lines +12 to +14
if ! command -v tailscale &>/dev/null; then
curl -fsSL https://tailscale.com/install.sh | sh
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Piping curl output directly to sh (curl -fsSL ... | sh) is a common practice but carries a security risk. It executes arbitrary code downloaded from the internet without prior inspection. While Tailscale's install script is generally trusted, for critical server setups, it's safer to download the script, review its contents, and then execute it. Consider replacing this with a two-step process: download, then execute.

Comment thread Makefile

.PHONY: switch
switch: nix-switch launchctl ## Apply Nix configuration and restart launchd agents.
switch: nix-switch ## Apply Nix configuration and restart launchd agents.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment for the switch target still mentions "restart launchd agents", but the launchctl dependency has been removed. This creates an inconsistency between the target's description and its actual actions.

switch: nix-switch ## Apply Nix configuration.

Comment thread Makefile
Comment on lines +323 to +328
if [ -n "$(HOST)" ]; then \
echo "Switching named home config: $(HOST)"; \
USER=$(NIX_USERNAME) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) --impure .#homeConfigurations.$(HOST).activationPackage; \
else \
USER=$(NIX_USERNAME) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) --impure .#$(NIX_CONFIG_TYPE)."$(NIX_USERNAME)@$(NIX_SYSTEM)".activationPackage; \
fi; \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the homeConfigurations block, the if [ -n "$(HOST)" ] branch hardcodes homeConfigurations.$(HOST).activationPackage, while the else branch uses $(NIX_CONFIG_TYPE)."$(NIX_USERNAME)@$(NIX_SYSTEM)".activationPackage. For consistency and to avoid potential issues if NIX_CONFIG_TYPE were to change its value unexpectedly within this context, it would be clearer to use $(NIX_CONFIG_TYPE) in both branches if it's guaranteed to be homeConfigurations at this point, or explicitly state homeConfigurations in both if that's the intent.

if [ -n "$(HOST)" ]; then \
	echo "Switching named home config: $(HOST)"; \
	USER=$(NIX_USERNAME) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) --impure .#$(NIX_CONFIG_TYPE).$(HOST).activationPackage; \
else \
	USER=$(NIX_USERNAME) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) --impure .#$(NIX_CONFIG_TYPE)."$(NIX_USERNAME)@$(NIX_SYSTEM)".activationPackage; \
fi;


# Declare directories and files for home-manager
home.file.".local/share/tailscale/tailscaled.state".source =
config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.local/state/tailscale/tailscaled.state";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The tailscaled.state file is configured to be a symlink from .local/share/tailscale/tailscaled.state to ${config.home.homeDirectory}/.local/state/tailscale/tailscaled.state. While xdg.dataHome defaults to ~/.local/share, the target path uses ~/.local/state. This creates an inconsistency in where state data is expected to reside according to XDG Base Directory Specification. It would be clearer and more consistent to either use xdg.stateHome for the target path or keep the state file directly within xdg.dataHome without symlinking to a different XDG directory type.

Comment on lines +48 to +50
```bash
kyber # Fish abbreviation that runs: ssh ubuntu@kyber
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The kyber abbreviation is documented here, but the underlying _kyber_function uses sshpass with a password retrieved from the Keychain and a hardcoded IP. The README should either explicitly mention these details or, ideally, guide users towards a more secure SSH setup (e.g., key-based authentication without sshpass and using SSH config for host aliases and identity files) to align with best security practices.

Comment on lines +22 to +23
sudo tailscale up

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The sudo tailscale up command will prompt for user authentication. Given that the _kyber_function.fish uses sshpass for SSH access, it implies a password-based setup. For server environments, it's generally recommended to use key-based authentication for tailscale up (e.g., via an auth key file managed by agenix, as commented out in named-hosts/kyber/default.nix) to avoid interactive password prompts and enhance automation and security.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 20 files

Prompt for AI agents (all 4 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="Makefile">

<violation number="1" location="Makefile:138">
P2: Comment is now misleading: the `launchctl` dependency was removed but the comment still says &quot;restart launchd agents&quot;. Update the comment to reflect the actual behavior.</violation>
</file>

<file name="home-manager/programs/fish/functions/_kyber_function.fish">

<violation number="1" location="home-manager/programs/fish/functions/_kyber_function.fish:4">
P1: Security vulnerability: Password passed as command-line argument is visible in process listings. Use `sshpass -e` with `SSHPASS` environment variable instead, or prefer SSH key authentication.</violation>
</file>

<file name="home-manager/modules/tailscale/default.nix">

<violation number="1" location="home-manager/modules/tailscale/default.nix:175">
P1: Auth key passed directly on command line is visible in process listings via `ps aux`. Consider deprecating the `authKey` option in favor of `authKeyFile` only, or use environment variables with `EnvironmentFile` to pass the secret securely.</violation>
</file>

<file name="config/k3s/default.nix">

<violation number="1" location="config/k3s/default.nix:17">
P2: Consider using more robust sudo detection like the tailscale module does. The hardcoded `/usr/bin/sudo` path may fail on systems where sudo is located elsewhere (e.g., NixOS), and there&#39;s no error handling if the command fails.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Comment thread Makefile

.PHONY: switch
switch: nix-switch launchctl ## Apply Nix configuration and restart launchd agents.
switch: nix-switch ## Apply Nix configuration and restart launchd agents.

@cubic-dev-ai cubic-dev-ai Bot Dec 10, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Comment is now misleading: the launchctl dependency was removed but the comment still says "restart launchd agents". Update the comment to reflect the actual behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Makefile, line 138:

<comment>Comment is now misleading: the `launchctl` dependency was removed but the comment still says &quot;restart launchd agents&quot;. Update the comment to reflect the actual behavior.</comment>

<file context>
@@ -135,7 +135,7 @@ setup: nix-setup ## Basic Nix setup (alias for nix-setup).
 
 .PHONY: switch
-switch: nix-switch launchctl ## Apply Nix configuration and restart launchd agents.
+switch: nix-switch ## Apply Nix configuration and restart launchd agents.
 
 .PHONY: test
</file context>
Suggested change
switch: nix-switch ## Apply Nix configuration and restart launchd agents.
switch: nix-switch ## Apply Nix configuration.
Fix with Cubic

function _kyber_function --description "SSH to Kyber server"
set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR

@cubic-dev-ai cubic-dev-ai Bot Dec 10, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Security vulnerability: Password passed as command-line argument is visible in process listings. Use sshpass -e with SSHPASS environment variable instead, or prefer SSH key authentication.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/fish/functions/_kyber_function.fish, line 4:

<comment>Security vulnerability: Password passed as command-line argument is visible in process listings. Use `sshpass -e` with `SSHPASS` environment variable instead, or prefer SSH key authentication.</comment>

<file context>
@@ -0,0 +1,9 @@
+function _kyber_function --description &quot;SSH to Kyber server&quot;
+  set -l password (security find-generic-password -s &quot;ssh ubuntu@91.242.214.231&quot; -w 2&gt;/dev/null)
+  if test -n &quot;$password&quot;
+    sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
+  else
+    echo &quot;Password not found in Keychain. Run: security add-generic-password -s &#39;ssh ubuntu@91.242.214.231&#39; -a ubuntu -w&quot;
</file context>
Fix with Cubic

let
authKeyArg =
if cfg.authKey != "" then
"--authkey=${cfg.authKey}"

@cubic-dev-ai cubic-dev-ai Bot Dec 10, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Auth key passed directly on command line is visible in process listings via ps aux. Consider deprecating the authKey option in favor of authKeyFile only, or use environment variables with EnvironmentFile to pass the secret securely.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/modules/tailscale/default.nix, line 175:

<comment>Auth key passed directly on command line is visible in process listings via `ps aux`. Consider deprecating the `authKey` option in favor of `authKeyFile` only, or use environment variables with `EnvironmentFile` to pass the secret securely.</comment>

<file context>
@@ -0,0 +1,277 @@
+        let
+          authKeyArg =
+            if cfg.authKey != &quot;&quot; then
+              &quot;--authkey=${cfg.authKey}&quot;
+            else if cfg.authKeyFile != &quot;&quot; then
+              &quot;--authkey-file=${cfg.authKeyFile}&quot;
</file context>
Fix with Cubic

Comment thread config/k3s/default.nix
home.activation.k3s-config = lib.mkIf pkgs.stdenv.isLinux (
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ -f "$HOME/.config/k3s/config.yaml" ]; then
$DRY_RUN_CMD /usr/bin/sudo mkdir -p /etc/rancher/k3s

@cubic-dev-ai cubic-dev-ai Bot Dec 10, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Consider using more robust sudo detection like the tailscale module does. The hardcoded /usr/bin/sudo path may fail on systems where sudo is located elsewhere (e.g., NixOS), and there's no error handling if the command fails.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/k3s/default.nix, line 17:

<comment>Consider using more robust sudo detection like the tailscale module does. The hardcoded `/usr/bin/sudo` path may fail on systems where sudo is located elsewhere (e.g., NixOS), and there&#39;s no error handling if the command fails.</comment>

<file context>
@@ -0,0 +1,22 @@
+  home.activation.k3s-config = lib.mkIf pkgs.stdenv.isLinux (
+    lib.hm.dag.entryAfter [ &quot;writeBoundary&quot; ] &#39;&#39;
+      if [ -f &quot;$HOME/.config/k3s/config.yaml&quot; ]; then
+        $DRY_RUN_CMD /usr/bin/sudo mkdir -p /etc/rancher/k3s
+        $DRY_RUN_CMD /usr/bin/sudo cp &quot;$HOME/.config/k3s/config.yaml&quot; /etc/rancher/k3s/config.yaml
+      fi
</file context>
Fix with Cubic

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configuration for a new Ubuntu Linux host called "Kyber" with Tailscale VPN integration, along with several related improvements to the Makefile, package management, and configuration files. The changes enable managing remote Linux servers using home-manager with secure networking through Tailscale.

  • Adds comprehensive Kyber host configuration with home-manager, Tailscale, and agenix secrets management
  • Implements a reusable Tailscale home-manager module with system service installation support
  • Enhances the Makefile's switch target to support named host configurations via HOST parameter
  • Adds k3s and cliproxyapi configuration support

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Makefile Removes launchctl dependency from switch target (macOS-specific); adds HOST parameter support for named configurations
package.json Adds @beads/bd package dependency
bun.lock Locks @beads/bd@0.29.0 with binary support
nix-darwin/config/homebrew.nix Adds sshpass for password-based SSH connections
home-manager/modules/tailscale/default.nix New comprehensive Tailscale module with system service installation and sudo/doas detection
home-manager/modules/default.nix Registers the new Tailscale module
home-manager/packages/default.nix Adds doppler package
home-manager/programs/fish/default.nix Adds cliproxyapi alias and kyber abbreviation for SSH access
home-manager/programs/fish/functions/_kyber_function.fish New SSH function with macOS Keychain password integration
named-hosts/kyber/default.nix Main configuration for Kyber Ubuntu host with Tailscale and agenix
named-hosts/kyber/secrets.nix Template for agenix secrets (currently empty/commented)
named-hosts/kyber/setup.sh Bootstrap script for initial Tailscale installation on Kyber
named-hosts/kyber/README.md Documentation for Kyber setup, secrets management, and SSH access
config/k3s/default.nix K3s configuration management with sudo-based activation
config/k3s/config.yaml K3s config to disable traefik
config/default.nix Registers k3s configuration module
config/cliproxyapi/default.nix Adds example config file for cliproxyapi bootstrap
config/cliproxyapi/config.yaml Enables remote management access
config/claude/settings.json Adds git fetch to allowed Bash commands
flake.nix Registers kyber as a new homeConfigurations entry
Comments suppressed due to low confidence (1)

home-manager/programs/fish/functions/_kyber_function.fish:4

  • Passing password as a command-line argument (-p $password) exposes it in process listings and system logs. This is a security vulnerability as any user on the system can see the password by running ps aux or similar commands. Consider using SSH key-based authentication instead, or use sshpass with the -e flag and pass the password via the SSHPASS environment variable.
    sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Whether to allow remote (non-localhost) management access.
# When false, only localhost can access management endpoints (a key is still required).
allow-remote: false
allow-remote: true

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling allow-remote: true exposes the management API to non-localhost connections. While authentication is still required (line 11 shows secret-key: ""), the empty secret key means the Management API is currently disabled (404 for all routes). If a secret key is later added, this configuration will allow remote access. Ensure this is intentional and that strong authentication is in place before deploying.

Suggested change
allow-remote: true
allow-remote: false

Copilot uses AI. Check for mistakes.
Comment thread config/k3s/default.nix
Comment on lines +17 to +18
$DRY_RUN_CMD /usr/bin/sudo mkdir -p /etc/rancher/k3s
$DRY_RUN_CMD /usr/bin/sudo cp "$HOME/.config/k3s/config.yaml" /etc/rancher/k3s/config.yaml

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded path /usr/bin/sudo may not work on all Linux distributions (e.g., NixOS places sudo in a different location). Consider using just sudo without the full path to let the shell's PATH resolution find it, or follow the pattern used in the Tailscale module (lines 223-237 in home-manager/modules/tailscale/default.nix) which checks for sudo availability before using it.

Suggested change
$DRY_RUN_CMD /usr/bin/sudo mkdir -p /etc/rancher/k3s
$DRY_RUN_CMD /usr/bin/sudo cp "$HOME/.config/k3s/config.yaml" /etc/rancher/k3s/config.yaml
$DRY_RUN_CMD sudo mkdir -p /etc/rancher/k3s
$DRY_RUN_CMD sudo cp "$HOME/.config/k3s/config.yaml" /etc/rancher/k3s/config.yaml

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +50
```bash
kyber # Fish abbreviation that runs: ssh ubuntu@kyber
```

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation mentions using the kyber Fish abbreviation for SSH access, but doesn't document that the KYBER_IP_ADDR environment variable must be set for the function to work. Add a note about setting this environment variable (e.g., in the Initial Setup section or SSH Access section).

Copilot uses AI. Check for mistakes.
Comment on lines +219 to +273
SERVICE_FILE="/etc/systemd/system/tailscaled.service"
NIX_SERVICE="${tailscaledServiceFile}"
SUDOERS_FILE="/etc/sudoers.d/nix-tailscale"

# Resolve an elevated command helper
SUDO_CMD=""
if command -v sudo >/dev/null 2>&1; then
SUDO_CMD="sudo"
elif [ -x /usr/bin/sudo ]; then
SUDO_CMD="/usr/bin/sudo"
elif command -v doas >/dev/null 2>&1; then
SUDO_CMD="doas"
elif [ -x /usr/bin/doas ]; then
SUDO_CMD="/usr/bin/doas"
elif [ "$(id -u)" -ne 0 ]; then
echo "Tailscale system service installation requires root privileges, but sudo/doas is not available." >&2
echo "Either install sudo, configure doas, or run home-manager as root." >&2
exit 1
fi

run_root_cmd() {
if [ -n "$SUDO_CMD" ]; then
''${DRY_RUN_CMD:-} "$SUDO_CMD" "$@"
else
''${DRY_RUN_CMD:-} "$@"
fi
}

# Only install if service file differs from nix-generated one
if ! cmp -s "$NIX_SERVICE" "$SERVICE_FILE" 2>/dev/null; then
echo "Installing tailscaled systemd service (requires root)..."
run_root_cmd cp "$NIX_SERVICE" "$SERVICE_FILE"
run_root_cmd systemctl daemon-reload
run_root_cmd systemctl enable tailscaled
echo "Tailscaled service installed."
fi

# Configure sudo to include Nix profile paths
echo "Configuring sudo PATH for Nix packages..."
SUDOERS_CONTENT="# Added by home-manager for Nix Tailscale
Defaults secure_path=\"${config.home.homeDirectory}/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"
"

# Create temporary file with correct content
TEMP_SUDOERS=$(mktemp)
echo "$SUDOERS_CONTENT" > "$TEMP_SUDOERS"

# Only update if different or doesn't exist
if ! cmp -s "$TEMP_SUDOERS" "$SUDOERS_FILE" 2>/dev/null; then
run_root_cmd cp "$TEMP_SUDOERS" "$SUDOERS_FILE"
run_root_cmd chmod 0440 "$SUDOERS_FILE"
echo "Sudo PATH configured. You can now use: sudo tailscale login"
fi

rm -f "$TEMP_SUDOERS"

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The shell script has inconsistent and excessive indentation (using many leading spaces). This makes the code harder to read and maintain. Consider aligning the script content to the left margin with minimal indentation, similar to the style used in the createTailscaleDirs activation script (lines 202-213).

Suggested change
SERVICE_FILE="/etc/systemd/system/tailscaled.service"
NIX_SERVICE="${tailscaledServiceFile}"
SUDOERS_FILE="/etc/sudoers.d/nix-tailscale"
# Resolve an elevated command helper
SUDO_CMD=""
if command -v sudo >/dev/null 2>&1; then
SUDO_CMD="sudo"
elif [ -x /usr/bin/sudo ]; then
SUDO_CMD="/usr/bin/sudo"
elif command -v doas >/dev/null 2>&1; then
SUDO_CMD="doas"
elif [ -x /usr/bin/doas ]; then
SUDO_CMD="/usr/bin/doas"
elif [ "$(id -u)" -ne 0 ]; then
echo "Tailscale system service installation requires root privileges, but sudo/doas is not available." >&2
echo "Either install sudo, configure doas, or run home-manager as root." >&2
exit 1
fi
run_root_cmd() {
if [ -n "$SUDO_CMD" ]; then
''${DRY_RUN_CMD:-} "$SUDO_CMD" "$@"
else
''${DRY_RUN_CMD:-} "$@"
fi
}
# Only install if service file differs from nix-generated one
if ! cmp -s "$NIX_SERVICE" "$SERVICE_FILE" 2>/dev/null; then
echo "Installing tailscaled systemd service (requires root)..."
run_root_cmd cp "$NIX_SERVICE" "$SERVICE_FILE"
run_root_cmd systemctl daemon-reload
run_root_cmd systemctl enable tailscaled
echo "Tailscaled service installed."
fi
# Configure sudo to include Nix profile paths
echo "Configuring sudo PATH for Nix packages..."
SUDOERS_CONTENT="# Added by home-manager for Nix Tailscale
Defaults secure_path=\"${config.home.homeDirectory}/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"
"
# Create temporary file with correct content
TEMP_SUDOERS=$(mktemp)
echo "$SUDOERS_CONTENT" > "$TEMP_SUDOERS"
# Only update if different or doesn't exist
if ! cmp -s "$TEMP_SUDOERS" "$SUDOERS_FILE" 2>/dev/null; then
run_root_cmd cp "$TEMP_SUDOERS" "$SUDOERS_FILE"
run_root_cmd chmod 0440 "$SUDOERS_FILE"
echo "Sudo PATH configured. You can now use: sudo tailscale login"
fi
rm -f "$TEMP_SUDOERS"
SERVICE_FILE="/etc/systemd/system/tailscaled.service"
NIX_SERVICE="${tailscaledServiceFile}"
SUDOERS_FILE="/etc/sudoers.d/nix-tailscale"
# Resolve an elevated command helper
SUDO_CMD=""
if command -v sudo >/dev/null 2>&1; then
SUDO_CMD="sudo"
elif [ -x /usr/bin/sudo ]; then
SUDO_CMD="/usr/bin/sudo"
elif command -v doas >/dev/null 2>&1; then
SUDO_CMD="doas"
elif [ -x /usr/bin/doas ]; then
SUDO_CMD="/usr/bin/doas"
elif [ "$(id -u)" -ne 0 ]; then
echo "Tailscale system service installation requires root privileges, but sudo/doas is not available." >&2
echo "Either install sudo, configure doas, or run home-manager as root." >&2
exit 1
fi
run_root_cmd() {
if [ -n "$SUDO_CMD" ]; then
''${DRY_RUN_CMD:-} "$SUDO_CMD" "$@"
else
''${DRY_RUN_CMD:-} "$@"
fi
}
# Only install if service file differs from nix-generated one
if ! cmp -s "$NIX_SERVICE" "$SERVICE_FILE" 2>/dev/null; then
echo "Installing tailscaled systemd service (requires root)..."
run_root_cmd cp "$NIX_SERVICE" "$SERVICE_FILE"
run_root_cmd systemctl daemon-reload
run_root_cmd systemctl enable tailscaled
echo "Tailscaled service installed."
fi
# Configure sudo to include Nix profile paths
echo "Configuring sudo PATH for Nix packages..."
SUDOERS_CONTENT="# Added by home-manager for Nix Tailscale
Defaults secure_path=\"${config.home.homeDirectory}/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"
"
# Create temporary file with correct content
TEMP_SUDOERS=$(mktemp)
echo "$SUDOERS_CONTENT" > "$TEMP_SUDOERS"
# Only update if different or doesn't exist
if ! cmp -s "$TEMP_SUDOERS" "$SUDOERS_FILE" 2>/dev/null; then
run_root_cmd cp "$TEMP_SUDOERS" "$SUDOERS_FILE"
run_root_cmd chmod 0440 "$SUDOERS_FILE"
echo "Sudo PATH configured. You can now use: sudo tailscale login"
fi
rm -f "$TEMP_SUDOERS"

Copilot uses AI. Check for mistakes.
Comment thread package.json
"license": "ISC",
"packageManager": "bun@1.3.0",
"dependencies": {
"@beads/bd": "^0.29.0",

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @beads/bd package includes a binary (bin/bd.js according to bun.lock line 49) but is not listed in the trustedDependencies array. Packages with install scripts or binaries should typically be included in trustedDependencies to explicitly declare trust for execution during installation. Consider adding "@beads/bd" to the trustedDependencies array (line 26-37).

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +7
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w"
ssh ubuntu@$KYBER_IP_ADDR

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable $KYBER_IP_ADDR is undefined and not set anywhere in the codebase. This will cause the SSH command to fail or connect to an unintended host. The function references the IP 91.242.214.231 in the keychain lookup (line 2) but uses the undefined variable for the actual connection. Either define KYBER_IP_ADDR as an environment variable or use the IP address directly.

Suggested change
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w"
ssh ubuntu@$KYBER_IP_ADDR
sshpass -p $password ssh ubuntu@91.242.214.231
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w"
ssh ubuntu@91.242.214.231

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +6
set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w"

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function contains a hardcoded IP address (91.242.214.231) in the keychain service name. This makes the function less maintainable and could lead to confusion if the IP changes. Consider using a hostname or a constant variable instead.

Suggested change
set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w"
set -l password (security find-generic-password -s "ssh ubuntu@$KYBER_IP_ADDR" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
else
echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@$KYBER_IP_ADDR' -a ubuntu -w"

Copilot uses AI. Check for mistakes.
function _kyber_function --description "SSH to Kyber server"
set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR exposes the SSH password as a command-line argument, which can be read by other local users or malware via process listings and system logs, leaking credentials for the Kyber server. An attacker with local user access could monitor running processes to capture the password and then reuse it to log into the remote host. To avoid exposing credentials, prefer key-based SSH authentication, or if sshpass is required, use a more secure mechanism (e.g., reading the password from a protected file or environment variable with sshpass -e) instead of passing it directly on the command line.

Suggested change
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR
set -lx SSHPASS $password
sshpass -e ssh ubuntu@$KYBER_IP_ADDR

Copilot uses AI. Check for mistakes.

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performed full review of 3d9f07b...3cd48e9

Analysis

  1. System-Level Operations via Home Manager: Using a user-space tool (Home Manager) to manage system-level services creates security boundary issues, risks partial configuration on sudo failures, and leaves persistent system changes that violate declarative principles.

  2. Incomplete Automation Chain: Critical elements are missing or commented out (Tailscale auth keys, SSH key validation, undefined environment variables), requiring manual intervention and undermining the declarative configuration approach.

  3. Expanded Attack Surface: Remote management for cliproxyapi is enabled without visible authentication configuration, and password-based SSH authentication is used instead of more secure alternatives like Tailscale SSH.

  4. Cross-Platform Compatibility Issues: The configuration mixes Darwin-specific elements with Linux-focused additions without proper platform guards, including hard-coded paths that will fail on different systems.

  5. Silent Failures: Multiple sudo operations during home-manager activation could fail silently, and the k3s configuration sync lacks error handling and validation.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

20 files reviewed | 6 comments | Edit Agent SettingsRead Docs

elif [ "$(id -u)" -ne 0 ]; then
echo "Tailscale system service installation requires root privileges, but sudo/doas is not available." >&2
echo "Either install sudo, configure doas, or run home-manager as root." >&2
exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

Using exit 1 here will abort the entire home-manager activation if sudo/doas is unavailable, potentially leaving the system in a partially configured state. Consider using a warning instead of a hard error, or add a configuration option to make system service installation optional. This is especially problematic since the module has installSystemService = true by default.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#404
File: home-manager/modules/tailscale/default.nix#L236
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
Using `exit 1` here will abort the entire home-manager activation if sudo/doas is unavailable, potentially leaving the system in a partially configured state. Consider using a warning instead of a hard error, or add a configuration option to make system service installation optional. This is especially problematic since the module has `installSystemService = true` by default.

};

# Agenix configuration
age.identityPaths = [ "/home/${username}/.ssh/id_ed25519" ];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

The SSH key path /home/${username}/.ssh/id_ed25519 is assumed to exist but is never created or validated. If this key doesn't exist when agenix tries to decrypt secrets, the entire home-manager activation will fail. Consider adding an activation script to generate the SSH key if it doesn't exist, or document this as a prerequisite in the README.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#404
File: named-hosts/kyber/default.nix#L47
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
The SSH key path `/home/${username}/.ssh/id_ed25519` is assumed to exist but is never created or validated. If this key doesn't exist when agenix tries to decrypt secrets, the entire home-manager activation will fail. Consider adding an activation script to generate the SSH key if it doesn't exist, or document this as a prerequisite in the README.

function _kyber_function --description "SSH to Kyber server"
set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null)
if test -n "$password"
sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High

The variable $KYBER_IP_ADDR is undefined and will cause SSH connection failures. Additionally, using sshpass -p $password exposes the password in process arguments (visible via ps). Consider either: 1) Define KYBER_IP_ADDR as an environment variable in the fish config, or 2) Use the Tailscale hostname directly (e.g., kyber.tailnet-name.ts.net), which would be more secure and eliminate the need for password-based auth entirely.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#404
File: home-manager/programs/fish/functions/_kyber_function.fish#L4
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
The variable `$KYBER_IP_ADDR` is undefined and will cause SSH connection failures. Additionally, using `sshpass -p $password` exposes the password in process arguments (visible via `ps`). Consider either: 1) Define `KYBER_IP_ADDR` as an environment variable in the fish config, or 2) Use the Tailscale hostname directly (e.g., `kyber.tailnet-name.ts.net`), which would be more secure and eliminate the need for password-based auth entirely.

# Whether to allow remote (non-localhost) management access.
# When false, only localhost can access management endpoints (a key is still required).
allow-remote: false
allow-remote: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

Enabling remote management access significantly expands the attack surface. While line 10 mentions that a management key is required, the actual key configuration is not visible in this diff. Ensure that: 1) A strong management key is configured (not left empty/default), 2) The service is only accessible via Tailscale VPN (not exposed to the public internet), and 3) This change is intentional and documented in the PR description with security implications.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#404
File: config/cliproxyapi/config.yaml#L7
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
Enabling remote management access significantly expands the attack surface. While line 10 mentions that a management key is required, the actual key configuration is not visible in this diff. Ensure that: 1) A strong management key is configured (not left empty/default), 2) The service is only accessible via Tailscale VPN (not exposed to the public internet), and 3) This change is intentional and documented in the PR description with security implications.


# Configure sudo to include Nix profile paths
echo "Configuring sudo PATH for Nix packages..."
SUDOERS_CONTENT="# Added by home-manager for Nix Tailscale

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

Modifying /etc/sudoers.d/ during every home-manager activation creates a permanent system-level change that persists even after uninstalling the module. This violates the principle of declarative configuration management. Consider: 1) Documenting this as a manual setup step, 2) Adding a cleanup mechanism in a deactivation hook, or 3) Using a different approach that doesn't require persistent sudoers modifications.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#404
File: home-manager/modules/tailscale/default.nix#L258
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
Modifying `/etc/sudoers.d/` during every home-manager activation creates a permanent system-level change that persists even after uninstalling the module. This violates the principle of declarative configuration management. Consider: 1) Documenting this as a manual setup step, 2) Adding a cleanup mechanism in a deactivation hook, or 3) Using a different approach that doesn't require persistent sudoers modifications.

Comment thread config/k3s/default.nix
home.activation.k3s-config = lib.mkIf pkgs.stdenv.isLinux (
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ -f "$HOME/.config/k3s/config.yaml" ]; then
$DRY_RUN_CMD /usr/bin/sudo mkdir -p /etc/rancher/k3s

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

The hard-coded /usr/bin/sudo path will fail on systems where sudo is installed elsewhere (e.g., NixOS where it's in /run/wrappers/bin/sudo, or some distributions using /bin/sudo). Use command -v sudo or check multiple paths as done in the Tailscale module (lines 225-236 of home-manager/modules/tailscale/default.nix). Additionally, there's no error handling if the sudo commands fail.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#404
File: config/k3s/default.nix#L17
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
The hard-coded `/usr/bin/sudo` path will fail on systems where sudo is installed elsewhere (e.g., NixOS where it's in `/run/wrappers/bin/sudo`, or some distributions using `/bin/sudo`). Use `command -v sudo` or check multiple paths as done in the Tailscale module (lines 225-236 of `home-manager/modules/tailscale/default.nix`). Additionally, there's no error handling if the sudo commands fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants