-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
89 lines (78 loc) · 2.97 KB
/
Copy pathflake.nix
File metadata and controls
89 lines (78 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
description = "Superclaude — sandboxed Claude Code for Bun/TypeScript development";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
llm-agents.url = "github:numtide/llm-agents.nix";
};
outputs = { self, nixpkgs, flake-utils, llm-agents, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = {
# The init script as a Nix package
superclaude-init = pkgs.writeShellApplication {
name = "superclaude";
runtimeInputs = with pkgs; [ coreutils gnused git ];
text = ''
TEMPLATE_DIR="${./templates/minimal}"
'' + builtins.readFile ./lib/init.sh;
};
# Re-export claude-code for convenience
claude-code = llm-agents.packages.${system}.claude-code;
};
# `nix run github:laged/superclaude -- init my-project`
apps.default = {
type = "app";
program = "${self.packages.${system}.superclaude-init}/bin/superclaude";
};
# `nix run github:laged/superclaude#new-with-env -- my-project`
# Creates a project and opens Ghostty with the dev environment
apps.new-with-env = {
type = "app";
program = toString (pkgs.writeShellScript "superclaude-new-with-env" ''
set -euo pipefail
if [ -z "''${1:-}" ]; then
echo "Usage: nix run github:laged/superclaude#new-with-env -- <project-name>"
exit 1
fi
project_name="$1"
# Create the project
${self.packages.${system}.superclaude-init}/bin/superclaude init "$project_name"
project_dir="$PWD/$project_name"
# Find Ghostty
${if pkgs.stdenv.hostPlatform.isDarwin then ''
if [ -x "/Applications/Ghostty.app/Contents/MacOS/ghostty" ]; then
ghostty_bin="/Applications/Ghostty.app/Contents/MacOS/ghostty"
elif command -v ghostty &>/dev/null; then
ghostty_bin=ghostty
else
echo ""
echo "Ghostty not found. Enter the dev shell manually:"
echo " cd $project_name && direnv allow"
exit 0
fi
'' else ''
ghostty_bin=${pkgs.ghostty}/bin/ghostty
''}
# Launch Ghostty with the dev environment
exec "$ghostty_bin" -e nix develop "$project_dir" --impure --command zsh
'');
};
}
) // {
# Flake templates
templates = {
default = {
path = ./templates/minimal;
description = "Minimal Bun/TypeScript project with sandboxed Claude Code";
};
minimal = {
path = ./templates/minimal;
description = "Minimal Bun/TypeScript project with sandboxed Claude Code";
};
};
};
}