-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
59 lines (47 loc) · 1.93 KB
/
flake.nix
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
{
# A short description for this flake
description = "A simple CLI for Anthropic's API";
# The key inputs we will need to build this
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
# This outputs section defines the things we are building.
# To do its work, it needs to know about this flake and its inputs
outputs = { self, nixpkgs, flake-utils }:
# This utility helps us iterate through each of our supported systems
flake-utils.lib.eachDefaultSystem(system:
let
# Let's grab Python 3.12 from Nixpkgs
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python312;
# Define the Python packages we need here, and look for them
# within the package group we defined above
python_packages = python.withPackages( ps: with ps; [
click
anthropic
]);
# Use the simplest builder, mkDerivation, to create our output
# (and call it 'claude'
claude = with pkgs; stdenv.mkDerivation {
# These are important and we all know why
pname = "claude";
version = "0.0.1";
# Make sure we bring those Python packages we defined above
propagatedBuildInputs = [ python_packages ];
# Perhaps this means that our source isn't an archive that needs
# to be extracted?
dontUnpack = true;
# Run this command to install our script into the bin/ dir
# of our output
installPhase = "install -Dm755 ${./claude.py} $out/bin/claude";
};
in rec {
# Dev shells need our Python packages too
devShells.default = pkgs.mkShell {
inputsFrom = [ claude ];
};
# The main thing inside this flake is the output we called
# 'claude' and if the flake is run this will be what is run
packages.default = claude;
}
);
}