Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
205 lines (186 loc) · 6.13 KB
/
Copy pathflake.nix
File metadata and controls
205 lines (186 loc) · 6.13 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{
description = "OMP coding agent and development environment";
nixConfig = {
extra-substituters = [ "https://nix-community.cachix.org" ];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# nixpkgs unstable dropped Intel macOS in 26.11; keep that supported
# platform on the final stable branch that still receives security fixes.
nixpkgs-darwin-x64.url = "github:NixOS/nixpkgs/nixpkgs-26.05-darwin";
crane.url = "github:ipetkov/crane";
bun2nix = {
url = "github:nix-community/bun2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# bun2nix's per-system helper packages must use the same Intel-compatible
# package set as the derivation consuming its overlay.
bun2nix-darwin-x64 = {
url = "github:nix-community/bun2nix";
inputs.nixpkgs.follows = "nixpkgs-darwin-x64";
inputs.systems.url = "github:nix-systems/x86_64-darwin";
};
nix-bun = {
url = "github:ryoppippi/nix-bun";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
bun2nix,
bun2nix-darwin-x64,
crane,
nix-bun,
nixpkgs,
nixpkgs-darwin-x64,
rust-overlay,
...
}:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor =
system:
(if system == "x86_64-darwin" then nixpkgs-darwin-x64 else nixpkgs).legacyPackages.${system};
bun2nixFor =
system:
(if system == "x86_64-darwin" then bun2nix-darwin-x64 else bun2nix).packages.${system}.bun2nix;
rustToolchainFor =
system:
(rust-overlay.lib.mkRustBin { } (pkgsFor system)).fromRustupToolchainFile ./rust-toolchain.toml;
localPackagesFor =
system:
let
pkgs = pkgsFor system;
in
{
bun = pkgs.callPackage (nix-bun.outPath + "/package.nix") {
sourcesFile = nix-bun.outPath + "/versions/1.4.4.json";
};
bun2nix = bun2nixFor system;
rustToolchain = rustToolchainFor system;
};
packageFor =
system:
let
pkgs = pkgsFor system;
localPkgs = localPackagesFor system;
in
pkgs.callPackage ./nix/package.nix {
source = self.outPath;
inherit (localPkgs) bun bun2nix;
craneLib = (crane.mkLib pkgs).overrideToolchain localPkgs.rustToolchain;
};
in
{
packages = forAllSystems (
system:
let
omp = packageFor system;
in
{
inherit omp;
default = omp;
}
);
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/omp";
meta.description = "Run OMP";
};
omp = self.apps.${system}.default;
});
devShells = forAllSystems (
system:
let
pkgs = pkgsFor system;
localPackages = localPackagesFor system;
in
{
default = import ./nix/dev-shell.nix ({ inherit pkgs; } // localPackages);
}
);
checks = forAllSystems (
system:
let
pkgs = pkgsFor system;
bun2nix = bun2nixFor system;
homeManagerEvaluation = pkgs.lib.evalModules {
specialArgs = { inherit pkgs; };
modules = [
{
options.home.packages = pkgs.lib.mkOption {
type = pkgs.lib.types.listOf pkgs.lib.types.package;
default = [ ];
};
options.home.activation = pkgs.lib.mkOption {
type = pkgs.lib.types.attrsOf pkgs.lib.types.anything;
default = { };
};
}
self.homeManagerModules.default
{
programs.omp.enable = true;
programs.omp.settings.startup.quiet = true;
}
];
};
nixosEvaluation = pkgs.lib.evalModules {
specialArgs = { inherit pkgs; };
modules = [
{
options.environment.systemPackages = pkgs.lib.mkOption {
type = pkgs.lib.types.listOf pkgs.lib.types.package;
default = [ ];
};
}
self.nixosModules.default
{ programs.omp.enable = true; }
];
};
modulesEvaluate =
assert builtins.elem self.packages.${system}.default homeManagerEvaluation.config.home.packages;
assert homeManagerEvaluation.config.home.activation ? ompConfig;
assert builtins.elem self.packages.${system}.default
nixosEvaluation.config.environment.systemPackages;
pkgs.runCommand "omp-module-evaluation" { } "touch $out";
in
{
bun-lock = pkgs.runCommand "omp-bun-lock" { nativeBuildInputs = [ bun2nix ]; } ''
cp -R ${self.outPath} source
chmod -R u+w source
cd source
mv nix/bun.nix nix/bun.expected.nix
bun2nix -l bun.lock -c ../ -o nix/bun.nix
sed -i -e '$a\' nix/bun.nix
diff -u nix/bun.expected.nix nix/bun.nix
touch "$out"
'';
modules = modulesEvaluate;
omp = self.packages.${system}.default;
}
);
formatter = forAllSystems (system: (pkgsFor system).nixfmt);
overlays.default = _final: previous: {
omp = self.packages.${previous.stdenv.hostPlatform.system}.default;
};
homeManagerModules.default = import ./nix/home-manager.nix { inherit self; };
homeManagerModules.omp = self.homeManagerModules.default;
nixosModules.default = import ./nix/nixos-module.nix { inherit self; };
nixosModules.omp = self.nixosModules.default;
};
}