Compare commits
10 Commits
nix-deck-s
...
63bf19b85f
| Author | SHA1 | Date | |
|---|---|---|---|
| 63bf19b85f | |||
| 1f9e9138ab | |||
| e218822566 | |||
| e88f3580e9 | |||
| 5451e75480 | |||
| fc9474a7c9 | |||
| 20daebbd61 | |||
| 3be23304c4 | |||
| 9059a739a0 | |||
| 977125645b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
result
|
result
|
||||||
|
thoughts
|
||||||
|
|||||||
@@ -1,280 +0,0 @@
|
|||||||
# Steam Deck (nix-deck) Jovian-NixOS Setup Guide
|
|
||||||
|
|
||||||
This document describes the setup for installing and maintaining NixOS with Jovian-NixOS on a Steam Deck.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
The `nix-deck` configuration provides:
|
|
||||||
- **Jovian-NixOS integration** for Steam Deck hardware support
|
|
||||||
- **Remote building** using `zix790prors` as the build host
|
|
||||||
- **SteamOS role** for easy Steam Deck UI configuration
|
|
||||||
- **Compatibility shim** for using Jovian on NixOS 25.05 stable
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
### Remote Building
|
|
||||||
|
|
||||||
The setup uses distributed builds to avoid slow compilation on the Steam Deck:
|
|
||||||
|
|
||||||
- **Build Host**: `zix790prors` (powerful desktop)
|
|
||||||
- Runs as a dedicated `nix-builder` user (not root)
|
|
||||||
- Accepts SSH connections from client machines
|
|
||||||
- Performs all heavy compilation work
|
|
||||||
|
|
||||||
- **Build Clients**: `nix-book` and `nix-deck`
|
|
||||||
- Automatically offload builds to `zix790prors`
|
|
||||||
- Fall back to local building if remote builder is unavailable
|
|
||||||
- Steam Deck heavily prefers remote (speedFactor=4)
|
|
||||||
|
|
||||||
### Jovian-NixOS Integration
|
|
||||||
|
|
||||||
- **Jovian module**: Provides Steam Deck hardware support, drivers, and Steam UI
|
|
||||||
- **Compatibility layer**: `roles/jovian-compat.nix` provides `services.logind.settings` for NixOS 25.05
|
|
||||||
- **IMPORTANT**: Remove this when upgrading to NixOS 25.11+
|
|
||||||
- An assertion will fail the build if used on 25.11+
|
|
||||||
|
|
||||||
- **SteamOS role**: `roles.desktop.steamos` abstracts Jovian configuration
|
|
||||||
```nix
|
|
||||||
roles.desktop.steamos = {
|
|
||||||
enable = true;
|
|
||||||
autoStart = false; # Set to true to boot directly to Steam UI
|
|
||||||
desktopSession = "plasmawayland";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Initial Installation
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
1. Steam Deck in recovery mode or booted to a live Linux environment
|
|
||||||
2. SSH access enabled on the Steam Deck
|
|
||||||
3. SSH key set up for passwordless authentication
|
|
||||||
|
|
||||||
### Option 1: Using nixos-anywhere (Initial Install Only)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# From your main machine
|
|
||||||
nix run github:nix-community/nixos-anywhere -- \
|
|
||||||
--flake .#nix-deck \
|
|
||||||
root@<steam-deck-ip>
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note**: This is only for the initial install. For updates, see below.
|
|
||||||
|
|
||||||
### Option 2: Manual Installation
|
|
||||||
|
|
||||||
1. Boot Steam Deck from NixOS installer USB
|
|
||||||
2. Partition and format the disk
|
|
||||||
3. Mount filesystems
|
|
||||||
4. Clone this repository
|
|
||||||
5. Generate hardware config:
|
|
||||||
```bash
|
|
||||||
nixos-generate-config --show-hardware-config > /tmp/hw.nix
|
|
||||||
```
|
|
||||||
6. Copy the hardware config content to `machines/nix-deck/hardware-configuration.nix`
|
|
||||||
7. Keep the `jovian.devices.steamdeck` settings in the file
|
|
||||||
8. Install:
|
|
||||||
```bash
|
|
||||||
nixos-install --flake .#nix-deck
|
|
||||||
```
|
|
||||||
|
|
||||||
## Updates and Rebuilds
|
|
||||||
|
|
||||||
### Method 1: Remote Build and Deploy (Recommended)
|
|
||||||
|
|
||||||
Build on your main machine, deploy to Steam Deck:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# From nix-book or zix790prors
|
|
||||||
nixos-rebuild switch \
|
|
||||||
--flake .#nix-deck \
|
|
||||||
--target-host root@nix-deck \
|
|
||||||
--build-host localhost
|
|
||||||
```
|
|
||||||
|
|
||||||
### Method 2: On-Device Rebuild (Uses Remote Builder)
|
|
||||||
|
|
||||||
The Steam Deck is configured to automatically use `zix790prors` as a remote builder:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# SSH into the Steam Deck
|
|
||||||
ssh root@nix-deck
|
|
||||||
|
|
||||||
# This will automatically build on zix790prors
|
|
||||||
nixos-rebuild switch --flake /path/to/nixos-configs#nix-deck
|
|
||||||
```
|
|
||||||
|
|
||||||
The build will automatically happen on `zix790prors` and be deployed locally.
|
|
||||||
|
|
||||||
## Remote Builder Setup
|
|
||||||
|
|
||||||
### On the Build Host (zix790prors)
|
|
||||||
|
|
||||||
The configuration creates a `nix-builder` user that client machines connect to:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
roles.remote-build.enableBuilder = true;
|
|
||||||
```
|
|
||||||
|
|
||||||
### On Client Machines (nix-book, nix-deck)
|
|
||||||
|
|
||||||
Configure the remote builder:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
roles.remote-build.builders = [{
|
|
||||||
hostName = "zix790prors";
|
|
||||||
maxJobs = 16;
|
|
||||||
speedFactor = 4; # Higher = prefer remote more
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
### SSH Key Setup
|
|
||||||
|
|
||||||
1. Generate SSH key on the builder host for the `nix-builder` user:
|
|
||||||
```bash
|
|
||||||
sudo -u nix-builder ssh-keygen -t ed25519 -f /var/lib/nix-builder/.ssh/id_ed25519
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Copy the public key to client machines:
|
|
||||||
```bash
|
|
||||||
# Add to /var/lib/nix-builder/.ssh/authorized_keys on zix790prors
|
|
||||||
```
|
|
||||||
|
|
||||||
3. On client machines, ensure you can connect:
|
|
||||||
```bash
|
|
||||||
ssh nix-builder@zix790prors
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuration Files
|
|
||||||
|
|
||||||
### Key Files Created/Modified
|
|
||||||
|
|
||||||
- `flake.nix` - Added Jovian input and nix-deck configuration
|
|
||||||
- `roles/jovian-compat.nix` - Compatibility shim (remove in 25.11+)
|
|
||||||
- `roles/desktop/steamos.nix` - SteamOS/Jovian role abstraction
|
|
||||||
- `roles/remote-build/default.nix` - Remote builder role
|
|
||||||
- `machines/nix-deck/configuration.nix` - Steam Deck system config
|
|
||||||
- `machines/nix-deck/hardware-configuration.nix` - Hardware config (placeholder)
|
|
||||||
|
|
||||||
### Example Configuration
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# machines/nix-deck/configuration.nix
|
|
||||||
{
|
|
||||||
roles = {
|
|
||||||
desktop = {
|
|
||||||
enable = true;
|
|
||||||
wayland = true;
|
|
||||||
gaming.enable = true;
|
|
||||||
kde = true;
|
|
||||||
sddm = true;
|
|
||||||
steamos = {
|
|
||||||
enable = true;
|
|
||||||
autoStart = false; # or true to boot to Steam UI
|
|
||||||
desktopSession = "plasmawayland";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
remote-build.builders = [{
|
|
||||||
hostName = "zix790prors";
|
|
||||||
maxJobs = 16;
|
|
||||||
speedFactor = 4;
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Jovian Features
|
|
||||||
|
|
||||||
### Enabled by Default
|
|
||||||
|
|
||||||
- Steam Deck hardware support (`jovian.devices.steamdeck.enable`)
|
|
||||||
- Steam UI (`jovian.steam.enable`)
|
|
||||||
- Decky Loader plugin system (`jovian.decky-loader.enable`)
|
|
||||||
|
|
||||||
### Optional Features
|
|
||||||
|
|
||||||
Set in the hardware-configuration.nix:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
jovian.devices.steamdeck = {
|
|
||||||
enable = true;
|
|
||||||
autoUpdate = false; # Auto-update BIOS/controller firmware
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manual Firmware Updates
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# BIOS update
|
|
||||||
sudo jupiter-biosupdate
|
|
||||||
|
|
||||||
# Controller update
|
|
||||||
sudo jupiter-controller-update
|
|
||||||
|
|
||||||
# Docking station (connect via USB-C first)
|
|
||||||
jupiter-dock-updater
|
|
||||||
```
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Remote Builds Not Working
|
|
||||||
|
|
||||||
1. Check SSH connectivity:
|
|
||||||
```bash
|
|
||||||
ssh nix-builder@zix790prors
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Verify builder is trusted:
|
|
||||||
```bash
|
|
||||||
# On zix790prors
|
|
||||||
nix show-config | grep trusted-users
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Check build logs:
|
|
||||||
```bash
|
|
||||||
journalctl -u nix-daemon -f
|
|
||||||
```
|
|
||||||
|
|
||||||
### Jovian Not Working
|
|
||||||
|
|
||||||
1. Ensure you're on NixOS 25.05 or the compatibility layer is removed for 25.11+
|
|
||||||
2. Check Jovian is imported in flake.nix
|
|
||||||
3. Verify hardware config has `jovian.devices.steamdeck.enable = true`
|
|
||||||
|
|
||||||
### Compatibility Layer Issues
|
|
||||||
|
|
||||||
If you see an error about `jovian-compat.nix` being incompatible:
|
|
||||||
|
|
||||||
1. You're running NixOS 25.11 or later
|
|
||||||
2. Remove `./roles/jovian-compat.nix` from `flake.nix`
|
|
||||||
3. Jovian should work natively on 25.11+
|
|
||||||
|
|
||||||
## Future Upgrades
|
|
||||||
|
|
||||||
### Upgrading to NixOS 25.11
|
|
||||||
|
|
||||||
1. Update `nixpkgs` input in flake.nix to 25.11
|
|
||||||
2. Remove `./roles/jovian-compat.nix` from flake.nix imports
|
|
||||||
3. The assertion in jovian-compat.nix will prevent accidental use
|
|
||||||
4. Test the build
|
|
||||||
5. Deploy
|
|
||||||
|
|
||||||
### Switching to Unstable
|
|
||||||
|
|
||||||
If you need Jovian to follow unstable nixpkgs:
|
|
||||||
|
|
||||||
1. Edit `flake.nix`:
|
|
||||||
```nix
|
|
||||||
jovian = {
|
|
||||||
url = "github:Jovian-Experiments/Jovian-NixOS";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
2. This only affects Jovian packages, not your base system
|
|
||||||
|
|
||||||
## Additional Resources
|
|
||||||
|
|
||||||
- [Jovian-NixOS Documentation](https://jovian-experiments.github.io/Jovian-NixOS/)
|
|
||||||
- [Jovian Steam Deck Guide](https://jovian-experiments.github.io/Jovian-NixOS/devices/valve-steam-deck/)
|
|
||||||
- [NixOS Remote Builds](https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html)
|
|
||||||
@@ -14,6 +14,7 @@ in
|
|||||||
# System packages
|
# System packages
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
autoraise
|
autoraise
|
||||||
|
google-cloud-sdk
|
||||||
];
|
];
|
||||||
|
|
||||||
# Note: ghostty installed via Homebrew (managed outside of nix)
|
# Note: ghostty installed via Homebrew (managed outside of nix)
|
||||||
@@ -222,6 +223,10 @@ in
|
|||||||
|
|
||||||
home.roles = {
|
home.roles = {
|
||||||
base.enable = true;
|
base.enable = true;
|
||||||
|
development = {
|
||||||
|
enable = true;
|
||||||
|
allowArbitraryClaudeCodeModelSelection = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
communication.enable = true;
|
communication.enable = true;
|
||||||
sync.enable = true;
|
sync.enable = true;
|
||||||
kdeconnect.enable = true;
|
kdeconnect.enable = true;
|
||||||
|
kubectl.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
targets.genericLinux.enable = true;
|
targets.genericLinux.enable = true;
|
||||||
@@ -30,4 +31,4 @@
|
|||||||
./modules/plasma-manager
|
./modules/plasma-manager
|
||||||
./modules/tmux
|
./modules/tmux
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
kdeconnect.enable = true;
|
kdeconnect.enable = true;
|
||||||
media.enable = true;
|
media.enable = true;
|
||||||
sync.enable = true;
|
sync.enable = true;
|
||||||
|
kubectl.enable = true;
|
||||||
# office.enable = false; # Excluded for storage constraints
|
# office.enable = false; # Excluded for storage constraints
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -32,5 +33,4 @@
|
|||||||
./modules/plasma-manager
|
./modules/plasma-manager
|
||||||
./modules/tmux
|
./modules/tmux
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
./development
|
./development
|
||||||
./gaming
|
./gaming
|
||||||
./kdeconnect
|
./kdeconnect
|
||||||
|
./kubectl
|
||||||
./media
|
./media
|
||||||
./office
|
./office
|
||||||
./sync
|
./sync
|
||||||
|
|||||||
@@ -4,22 +4,90 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.home.roles.development;
|
cfg = config.home.roles.development;
|
||||||
|
|
||||||
|
# Fetch the claude-plugins repository
|
||||||
|
# Update the rev to get newer versions of the commands
|
||||||
|
claudePluginsRepo = builtins.fetchGit {
|
||||||
|
url = "https://github.com/jeffh/claude-plugins.git";
|
||||||
|
# To update: change this to the latest commit hash
|
||||||
|
# You can find the latest commit at: https://github.com/jeffh/claude-plugins/commits/main
|
||||||
|
rev = "5e3e4d937162185b6d78c62022cbfd1c8ad42c4c";
|
||||||
|
ref = "main";
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.home.roles.development = {
|
options.home.roles.development = {
|
||||||
enable = mkEnableOption "Enable development tools and utilities";
|
enable = mkEnableOption "Enable development tools and utilities";
|
||||||
|
|
||||||
|
allowArbitraryClaudeCodeModelSelection = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to preserve model specifications in Claude Code humanlayer commands and agents.
|
||||||
|
|
||||||
|
When false (default), the model: line is stripped from frontmatter, allowing Claude Code
|
||||||
|
to use its default model selection.
|
||||||
|
|
||||||
|
When true, the model: specifications from the source files are preserved, allowing
|
||||||
|
commands to specify opus/sonnet/haiku explicitly.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
pkgs.unstable.claude-code
|
pkgs.unstable.claude-code-router
|
||||||
pkgs.codex
|
pkgs.unstable.codex
|
||||||
|
|
||||||
# Custom packages
|
# Custom packages
|
||||||
pkgs.custom.tea-rbw
|
pkgs.custom.tea-rbw
|
||||||
|
pkgs.custom.claude-cli
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.kubectl-secure.enable = true;
|
# Install Claude Code humanlayer command and agent plugins
|
||||||
|
home.activation.claudeCodeCommands = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
|
# Clean up old plugin-installed commands and agents to avoid duplicates
|
||||||
|
rm -f ~/.claude/commands/humanlayer:* 2>/dev/null || true
|
||||||
|
rm -f ~/.claude/agents/humanlayer:* 2>/dev/null || true
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
mkdir -p ~/.claude/commands
|
||||||
|
mkdir -p ~/.claude/agents
|
||||||
|
|
||||||
|
# Copy all humanlayer command files and remove model specifications
|
||||||
|
for file in ${claudePluginsRepo}/humanlayer/commands/*.md; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
filename=$(basename "$file" .md)
|
||||||
|
dest="$HOME/.claude/commands/humanlayer:''${filename}.md"
|
||||||
|
|
||||||
|
# Copy file and conditionally remove the "model:" line from frontmatter
|
||||||
|
${if cfg.allowArbitraryClaudeCodeModelSelection
|
||||||
|
then "cp \"$file\" \"$dest\""
|
||||||
|
else "${pkgs.gnused}/bin/sed '/^model:/d' \"$file\" > \"$dest\""
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Copy all humanlayer agent files and remove model specifications
|
||||||
|
for file in ${claudePluginsRepo}/humanlayer/agents/*.md; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
filename=$(basename "$file" .md)
|
||||||
|
dest="$HOME/.claude/agents/humanlayer:''${filename}.md"
|
||||||
|
|
||||||
|
# Copy file and conditionally remove the "model:" line from frontmatter
|
||||||
|
${if cfg.allowArbitraryClaudeCodeModelSelection
|
||||||
|
then "cp \"$file\" \"$dest\""
|
||||||
|
else "${pkgs.gnused}/bin/sed '/^model:/d' \"$file\" > \"$dest\""
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
$DRY_RUN_CMD echo "Claude Code humanlayer commands and agents installed successfully${
|
||||||
|
if cfg.allowArbitraryClaudeCodeModelSelection
|
||||||
|
then " (model specifications preserved)"
|
||||||
|
else " (model selection removed)"
|
||||||
|
}"
|
||||||
|
'';
|
||||||
|
|
||||||
# Note: modules must be imported at top-level home config
|
# Note: modules must be imported at top-level home config
|
||||||
};
|
};
|
||||||
|
|||||||
16
home/roles/kubectl/default.nix
Normal file
16
home/roles/kubectl/default.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ config, lib, pkgs, globalInputs, system, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.home.roles.kubectl;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.home.roles.kubectl = {
|
||||||
|
enable = mkEnableOption "Enable management tools for the homelab k3s oglenet cluster";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
programs.kubectl-secure.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
116
packages/claude-cli/README.md
Normal file
116
packages/claude-cli/README.md
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# claude-cli
|
||||||
|
|
||||||
|
Custom Nix package for Claude Code CLI.
|
||||||
|
|
||||||
|
## Why This Package Exists
|
||||||
|
|
||||||
|
The official `claude-code` package in nixpkgs tries to fetch from npm registry, which is blocked by Block's corporate security (Cloudflare Teams dependency confusion protection). This custom package fetches directly from Anthropic's Google Cloud Storage distribution, bypassing the npm registry entirely.
|
||||||
|
|
||||||
|
## Updating to a New Version
|
||||||
|
|
||||||
|
### Automated Update (Recommended)
|
||||||
|
|
||||||
|
Run the update script to automatically fetch and update to the latest version:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd packages/claude-cli
|
||||||
|
./update.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The script will:
|
||||||
|
- Fetch the latest version from Homebrew cask
|
||||||
|
- Update version and all SHA256 hashes in default.nix
|
||||||
|
- Show you what changed
|
||||||
|
|
||||||
|
For a dry-run to see what would change:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./update.sh --dry-run
|
||||||
|
```
|
||||||
|
|
||||||
|
After the script completes, follow the "Test the Build" steps below.
|
||||||
|
|
||||||
|
### Manual Update
|
||||||
|
|
||||||
|
If you prefer to update manually, or if the automated script fails:
|
||||||
|
|
||||||
|
#### 1. Find the Latest Version and Hashes
|
||||||
|
|
||||||
|
Check the Homebrew cask formula for the latest version info:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s "https://raw.githubusercontent.com/Homebrew/homebrew-cask/HEAD/Casks/c/claude-code.rb" | head -50
|
||||||
|
```
|
||||||
|
|
||||||
|
This will show:
|
||||||
|
- The latest `version` number
|
||||||
|
- SHA256 hashes for all platforms (`arm64`, `x86_64`, `x86_64_linux`, `arm64_linux`)
|
||||||
|
|
||||||
|
#### 2. Update default.nix
|
||||||
|
|
||||||
|
Edit `default.nix` and update:
|
||||||
|
|
||||||
|
1. The `version` variable (line 9):
|
||||||
|
```nix
|
||||||
|
version = "2.0.51"; # Update this
|
||||||
|
```
|
||||||
|
|
||||||
|
2. All four platform sha256 hashes in the `srcs` attribute set (lines 11-27):
|
||||||
|
```nix
|
||||||
|
aarch64-darwin = {
|
||||||
|
sha256 = "..."; # Update from Homebrew cask "arm:" value
|
||||||
|
};
|
||||||
|
x86_64-darwin = {
|
||||||
|
sha256 = "..."; # Update from Homebrew cask "x86_64:" value
|
||||||
|
};
|
||||||
|
x86_64-linux = {
|
||||||
|
sha256 = "..."; # Update from Homebrew cask "x86_64_linux:" value
|
||||||
|
};
|
||||||
|
aarch64-linux = {
|
||||||
|
sha256 = "..."; # Update from Homebrew cask "arm64_linux:" value
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Test the Build
|
||||||
|
|
||||||
|
Before committing, test that the package builds successfully:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NIXPKGS_ALLOW_UNFREE=1 nix-build -E 'with import <nixpkgs> { config.allowUnfree = true; }; callPackage ./packages/claude-cli {}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify the version:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./result/bin/claude --version
|
||||||
|
```
|
||||||
|
|
||||||
|
Clean up the test build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm result
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. Deploy
|
||||||
|
|
||||||
|
Commit your changes and rebuild:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add packages/claude-cli/
|
||||||
|
git commit -m "claude-cli: Update to version X.Y.Z"
|
||||||
|
darwin-rebuild switch --flake .#blkfv4yf49kt7
|
||||||
|
```
|
||||||
|
|
||||||
|
## Alternative: Automated Hash Fetching
|
||||||
|
|
||||||
|
If you prefer to fetch hashes automatically, you can use `nix-prefetch-url`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For macOS ARM64 (your current platform)
|
||||||
|
nix-prefetch-url "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/VERSION/darwin-arm64/claude"
|
||||||
|
|
||||||
|
# For other platforms, replace VERSION and adjust the platform string:
|
||||||
|
# darwin-x64, linux-x64, linux-arm64
|
||||||
|
```
|
||||||
|
|
||||||
|
This will download the file and output the SHA256 hash.
|
||||||
61
packages/claude-cli/default.nix
Normal file
61
packages/claude-cli/default.nix
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, fetchurl
|
||||||
|
, autoPatchelfHook
|
||||||
|
, makeWrapper
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
version = "2.0.53";
|
||||||
|
|
||||||
|
srcs = {
|
||||||
|
aarch64-darwin = {
|
||||||
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-arm64/claude";
|
||||||
|
sha256 = "28c3ad73a20f3ae7ab23efa24d45a9791ccbe071284f1622d4e5e2b89c4a15b7";
|
||||||
|
};
|
||||||
|
x86_64-darwin = {
|
||||||
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-x64/claude";
|
||||||
|
sha256 = "a27f7b75a51514658640432a0afec8be130673eb7dbecc9a4d742527dd85d29a";
|
||||||
|
};
|
||||||
|
x86_64-linux = {
|
||||||
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-x64/claude";
|
||||||
|
sha256 = "9c4cc19e207fb6bf7ea140a1580d5ed0dd0a481af471f23614d5a140a4abf1c6";
|
||||||
|
};
|
||||||
|
aarch64-linux = {
|
||||||
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-arm64/claude";
|
||||||
|
sha256 = "a5d4044034f3b63c38379bc2dd4067a4dd3c8ec48965ba8e66e3623774a93b72";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||||
|
|
||||||
|
in stdenv.mkDerivation {
|
||||||
|
pname = "claude-cli";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetchurl {
|
||||||
|
inherit (src) url sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
dontUnpack = true;
|
||||||
|
dontBuild = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
install -Dm755 $src $out/bin/claude
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Terminal-based AI coding assistant from Anthropic";
|
||||||
|
homepage = "https://www.anthropic.com/claude-code";
|
||||||
|
license = licenses.unfree;
|
||||||
|
maintainers = [ ];
|
||||||
|
platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
|
||||||
|
mainProgram = "claude";
|
||||||
|
};
|
||||||
|
}
|
||||||
132
packages/claude-cli/update.sh
Executable file
132
packages/claude-cli/update.sh
Executable file
@@ -0,0 +1,132 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DRY_RUN=false
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--dry-run|-n)
|
||||||
|
DRY_RUN=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--help|-h)
|
||||||
|
echo "Usage: $0 [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --dry-run, -n Show what would be updated without making changes"
|
||||||
|
echo " --help, -h Show this help message"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option: $1"
|
||||||
|
echo "Use --help for usage information"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
CASK_URL="https://raw.githubusercontent.com/Homebrew/homebrew-cask/HEAD/Casks/c/claude-code.rb"
|
||||||
|
NIX_FILE="$(dirname "$0")/default.nix"
|
||||||
|
|
||||||
|
echo "Fetching latest claude-code version from Homebrew cask..."
|
||||||
|
|
||||||
|
# Fetch the cask file
|
||||||
|
CASK_CONTENT=$(curl -fsSL "$CASK_URL")
|
||||||
|
|
||||||
|
# Extract version (format: version "X.Y.Z")
|
||||||
|
NEW_VERSION=$(echo "$CASK_CONTENT" | grep -m1 'version' | sed -E 's/.*version "([^"]+)".*/\1/')
|
||||||
|
|
||||||
|
# Extract SHA256 hashes (be specific to match sha256 lines only)
|
||||||
|
SHA_ARM=$(echo "$CASK_CONTENT" | grep 'sha256 arm:' | sed -E 's/.*"([a-f0-9]{64})".*/\1/')
|
||||||
|
SHA_X86_64=$(echo "$CASK_CONTENT" | grep 'x86_64:' | sed -E 's/.*"([a-f0-9]{64})".*/\1/')
|
||||||
|
SHA_X86_64_LINUX=$(echo "$CASK_CONTENT" | grep 'x86_64_linux:' | sed -E 's/.*"([a-f0-9]{64})".*/\1/')
|
||||||
|
SHA_ARM64_LINUX=$(echo "$CASK_CONTENT" | grep 'arm64_linux:' | sed -E 's/.*"([a-f0-9]{64})".*/\1/')
|
||||||
|
|
||||||
|
# Get current version
|
||||||
|
CURRENT_VERSION=$(grep -m1 'version = ' "$NIX_FILE" | sed -E 's/.*version = "([^"]+)".*/\1/')
|
||||||
|
|
||||||
|
# Validate extracted data
|
||||||
|
if [ -z "$NEW_VERSION" ] || [ -z "$SHA_ARM" ] || [ -z "$SHA_X86_64" ] || [ -z "$SHA_X86_64_LINUX" ] || [ -z "$SHA_ARM64_LINUX" ]; then
|
||||||
|
echo -e "${RED}Error: Failed to extract all required values from Homebrew cask${NC}"
|
||||||
|
echo "Version: $NEW_VERSION"
|
||||||
|
echo "ARM: $SHA_ARM"
|
||||||
|
echo "x86_64: $SHA_X86_64"
|
||||||
|
echo "x86_64_linux: $SHA_X86_64_LINUX"
|
||||||
|
echo "arm64_linux: $SHA_ARM64_LINUX"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if update is needed
|
||||||
|
if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then
|
||||||
|
echo -e "${GREEN}Already up to date: $CURRENT_VERSION${NC}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}Updating from $CURRENT_VERSION to $NEW_VERSION${NC}"
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" = true ]; then
|
||||||
|
echo -e "${YELLOW}DRY RUN - No changes will be made${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Would update:"
|
||||||
|
echo " Version: $CURRENT_VERSION -> $NEW_VERSION"
|
||||||
|
echo " aarch64-darwin SHA: $SHA_ARM"
|
||||||
|
echo " x86_64-darwin SHA: $SHA_X86_64"
|
||||||
|
echo " x86_64-linux SHA: $SHA_X86_64_LINUX"
|
||||||
|
echo " aarch64-linux SHA: $SHA_ARM64_LINUX"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update version
|
||||||
|
sed -i.tmp "s/version = \".*\";/version = \"$NEW_VERSION\";/" "$NIX_FILE"
|
||||||
|
|
||||||
|
# Update SHA256 hashes using awk for more reliable parsing
|
||||||
|
awk -v sha_arm="$SHA_ARM" -v sha_x86="$SHA_X86_64" -v sha_x86_linux="$SHA_X86_64_LINUX" -v sha_arm_linux="$SHA_ARM64_LINUX" '
|
||||||
|
/aarch64-darwin = {/ { in_arm = 1 }
|
||||||
|
/x86_64-darwin = {/ { in_x86 = 1 }
|
||||||
|
/x86_64-linux = {/ { in_x86_linux = 1 }
|
||||||
|
/aarch64-linux = {/ { in_arm_linux = 1 }
|
||||||
|
/};/ {
|
||||||
|
in_arm = 0
|
||||||
|
in_x86 = 0
|
||||||
|
in_x86_linux = 0
|
||||||
|
in_arm_linux = 0
|
||||||
|
}
|
||||||
|
/sha256 = / {
|
||||||
|
if (in_arm) {
|
||||||
|
sub(/sha256 = ".*";/, "sha256 = \"" sha_arm "\";")
|
||||||
|
} else if (in_x86) {
|
||||||
|
sub(/sha256 = ".*";/, "sha256 = \"" sha_x86 "\";")
|
||||||
|
} else if (in_x86_linux) {
|
||||||
|
sub(/sha256 = ".*";/, "sha256 = \"" sha_x86_linux "\";")
|
||||||
|
} else if (in_arm_linux) {
|
||||||
|
sub(/sha256 = ".*";/, "sha256 = \"" sha_arm_linux "\";")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
' "$NIX_FILE" > "$NIX_FILE.new"
|
||||||
|
|
||||||
|
mv "$NIX_FILE.new" "$NIX_FILE"
|
||||||
|
|
||||||
|
# Clean up temp files
|
||||||
|
rm -f "$NIX_FILE.tmp"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Successfully updated to version $NEW_VERSION${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Updated SHA256 hashes:"
|
||||||
|
echo " aarch64-darwin: $SHA_ARM"
|
||||||
|
echo " x86_64-darwin: $SHA_X86_64"
|
||||||
|
echo " x86_64-linux: $SHA_X86_64_LINUX"
|
||||||
|
echo " aarch64-linux: $SHA_ARM64_LINUX"
|
||||||
|
echo ""
|
||||||
|
echo "Next steps:"
|
||||||
|
echo " 1. Review changes: git diff $NIX_FILE"
|
||||||
|
echo " 2. Test build: NIXPKGS_ALLOW_UNFREE=1 nix-build -E 'with import <nixpkgs> { config.allowUnfree = true; }; callPackage ./packages/claude-cli {}'"
|
||||||
|
echo " 3. Verify version: ./result/bin/claude --version"
|
||||||
|
echo " 4. Commit: git add $NIX_FILE && git commit -m 'claude-cli: Update to version $NEW_VERSION'"
|
||||||
@@ -3,4 +3,5 @@
|
|||||||
vulkanHDRLayer = pkgs.callPackage ./vulkan-hdr-layer {};
|
vulkanHDRLayer = pkgs.callPackage ./vulkan-hdr-layer {};
|
||||||
tea-rbw = pkgs.callPackage ./tea-rbw {};
|
tea-rbw = pkgs.callPackage ./tea-rbw {};
|
||||||
app-launcher-server = pkgs.callPackage ./app-launcher-server {};
|
app-launcher-server = pkgs.callPackage ./app-launcher-server {};
|
||||||
|
claude-cli = pkgs.callPackage ./claude-cli {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user