-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
75 lines (67 loc) · 1.98 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
description = "A Python development environment with poetry";
inputs = {
nixpkgs.url = "nixpkgs";
easy-sync.url = "github:luochen1990/easy-sync/master";
easy-sync.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, easy-sync }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
eachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
inherit system;
pkgs = import nixpkgs { inherit system; };
python = pkgs.python3; # use pkgs.python3.withPackages (p: []) if you need more python packages in nixpkgs
});
in
{
packages = eachSystem ({pkgs, system, ...}: rec {
default = ai-powered;
ai-powered = let
pyproject = pkgs.lib.importTOML ./pyproject.toml;
meta = pyproject.tool.poetry;
pypkgs = pkgs.python3Packages;
in
pypkgs.buildPythonPackage {
pname = meta.name;
version = meta.version;
pyproject = true;
src = ./.;
buildInputs = [ pypkgs.poetry-core ];
dependencies = [
easy-sync.packages.${system}.easy-sync
pypkgs.msgspec
pypkgs.openai
];
doCheck = true;
meta = with pkgs.lib; {
description = meta.description;
homepage = meta.repository;
license = licenses.asl20;
maintainers = with maintainers; [ luochen1990 ];
};
};
});
devShells = eachSystem ({pkgs, python, ...}: rec {
default = poetry;
poetry = pkgs.mkShell {
buildInputs = [
python
pkgs.poetry
];
shellHook = ''
export PATH=$(poetry env info --path)/bin:$PATH
'';
};
});
apps = eachSystem ({system, pkgs, ...}: {
default = {
type = "app";
program = "${pkgs.writeShellScript "funix-app" ''
source ${self.devShells.${system}.default.shellHook}
funix .
''}";
};
});
};
}