From 26c8423a476cc8b23f08798949ba3dd702036419 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 10 Dec 2025 14:28:58 +0700 Subject: [PATCH] fix: ai notebook sentencepipe incompatibility with apple devices --- flake.lock | 72 ++++++++++++------------ flake.nix | 1 + shells/ai-notebook.nix | 3 +- shells/effect-ts.nix | 122 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 38 deletions(-) create mode 100644 shells/effect-ts.nix diff --git a/flake.lock b/flake.lock index 232408f..4509e61 100644 --- a/flake.lock +++ b/flake.lock @@ -52,11 +52,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1764596563, - "narHash": "sha256-tH3AGDWlAN3ImVuBBCLmqaqD0EbkISiPCHGeMcd430k=", + "lastModified": 1765204341, + "narHash": "sha256-7xd45skcuLCu2DHxVvU+W/z+7CUOjyv+QPtT4PLZaIU=", "owner": "chaotic-cx", "repo": "nyx", - "rev": "0701ee838b0fb34a77b6dd4b35476b4bb09fbca9", + "rev": "aacb796ccd42be1555196c20013b9b674b71df75", "type": "github" }, "original": { @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1764161084, - "narHash": "sha256-HN84sByg9FhJnojkGGDSrcjcbeioFWoNXfuyYfJ1kBE=", + "lastModified": 1765065051, + "narHash": "sha256-b7W9WsvyMOkUScNxbzS45KEJp0iiqRPyJ1I3JBE+oEE=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "e95de00a471d07435e0527ff4db092c84998698e", + "rev": "7e22bf538aa3e0937effcb1cee73d5f1bcc26f79", "type": "github" }, "original": { @@ -181,11 +181,11 @@ "zon2nix": "zon2nix" }, "locked": { - "lastModified": 1764605702, - "narHash": "sha256-ZGIKHORnvJ+6ghU/KjtXTesbRB4S75KwwAat7UFMpXU=", + "lastModified": 1765256324, + "narHash": "sha256-LB4FO4xP9XlmaxEzruiW88S2n6SEYqALdzKE3oybGkI=", "owner": "ghostty-org", "repo": "ghostty", - "rev": "5714ed07a1012573261b7b7e3ed2add9c1504496", + "rev": "cf06417b7dfbd0daeb58a9143f9b6ee194cbce26", "type": "github" }, "original": { @@ -202,11 +202,11 @@ ] }, "locked": { - "lastModified": 1764194569, - "narHash": "sha256-iUM9ktarEzThkayyZrzQ7oycPshAY2XRQqVKz0xX/L0=", + "lastModified": 1764998300, + "narHash": "sha256-fZatn/KLfHLDXnF0wy7JxXqGaZmGDTVufT4o/AOlj44=", "owner": "nix-community", "repo": "home-manager", - "rev": "9651819d75f6c7ffaf8a9227490ac704f29659f0", + "rev": "27a6182347ccae90a88231ae0dc5dfa7d15815bb", "type": "github" }, "original": { @@ -222,11 +222,11 @@ ] }, "locked": { - "lastModified": 1764636297, - "narHash": "sha256-S41K55kw+hWgDfgKmZ9/fMZ3F0BQDMvqFfE120fMHeE=", + "lastModified": 1765337252, + "narHash": "sha256-HuWQp8fM25fyWflbuunQkQI62Hg0ecJxWD52FAgmxqY=", "owner": "nix-community", "repo": "home-manager", - "rev": "ff067cfc619fdf6f82d50344e7d19ff2323f0827", + "rev": "13cc1efd78b943b98c08d74c9060a5b59bf86921", "type": "github" }, "original": { @@ -244,11 +244,11 @@ ] }, "locked": { - "lastModified": 1764275117, - "narHash": "sha256-DRcv8Y0BnWm4ZhUQnaYk1dNzC6ZhA2W9Vv5Jl4n0RbE=", + "lastModified": 1764922999, + "narHash": "sha256-LSvUxKm6S6ZAd/otQSkAHd3+8KJhi8OwGJGSe0K//B8=", "owner": "Jovian-Experiments", "repo": "Jovian-NixOS", - "rev": "96023dcc9a0febaaa3b91f447b9ae2fbe86f2923", + "rev": "9b9ead1b5591b68f4048e7205ba1397bc85ce6c4", "type": "github" }, "original": { @@ -266,11 +266,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1764643925, - "narHash": "sha256-GLvOrqcAURAbLapyTLk9CHf30YXyllwMbouErByho0I=", + "lastModified": 1765336700, + "narHash": "sha256-xeqAm4VadgpfvyTBnIqoDTDcfLg0pEB0IOI8wCVr6gQ=", "owner": "numtide", "repo": "nix-ai-tools", - "rev": "56de5ea7034968434a3a56f027ea6bacc19a4978", + "rev": "6d53cb0335d2e3c39b8ec4f3d5808930679f2ae0", "type": "github" }, "original": { @@ -304,11 +304,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1764517877, - "narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=", + "lastModified": 1764950072, + "narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c", + "rev": "f61125a668a320878494449750330ca58b78c557", "type": "github" }, "original": { @@ -348,11 +348,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1764517877, - "narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=", + "lastModified": 1765186076, + "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c", + "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", "type": "github" }, "original": { @@ -383,11 +383,11 @@ ] }, "locked": { - "lastModified": 1764211126, - "narHash": "sha256-p5y13PnMZYd5WdHk+XCzyUaLGBUCwnz2n4KYKEZM0Pw=", + "lastModified": 1765075567, + "narHash": "sha256-KFDCdQcHJ0hE3Nt5Gm5enRIhmtEifAjpxgUQ3mzSJpA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "895935bff08cfcfb663fb9c8263c43596e7cd1ed", + "rev": "769156779b41e8787a46ca3d7d76443aaf68be6f", "type": "github" }, "original": { @@ -403,11 +403,11 @@ ] }, "locked": { - "lastModified": 1764483358, - "narHash": "sha256-EyyvCzXoHrbL467YSsQBTWWg4sR96MH1sPpKoSOelB4=", + "lastModified": 1765231718, + "narHash": "sha256-qdBzo6puTgG4G2RHG0PkADg22ZnQo1JmSVFRxrD4QM4=", "owner": "Mic92", "repo": "sops-nix", - "rev": "5aca6ff67264321d47856a2ed183729271107c9c", + "rev": "7fd1416aba1865eddcdec5bb11339b7222c2363e", "type": "github" }, "original": { @@ -490,11 +490,11 @@ ] }, "locked": { - "lastModified": 1764893252, - "narHash": "sha256-Ua2TYmHHsJCCse6Oo6jT7ZD7Ko73dd7a70PRqqhTd6w=", + "lastModified": 1765037997, + "narHash": "sha256-OULPSaxqO2HmUT+6Eprnf9A5nLrJ8WwGP1L/gqANsf4=", "owner": "tobi", "repo": "try", - "rev": "9babc916eb199148c5949e7e8dee318a3f3a4770", + "rev": "08f70fa34761e308acc0546b723d038e41aa0fee", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e158e16..696851f 100644 --- a/flake.nix +++ b/flake.nix @@ -147,6 +147,7 @@ web-bun = importShell "web-bun"; rust = importShell "rust"; ai-agent = importShell "ai-agent"; + effect-ts = importShell "effect-ts"; }); formatter = forEachSystem (system: (mkPkgs system).nixfmt-classic); diff --git a/shells/ai-notebook.nix b/shells/ai-notebook.nix index 5da154c..ddac3a4 100644 --- a/shells/ai-notebook.nix +++ b/shells/ai-notebook.nix @@ -22,12 +22,11 @@ let scikit-image scikit-learn seaborn - sentencepiece tokenizers transformers ]; linuxOnlyPackages = lib.optionals pkgs.stdenv.isLinux - (with ps; [ torch torchaudio torchvision ]); + (with ps; [ sentencepiece torch torchaudio torchvision ]); in basePackages ++ linuxOnlyPackages); in pkgs.mkShell { name = "ai-notebook"; diff --git a/shells/effect-ts.nix b/shells/effect-ts.nix new file mode 100644 index 0000000..ad71996 --- /dev/null +++ b/shells/effect-ts.nix @@ -0,0 +1,122 @@ +{ pkgs, ... }: + +let + effectInit = pkgs.writeShellScriptBin "effect-init" '' + set -e + + PROJECT_NAME="''${1:-.}" + + if [ "$PROJECT_NAME" != "." ]; then + mkdir -p "$PROJECT_NAME" + cd "$PROJECT_NAME" + echo "Creating Effect project in $PROJECT_NAME..." + else + PROJECT_NAME=$(basename "$PWD") + echo "Initializing Effect project in current directory..." + fi + + # Generate package.json + cat > package.json << 'PACKAGE_EOF' + { + "name": "PROJECT_NAME_PLACEHOLDER", + "type": "module", + "scripts": { + "typecheck": "tsc --noEmit", + "lint": "biome check .", + "format": "biome format --write .", + "es": "effect-solutions" + }, + "dependencies": { + "effect": "latest" + }, + "devDependencies": { + "@effect/language-service": "latest", + "effect-solutions": "latest", + "typescript": "latest" + } + } + PACKAGE_EOF + + # Replace placeholder with actual project name + ${pkgs.gnused}/bin/sed -i "s/PROJECT_NAME_PLACEHOLDER/$PROJECT_NAME/" package.json + + # Generate tsconfig.json + cat > tsconfig.json << 'TSCONFIG_EOF' + { + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "exactOptionalPropertyTypes": true, + "noUncheckedIndexedAccess": true, + "noEmit": true, + "skipLibCheck": true, + "plugins": [{ "name": "@effect/language-service" }] + }, + "include": ["src/**/*"] + } + TSCONFIG_EOF + + # Generate biome.json + cat > biome.json << 'BIOME_EOF' + { + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "organizeImports": { "enabled": true }, + "linter": { "enabled": true }, + "formatter": { "enabled": true, "indentStyle": "space", "indentWidth": 2 } + } + BIOME_EOF + + # Create src directory with starter file + mkdir -p src + cat > src/index.ts << 'SRC_EOF' + import { Effect, Console } from "effect" + + const program = Console.log("Hello, Effect!") + + Effect.runPromise(program) + SRC_EOF + + # Install dependencies + echo "" + echo "Installing dependencies..." + ${pkgs.bun}/bin/bun install + + echo "" + echo "Effect project initialized successfully!" + echo "" + echo "Next steps:" + echo " bun run src/index.ts - Run the starter program" + echo " bun typecheck - Check types" + echo " bun lint - Lint code" + echo " bun es list - Browse Effect patterns" + ''; + +in pkgs.mkShell { + name = "effect-ts"; + packages = with pkgs; [ + bun + typescript + biome + vscode-langservers-extracted + effectInit + ]; + shellHook = '' + mkdir -p "$PWD/.cache/bun" + export BUN_INSTALL_CACHE="$PWD/.cache/bun" + + es() { ${pkgs.bun}/bin/bunx effect-solutions "$@"; } + export -f es + + echo "Effect TypeScript shell ready" + echo " Bun: ${pkgs.bun.version} | TypeScript: ${pkgs.typescript.version} | Biome: ${pkgs.biome.version}" + echo "" + echo "Commands:" + echo " effect-init [name] - Scaffold new Effect project" + echo " es - Run effect-solutions CLI (via bunx)" + echo " bun typecheck - Run TypeScript type checking" + echo " bun lint - Run Biome linter" + echo " bun format - Format code with Biome" + ''; +}