Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
130 lines (110 loc) · 4.6 KB
/
Copy pathflake.nix
File metadata and controls
130 lines (110 loc) · 4.6 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{
description = "Secure, kernel-enforced sandbox for AI agents, MCP and LLM workloads";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Pin x86_64-darwin to a stable release branch for older macOS Intel
# compatibility. The project requires Rust 1.95 (edition2024), which
# nixpkgs-unstable does not reliably ship for x86_64-darwin.
nixpkgs-darwin-legacy.url = "github:NixOS/nixpkgs/nixpkgs-26.05-darwin";
};
outputs = { self, nixpkgs, nixpkgs-darwin-legacy, ... }:
let
# Read version from Cargo.toml so it never needs manual syncing
cargoToml = builtins.fromTOML (builtins.readFile ./crates/nono-cli/Cargo.toml);
version = cargoToml.package.version;
allSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs allSystems f;
pkgsFor = system:
if system == "x86_64-darwin"
then nixpkgs-darwin-legacy.legacyPackages.${system}
else nixpkgs.legacyPackages.${system};
nonoFor = system: let pkgs = pkgsFor system; in pkgs.rustPlatform.buildRustPackage {
pname = "nono";
inherit version;
src = self;
cargoLock.lockFile = "${self}/Cargo.lock";
nativeBuildInputs = [ pkgs.pkg-config ];
# Tests require /bin/pwd, /usr/bin/env, git, /var/folders, network, etc.
# and fail in the Nix sandbox. The project's own CI covers testing.
doCheck = false;
meta = with pkgs.lib; {
description = "Secure, kernel-enforced sandbox for AI agents, MCP and LLM workloads";
homepage = "https://github.com/nolabs-ai/nono";
license = licenses.asl20;
mainProgram = "nono";
platforms = allSystems;
};
};
# Map Nix system triples to the release tarball target strings.
releaseTarget = system: {
"x86_64-linux" = "x86_64-unknown-linux-gnu";
"aarch64-linux" = "aarch64-unknown-linux-gnu";
"x86_64-darwin" = "x86_64-apple-darwin";
"aarch64-darwin" = "aarch64-apple-darwin";
}.${system};
# Per-platform SHA-256 hashes for the release tarballs.
# Auto-updated by the `update-nix-hashes` job in release.yml
# after each release — no manual maintenance needed.
prebuiltHashes = {
"x86_64-linux" = "sha256-gdelYWYi3PaMoO0rfms68IwSFvsMQtxtfs+9K78tP1A=";
"aarch64-linux" = "sha256-3ha2Y/GUG0/4UA91800QpJfvHRk0KBVziI+56AjatT4=";
"x86_64-darwin" = "sha256-47/ti1635jMv/J/F6I73IzjqepvIp/BwBHmqs5W89jU=";
"aarch64-darwin" = "sha256-oRdgsdXpRxUtH9xkl7KrouQYUGGlY5Cy8RN8g87ztaQ=";
};
prebuiltFor = system: let pkgs = pkgsFor system; in pkgs.stdenv.mkDerivation {
pname = "nono-prebuilt";
inherit version;
src = pkgs.fetchurl {
url = "https://github.com/nolabs-ai/nono/releases/download/v${version}/nono-v${version}-${releaseTarget system}.tar.gz";
sha256 = prebuiltHashes.${system};
};
# autoPatchelfHook patches the Linux binary's dynamic linker
# and shared library references. Darwin binaries are already
# self-contained and don't need patching.
nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
pkgs.autoPatchelfHook
];
# The Linux release binary links against libgcc_s.so.1.
buildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
pkgs.gcc.cc.lib
];
# The tarball contains a single `nono` binary at the root.
sourceRoot = ".";
installPhase = ''
runHook preInstall
install -Dm755 nono $out/bin/nono
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Secure, kernel-enforced sandbox for AI agents, MCP and LLM workloads (prebuilt release binary)";
homepage = "https://github.com/nolabs-ai/nono";
license = licenses.asl20;
mainProgram = "nono";
platforms = allSystems;
};
};
in {
packages = forAllSystems (system: rec {
nono = nonoFor system;
prebuilt = prebuiltFor system;
default = nono;
});
apps = forAllSystems (system: {
default = {
type = "app";
program = "${nonoFor system}/bin/nono";
};
});
checks = forAllSystems (system: {
default = nonoFor system;
});
devShells = forAllSystems (system: let pkgs = pkgsFor system; in {
default = pkgs.mkShell {
nativeBuildInputs = [ pkgs.pkg-config ];
# Keep D-Bus tools in the development shell for manual Secret Service
# testing; the package build itself uses the pure-Rust zbus client.
buildInputs = [ pkgs.dbus pkgs.rustc pkgs.cargo ];
};
});
};
}