-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathflake.nix
More file actions
186 lines (172 loc) · 5.93 KB
/
Copy pathflake.nix
File metadata and controls
186 lines (172 loc) · 5.93 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
{
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";
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,
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;
nixpkgsFor = system: if system == "x86_64-darwin" then nixpkgs-darwin-x64 else nixpkgs;
bun2nixFor = system: if system == "x86_64-darwin" then bun2nix-darwin-x64 else bun2nix;
pkgsFor =
system:
import (nixpkgsFor system) {
inherit system;
overlays = [
rust-overlay.overlays.default
(bun2nixFor system).overlays.default
(final: _previous: {
# Instantiate the pinned upstream binary against this package
# set so Intel macOS does not re-enter nix-bun's unstable input.
bun = final.callPackage (nix-bun.outPath + "/package.nix") {
sourcesFile = nix-bun.outPath + "/versions/1.4.0.json";
};
})
];
};
packageFor =
system:
let
pkgs = pkgsFor system;
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
pkgs.callPackage ./nix/package.nix {
inherit rustToolchain;
source = self.outPath;
};
in
{
packages = forAllSystems (system: {
default = packageFor system;
omp = packageFor system;
});
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;
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
default = import ./nix/dev-shell.nix { inherit pkgs rustToolchain; };
}
);
checks = forAllSystems (
system:
let
pkgs = pkgsFor 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 = [ pkgs.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
diff -u nix/bun.expected.nix nix/bun.nix
touch "$out"
'';
4CBC
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;
};
}