Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
65 lines (61 loc) · 2.26 KB
/
Copy pathflake.nix
File metadata and controls
65 lines (61 loc) · 2.26 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
{
description = "laya + laya-serve: a self-hosted, TypeSafe Jev-compatible System-1 decision server";
inputs = {
# Pinned to the same rev missionctrl-infra uses, so hq's binary cache
# (cache.nixos.org + missionctrl.cachix.org) hits instead of rebuilding torch.
nixpkgs.url = "github:NixOS/nixpkgs/ccad53cd79cf4cf3bc338805d007d68565e75bda";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
# Overlay exposing `laya` + `laya-serve`, built from ./nix/package.nix.
overlay = final: prev:
let p = final.callPackage ./nix/package.nix { };
in { inherit (p) laya laya-serve; };
in
{
overlays.default = overlay;
# The module builds its package from the host's own `pkgs` (see
# nix/laya-serve.nix), so it works even on hosts that inject `pkgs` via
# specialArgs and ignore module-level `nixpkgs.overlays` — no overlay
# required here.
nixosModules.default = ./nix/laya-serve.nix;
nixosModules.laya-serve = ./nix/laya-serve.nix;
}
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true; # torch-bin bundles CUDA (unfree)
overlays = [ overlay ];
};
in
{
packages = {
default = pkgs.laya-serve;
laya-serve = pkgs.laya-serve;
laya = pkgs.laya;
};
devShells.default = pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (ps: [
ps.torch-bin
ps.transformers
ps.safetensors
ps.huggingface-hub
ps.numpy
ps.fastapi
ps.uvicorn
ps.pytest
ps.httpx # fastapi TestClient
]))
];
shellHook = ''
export PYTHONPATH="$PWD:$PYTHONPATH"
# torch-bin's CUDA needs the host NVIDIA userspace driver.
export LD_LIBRARY_PATH="/run/opengl-driver/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
echo "laya dev shell — python $(python --version 2>&1 | cut -d' ' -f2), torch $(python -c 'import torch; print(torch.__version__)' 2>/dev/null)"
'';
};
});
}