-
Notifications
You must be signed in to change notification settings - Fork 11
/
flake.nix
145 lines (138 loc) · 4.25 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nci.url = "github:yusdacra/nix-cargo-integration";
nci.inputs.nixpkgs.follows = "nixpkgs";
parts.url = "github:hercules-ci/flake-parts";
parts.inputs.nixpkgs-lib.follows = "nixpkgs";
};
outputs = inputs @ {
parts,
nci,
...
}:
parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
imports = [
nci.flakeModule
parts.flakeModules.easyOverlay
];
perSystem = {
config,
pkgs,
...
}: let
outputs = config.nci.outputs;
oxenBuildInputs = with pkgs;
[
pkg-config
mold
clang
llvmPackages.libclang.lib
openssl
]
++ lib.optionals (pkgs.stdenv.isDarwin) [
darwin.IOKit
darwin.apple_sdk.frameworks.SystemConfiguration
];
commonDrvConfig = {
deps.stdenv = pkgs.clangStdenv;
mkDerivation = {
buildInputs = oxenBuildInputs;
};
env = {
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages.libclang.lib];
RUST_BACKTRACE = 1;
RUST_LOG = "info";
RUSTFLAGS = "-C target-cpu=native";
};
};
in {
nci.projects."Oxen" = {
path = ./.;
export = true;
};
nci.crates = {
"oxen-cli" = {
depsDrvConfig = commonDrvConfig;
drvConfig = commonDrvConfig;
};
"oxen-server" = {
depsDrvConfig = commonDrvConfig;
drvConfig = commonDrvConfig;
profiles = {
dev.runTests = false;
release.runTests = false;
};
};
"liboxen" = {
depsDrvConfig = commonDrvConfig;
drvConfig = commonDrvConfig;
profiles = {
dev.runTests = false;
release.runTests = false;
};
};
};
# nix fmt
formatter = pkgs.alejandra;
# export the project devshell as the default devshell
devShells = {
# nix develop -c $SHELL
default = outputs."Oxen".devShell.overrideAttrs (old: {
buildInputs = old.buildInputs ++ oxenBuildInputs;
packages = [
pkgs.rust-analyzer
];
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages.libclang.lib];
RUST_BACKTRACE = 1;
RUST_LOG = "info";
RUSTFLAGS = "-C target-cpu=native";
});
};
# export the release package of the crate as default package
packages = rec {
# nix build .#oxen-cli
oxen-cli = outputs."oxen-cli".packages.release;
# nix build .#oxen-server
oxen-server = outputs."oxen-server".packages.release;
# nix build .#liboxen
liboxen = outputs."liboxen".packages.release;
# nix build .#oxen-cli-oci
oci-oxen-cli = pkgs.dockerTools.buildImage {
name = "oxenai/oxen-cli";
tag = oxen-cli.version;
created = "now";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [oxen-cli];
pathsToLink = ["${oxen-cli}/bin"];
};
config = {
Cmd = ["${oxen-cli}/bin/oxen"];
};
};
# nix build .#oxen-server-oci
oci-oxen-server = pkgs.dockerTools.buildImage {
name = "oxenai/oxen-server";
tag = oxen-cli.version;
created = "now";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [oxen-server];
pathsToLink = ["${oxen-server}/bin"];
};
config = {
Cmd = ["${oxen-server}/bin/oxen-server"];
};
};
# nix build
default = oxen-cli;
};
# Overlay that can be imported so you can access the packages using oxen.overlay
overlayAttrs = {
inherit (config.packages) oxen-cli oxen-server liboxen oci-oxen-cli oci-oxen-server;
};
};
};
}