@ifunny/ifunny-api-types 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/.devenv/bootstrap/bootstrapLib.nix +630 -0
  2. package/.devenv/bootstrap/default.nix +22 -0
  3. package/.devenv/bootstrap/resolve-lock.nix +190 -0
  4. package/.devenv/changelog-cache.json +9 -0
  5. package/.devenv/devenv.fish +252 -0
  6. package/.devenv/imports.txt +0 -0
  7. package/.devenv/input-paths.txt +10 -0
  8. package/.devenv/load-exports +1 -0
  9. package/.devenv/nix-eval-cache.db +0 -0
  10. package/.devenv/nix-eval-cache.db-shm +0 -0
  11. package/.devenv/nix-eval-cache.db-wal +0 -0
  12. package/.devenv/nix-eval-cache.db.init.lock +0 -0
  13. package/.devenv/nixpkgs-config-99f33fda17d41bc9.nix +17 -0
  14. package/.devenv/nixpkgs-config-c46eff8321b73149.nix +29 -0
  15. package/.devenv/profiles/nix/bootstrap/bootstrapLib.nix +571 -0
  16. package/.devenv/profiles/nix/bootstrap/default.nix +19 -0
  17. package/.devenv/profiles/nix/bootstrap/resolve-lock.nix +157 -0
  18. package/.devenv/profiles/nix/imports.txt +0 -0
  19. package/.devenv/profiles/nix/input-paths.txt +4 -0
  20. package/.devenv/profiles/nix/load-exports +1 -0
  21. package/.devenv/profiles/nix/nix-eval-cache.db +0 -0
  22. package/.devenv/profiles/nix/nix-eval-cache.db-shm +0 -0
  23. package/.devenv/profiles/nix/nix-eval-cache.db-wal +0 -0
  24. package/.devenv/profiles/nix/nixpkgs-config-99f33fda17d41bc9.nix +17 -0
  25. package/.devenv/profiles/nix/shell-0d722b4fe4724c8e.sh +2270 -0
  26. package/.devenv/profiles/nix/shell-314b72302fb2c916.sh +2270 -0
  27. package/.devenv/profiles/nix/shell-6a4b00b5ca837a3b.sh +2270 -0
  28. package/.devenv/profiles/nix/shell-956adc1e664f64c3.sh +2270 -0
  29. package/.devenv/profiles/nix/shell-9dbff87fad44e8d9.sh +2270 -0
  30. package/.devenv/profiles/nix/shell-b1e9e1f82076662f.sh +2270 -0
  31. package/.devenv/profiles/nix/shell-b4f4bbfa36797bee.sh +2270 -0
  32. package/.devenv/profiles/nix/shell-c4b190d331c48d67.sh +2270 -0
  33. package/.devenv/profiles/nix/state/files.json +1 -0
  34. package/.devenv/profiles/nix/state/tasks.db +0 -0
  35. package/.devenv/profiles/nix/state/tasks.db-shm +0 -0
  36. package/.devenv/profiles/nix/state/tasks.db-wal +0 -0
  37. package/.devenv/profiles/nix/task-names.txt +5 -0
  38. package/.devenv/shell-086ca2c39799e6a6.sh +2270 -0
  39. package/.devenv/shell-2c06a35dd99be3d1.sh +2270 -0
  40. package/.devenv/shell-36f1fe0faec08873.sh +2270 -0
  41. package/.devenv/shell-676361065bda5b43.sh +2270 -0
  42. package/.devenv/shell-9f6cb513d1721fef.sh +2270 -0
  43. package/.devenv/shell-c0e4459b4f5922d7.sh +2270 -0
  44. package/.devenv/shell-c862a0db6e9ad5f4.sh +2270 -0
  45. package/.devenv/shell-d71ade933a43e837.sh +2270 -0
  46. package/.devenv/shell-dd73aac05b182946.sh +2270 -0
  47. package/.devenv/shell-e39d0b30a7e0eb13.sh +2270 -0
  48. package/.devenv/shell-env.sh +2263 -0
  49. package/.devenv/shell-f924d749ff8c17ee.sh +2270 -0
  50. package/.devenv/shell-rcfile.sh +152 -0
  51. package/.devenv/state/files.json +1 -0
  52. package/.devenv/state/tasks.db +0 -0
  53. package/.devenv/state/tasks.db-shm +0 -0
  54. package/.devenv/state/tasks.db-wal +0 -0
  55. package/.devenv/state/tasks.db.init.lock +0 -0
  56. package/.devenv/task-names.txt +5 -0
  57. package/.github/workflows/codeql.yml +72 -72
  58. package/.github/workflows/test.yml +31 -31
  59. package/CHANGELOG.md +8405 -417
  60. package/LICENSE +121 -121
  61. package/README.md +2 -2
  62. package/devenv.lock +65 -0
  63. package/devenv.nix +38 -0
  64. package/devenv.yaml +18 -0
  65. package/eslint.config.mjs +18 -0
  66. package/package.json +59 -50
  67. package/prettier.config.js +15 -0
  68. package/dist/errors/bad_request.js +0 -8
  69. package/dist/errors/bad_request.js.map +0 -1
  70. package/dist/errors/captcha_required.js +0 -19
  71. package/dist/errors/captcha_required.js.map +0 -1
  72. package/dist/errors/email_exists.js +0 -8
  73. package/dist/errors/email_exists.js.map +0 -1
  74. package/dist/errors/error.js +0 -3
  75. package/dist/errors/error.js.map +0 -1
  76. package/dist/errors/error_base.js +0 -43
  77. package/dist/errors/error_base.js.map +0 -1
  78. package/dist/errors/index.js +0 -29
  79. package/dist/errors/index.js.map +0 -1
  80. package/dist/errors/invalid_client.js +0 -8
  81. package/dist/errors/invalid_client.js.map +0 -1
  82. package/dist/errors/invalid_email.js +0 -8
  83. package/dist/errors/invalid_email.js.map +0 -1
  84. package/dist/errors/invalid_grant.js +0 -8
  85. package/dist/errors/invalid_grant.js.map +0 -1
  86. package/dist/errors/not_found.js +0 -3
  87. package/dist/errors/not_found.js.map +0 -1
  88. package/dist/errors/permission_denied.js +0 -8
  89. package/dist/errors/permission_denied.js.map +0 -1
  90. package/dist/errors/unauthorized.js +0 -8
  91. package/dist/errors/unauthorized.js.map +0 -1
  92. package/dist/errors/wrong_params.js +0 -8
  93. package/dist/errors/wrong_params.js.map +0 -1
  94. package/dist/index.js +0 -21
  95. package/dist/index.js.map +0 -1
  96. package/dist/payloads/activity.js +0 -50
  97. package/dist/payloads/activity.js.map +0 -1
  98. package/dist/payloads/app.js +0 -3
  99. package/dist/payloads/app.js.map +0 -1
  100. package/dist/payloads/appeal.js +0 -14
  101. package/dist/payloads/appeal.js.map +0 -1
  102. package/dist/payloads/ban.js +0 -36
  103. package/dist/payloads/ban.js.map +0 -1
  104. package/dist/payloads/base.js +0 -3
  105. package/dist/payloads/base.js.map +0 -1
  106. package/dist/payloads/client.js +0 -13
  107. package/dist/payloads/client.js.map +0 -1
  108. package/dist/payloads/comment.js +0 -42
  109. package/dist/payloads/comment.js.map +0 -1
  110. package/dist/payloads/content.js +0 -176
  111. package/dist/payloads/content.js.map +0 -1
  112. package/dist/payloads/index.js +0 -27
  113. package/dist/payloads/index.js.map +0 -1
  114. package/dist/payloads/strike.js +0 -3
  115. package/dist/payloads/strike.js.map +0 -1
  116. package/dist/payloads/user.js +0 -214
  117. package/dist/payloads/user.js.map +0 -1
  118. package/dist/rest/account.js +0 -3
  119. package/dist/rest/account.js.map +0 -1
  120. package/dist/rest/content.js +0 -54
  121. package/dist/rest/content.js.map +0 -1
  122. package/dist/rest/counters.js +0 -3
  123. package/dist/rest/counters.js.map +0 -1
  124. package/dist/rest/endpoints.js +0 -199
  125. package/dist/rest/endpoints.js.map +0 -1
  126. package/dist/rest/explore.js +0 -82
  127. package/dist/rest/explore.js.map +0 -1
  128. package/dist/rest/feeds.js +0 -3
  129. package/dist/rest/feeds.js.map +0 -1
  130. package/dist/rest/index.js +0 -25
  131. package/dist/rest/index.js.map +0 -1
  132. package/dist/rest/issues.js +0 -3
  133. package/dist/rest/issues.js.map +0 -1
  134. package/dist/rest/oauth2.js +0 -9
  135. package/dist/rest/oauth2.js.map +0 -1
  136. package/dist/utils/index.js +0 -19
  137. package/dist/utils/index.js.map +0 -1
  138. package/dist/utils/rest.js +0 -3
  139. package/dist/utils/rest.js.map +0 -1
  140. package/dist/utils/util.js +0 -3
  141. package/dist/utils/util.js.map +0 -1
  142. package/types/errors/bad_request.d.ts +0 -12
  143. package/types/errors/bad_request.d.ts.map +0 -1
  144. package/types/errors/captcha_required.d.ts +0 -33
  145. package/types/errors/captcha_required.d.ts.map +0 -1
  146. package/types/errors/email_exists.d.ts +0 -15
  147. package/types/errors/email_exists.d.ts.map +0 -1
  148. package/types/errors/error.d.ts +0 -29
  149. package/types/errors/error.d.ts.map +0 -1
  150. package/types/errors/error_base.d.ts +0 -61
  151. package/types/errors/error_base.d.ts.map +0 -1
  152. package/types/errors/index.d.ts +0 -13
  153. package/types/errors/index.d.ts.map +0 -1
  154. package/types/errors/invalid_client.d.ts +0 -15
  155. package/types/errors/invalid_client.d.ts.map +0 -1
  156. package/types/errors/invalid_email.d.ts +0 -15
  157. package/types/errors/invalid_email.d.ts.map +0 -1
  158. package/types/errors/invalid_grant.d.ts +0 -12
  159. package/types/errors/invalid_grant.d.ts.map +0 -1
  160. package/types/errors/not_found.d.ts +0 -8
  161. package/types/errors/not_found.d.ts.map +0 -1
  162. package/types/errors/permission_denied.d.ts +0 -12
  163. package/types/errors/permission_denied.d.ts.map +0 -1
  164. package/types/errors/unauthorized.d.ts +0 -12
  165. package/types/errors/unauthorized.d.ts.map +0 -1
  166. package/types/errors/wrong_params.d.ts +0 -11
  167. package/types/errors/wrong_params.d.ts.map +0 -1
  168. package/types/index.d.ts +0 -5
  169. package/types/index.d.ts.map +0 -1
  170. package/types/payloads/activity.d.ts +0 -114
  171. package/types/payloads/activity.d.ts.map +0 -1
  172. package/types/payloads/app.d.ts +0 -266
  173. package/types/payloads/app.d.ts.map +0 -1
  174. package/types/payloads/appeal.d.ts +0 -22
  175. package/types/payloads/appeal.d.ts.map +0 -1
  176. package/types/payloads/ban.d.ts +0 -85
  177. package/types/payloads/ban.d.ts.map +0 -1
  178. package/types/payloads/base.d.ts +0 -5
  179. package/types/payloads/base.d.ts.map +0 -1
  180. package/types/payloads/client.d.ts +0 -106
  181. package/types/payloads/client.d.ts.map +0 -1
  182. package/types/payloads/comment.d.ts +0 -124
  183. package/types/payloads/comment.d.ts.map +0 -1
  184. package/types/payloads/content.d.ts +0 -676
  185. package/types/payloads/content.d.ts.map +0 -1
  186. package/types/payloads/index.d.ts +0 -11
  187. package/types/payloads/index.d.ts.map +0 -1
  188. package/types/payloads/strike.d.ts +0 -15
  189. package/types/payloads/strike.d.ts.map +0 -1
  190. package/types/payloads/user.d.ts +0 -515
  191. package/types/payloads/user.d.ts.map +0 -1
  192. package/types/rest/account.d.ts +0 -4
  193. package/types/rest/account.d.ts.map +0 -1
  194. package/types/rest/content.d.ts +0 -96
  195. package/types/rest/content.d.ts.map +0 -1
  196. package/types/rest/counters.d.ts +0 -10
  197. package/types/rest/counters.d.ts.map +0 -1
  198. package/types/rest/endpoints.d.ts +0 -153
  199. package/types/rest/endpoints.d.ts.map +0 -1
  200. package/types/rest/explore.d.ts +0 -113
  201. package/types/rest/explore.d.ts.map +0 -1
  202. package/types/rest/feeds.d.ts +0 -17
  203. package/types/rest/feeds.d.ts.map +0 -1
  204. package/types/rest/index.d.ts +0 -9
  205. package/types/rest/index.d.ts.map +0 -1
  206. package/types/rest/issues.d.ts +0 -16
  207. package/types/rest/issues.d.ts.map +0 -1
  208. package/types/rest/oauth2.d.ts +0 -37
  209. package/types/rest/oauth2.d.ts.map +0 -1
  210. package/types/utils/index.d.ts +0 -3
  211. package/types/utils/index.d.ts.map +0 -1
  212. package/types/utils/rest.d.ts +0 -50
  213. package/types/utils/rest.d.ts.map +0 -1
  214. package/types/utils/util.d.ts +0 -80
  215. package/types/utils/util.d.ts.map +0 -1
@@ -0,0 +1,571 @@
1
+ # Shared library functions for devenv evaluation
2
+ { inputs }:
3
+
4
+ rec {
5
+ # Helper to get overlays for a given input
6
+ getOverlays =
7
+ inputName: inputAttrs:
8
+ let
9
+ lib = inputs.nixpkgs.lib;
10
+ in
11
+ map
12
+ (
13
+ overlay:
14
+ let
15
+ input =
16
+ inputs.${inputName} or (throw "No such input `${inputName}` while trying to configure overlays.");
17
+ in
18
+ input.overlays.${overlay}
19
+ or (throw "Input `${inputName}` has no overlay called `${overlay}`. Supported overlays: ${lib.concatStringsSep ", " (builtins.attrNames input.overlays)}")
20
+ ) inputAttrs.overlays or [ ];
21
+
22
+ # Main function to create devenv configuration for a specific system with profiles support
23
+ # This is the full-featured version used by default.nix
24
+ mkDevenvForSystem =
25
+ { version
26
+ , is_development_version ? false
27
+ , system
28
+ , devenv_root
29
+ , git_root ? null
30
+ , devenv_dotfile
31
+ , devenv_dotfile_path
32
+ , devenv_tmpdir
33
+ , devenv_runtime
34
+ , devenv_state ? null
35
+ , devenv_istesting ? false
36
+ , devenv_direnvrc_latest_version
37
+ , container_name ? null
38
+ , active_profiles ? [ ]
39
+ , hostname
40
+ , username
41
+ , cli_options ? [ ]
42
+ , skip_local_src ? false
43
+ , secretspec ? null
44
+ , devenv_inputs ? { }
45
+ , devenv_imports ? [ ]
46
+ , impure ? false
47
+ , nixpkgs_config ? { }
48
+ , lock_fingerprint ? null
49
+ , primops ? { }
50
+ }:
51
+ let
52
+ inherit (inputs) nixpkgs;
53
+ lib = nixpkgs.lib;
54
+ targetSystem = system;
55
+
56
+ overlays = lib.flatten (lib.mapAttrsToList getOverlays devenv_inputs);
57
+
58
+ # Helper to create pkgs for a given system with nixpkgs_config
59
+ mkPkgsForSystem =
60
+ evalSystem:
61
+ import nixpkgs {
62
+ system = evalSystem;
63
+ config = nixpkgs_config // {
64
+ allowUnfreePredicate =
65
+ if nixpkgs_config.allowUnfree or false then
66
+ (_: true)
67
+ else if (nixpkgs_config.permittedUnfreePackages or [ ]) != [ ] then
68
+ (pkg: builtins.elem (lib.getName pkg) (nixpkgs_config.permittedUnfreePackages or [ ]))
69
+ else
70
+ (_: false);
71
+ allowInsecurePredicate =
72
+ if (nixpkgs_config.permittedInsecurePackages or [ ]) != [ ] then
73
+ (pkg: builtins.elem (lib.getName pkg) (nixpkgs_config.permittedInsecurePackages or [ ]))
74
+ else
75
+ (_: false);
76
+ } // lib.optionalAttrs ((nixpkgs_config.allowlistedLicenses or [ ]) != [ ]) {
77
+ allowlistedLicenses = map (name: lib.licenses.${name}) (nixpkgs_config.allowlistedLicenses or [ ]);
78
+ } // lib.optionalAttrs ((nixpkgs_config.blocklistedLicenses or [ ]) != [ ]) {
79
+ blocklistedLicenses = map (name: lib.licenses.${name}) (nixpkgs_config.blocklistedLicenses or [ ]);
80
+ };
81
+ inherit overlays;
82
+ };
83
+
84
+ pkgsBootstrap = mkPkgsForSystem targetSystem;
85
+
86
+ # Helper to import a path, trying .nix first then /devenv.nix
87
+ # Returns a list of modules, including devenv.local.nix when present
88
+ tryImport =
89
+ resolvedPath: basePath:
90
+ if lib.hasSuffix ".nix" basePath then
91
+ [ (import resolvedPath) ]
92
+ else
93
+ let
94
+ devenvpath = resolvedPath + "/devenv.nix";
95
+ localpath = resolvedPath + "/devenv.local.nix";
96
+ in
97
+ if builtins.pathExists devenvpath then
98
+ [ (import devenvpath) ] ++ lib.optional (builtins.pathExists localpath) (import localpath)
99
+ else
100
+ throw (basePath + "/devenv.nix file does not exist");
101
+
102
+ importModule =
103
+ path:
104
+ if lib.hasPrefix "path:" path then
105
+ # path: prefix indicates a local filesystem path - strip it and import directly
106
+ let
107
+ actualPath = builtins.substring 5 999999 path;
108
+ in
109
+ tryImport (/. + actualPath) path
110
+ else if lib.hasPrefix "/" path then
111
+ # Absolute path - import directly (avoids input resolution and NAR hash computation)
112
+ tryImport (/. + path) path
113
+ else if lib.hasPrefix "./" path then
114
+ # Relative paths are relative to devenv_root, not bootstrap directory
115
+ let
116
+ relPath = builtins.substring 1 255 path;
117
+ in
118
+ tryImport (/. + devenv_root + relPath) path
119
+ else if lib.hasPrefix "../" path then
120
+ # Parent relative paths also relative to devenv_root
121
+ tryImport (/. + devenv_root + "/${path}") path
122
+ else
123
+ let
124
+ paths = lib.splitString "/" path;
125
+ name = builtins.head paths;
126
+ input = inputs.${name} or (throw "Unknown input ${name}");
127
+ subpath = "/${lib.concatStringsSep "/" (builtins.tail paths)}";
128
+ devenvpath = input + subpath;
129
+ in
130
+ tryImport devenvpath path;
131
+
132
+ # Common modules shared between main evaluation and cross-system evaluation
133
+ mkCommonModules =
134
+ evalPkgs:
135
+ [
136
+ (
137
+ { config, ... }:
138
+ {
139
+ _module.args.pkgs = evalPkgs.appendOverlays (config.overlays or [ ]);
140
+ _module.args.secretspec = secretspec;
141
+ _module.args.devenvPrimops = primops;
142
+ }
143
+ )
144
+ (inputs.devenv.modules + /top-level.nix)
145
+ (
146
+ { options, ... }:
147
+ {
148
+ config.devenv = lib.mkMerge [
149
+ {
150
+ root = devenv_root;
151
+ dotfile = devenv_dotfile;
152
+ }
153
+ (
154
+ if builtins.hasAttr "cli" options.devenv then
155
+ {
156
+ cli.version = version;
157
+ cli.isDevelopment = is_development_version;
158
+ }
159
+ else
160
+ {
161
+ cliVersion = version;
162
+ }
163
+ )
164
+ (lib.optionalAttrs (builtins.hasAttr "tmpdir" options.devenv) {
165
+ tmpdir = devenv_tmpdir;
166
+ })
167
+ (lib.optionalAttrs (builtins.hasAttr "isTesting" options.devenv) {
168
+ isTesting = devenv_istesting;
169
+ })
170
+ (lib.optionalAttrs (builtins.hasAttr "runtime" options.devenv) {
171
+ runtime = devenv_runtime;
172
+ })
173
+ (lib.optionalAttrs (builtins.hasAttr "state" options.devenv && devenv_state != null) {
174
+ state = lib.mkForce devenv_state;
175
+ })
176
+ (lib.optionalAttrs (builtins.hasAttr "direnvrcLatestVersion" options.devenv) {
177
+ direnvrcLatestVersion = devenv_direnvrc_latest_version;
178
+ })
179
+ ];
180
+ }
181
+ )
182
+ (
183
+ { options, ... }:
184
+ {
185
+ config = lib.mkMerge [
186
+ (lib.optionalAttrs (builtins.hasAttr "git" options) {
187
+ git.root = git_root;
188
+ })
189
+ ];
190
+ }
191
+ )
192
+ (lib.optionalAttrs (container_name != null) {
193
+ container.isBuilding = lib.mkForce true;
194
+ containers.${container_name}.isBuilding = true;
195
+ })
196
+ ]
197
+ ++ (lib.flatten (map importModule devenv_imports))
198
+ ++ (if !skip_local_src then (importModule (devenv_root + "/devenv.nix")) else [ ])
199
+ ++ [
200
+ (
201
+ let
202
+ localPath = devenv_root + "/devenv.local.nix";
203
+ in
204
+ if builtins.pathExists localPath then import localPath else { }
205
+ )
206
+ cli_options
207
+ ];
208
+
209
+ # Phase 1: Base evaluation to extract profile definitions
210
+ baseProject = lib.evalModules {
211
+ specialArgs = inputs // {
212
+ inherit inputs secretspec primops;
213
+ };
214
+ modules = mkCommonModules pkgsBootstrap;
215
+ };
216
+
217
+ # Phase 2: Extract and apply profiles using extendModules with priority overrides
218
+ project =
219
+ let
220
+ # Build ordered list of profile names: hostname -> user -> manual
221
+ manualProfiles = active_profiles;
222
+ currentHostname = hostname;
223
+ currentUsername = username;
224
+ hostnameProfiles = lib.optional
225
+ (
226
+ currentHostname != null
227
+ && currentHostname != ""
228
+ && builtins.hasAttr currentHostname (baseProject.config.profiles.hostname or { })
229
+ ) "hostname.${currentHostname}";
230
+ userProfiles = lib.optional
231
+ (
232
+ currentUsername != null
233
+ && currentUsername != ""
234
+ && builtins.hasAttr currentUsername (baseProject.config.profiles.user or { })
235
+ ) "user.${currentUsername}";
236
+
237
+ # Ordered list of profiles to activate
238
+ orderedProfiles = hostnameProfiles ++ userProfiles ++ manualProfiles;
239
+
240
+ # Resolve profile extends with cycle detection
241
+ resolveProfileExtends =
242
+ profileName: visited:
243
+ if builtins.elem profileName visited then
244
+ throw "Circular dependency detected in profile extends: ${lib.concatStringsSep " -> " visited} -> ${profileName}"
245
+ else
246
+ let
247
+ profile = getProfileConfig profileName;
248
+ extends = profile.extends or [ ];
249
+ newVisited = visited ++ [ profileName ];
250
+ extendedProfiles = lib.flatten (map (name: resolveProfileExtends name newVisited) extends);
251
+ in
252
+ extendedProfiles ++ [ profileName ];
253
+
254
+ # Get profile configuration by name from baseProject
255
+ getProfileConfig =
256
+ profileName:
257
+ if lib.hasPrefix "hostname." profileName then
258
+ let
259
+ name = lib.removePrefix "hostname." profileName;
260
+ in
261
+ baseProject.config.profiles.hostname.${name}
262
+ else if lib.hasPrefix "user." profileName then
263
+ let
264
+ name = lib.removePrefix "user." profileName;
265
+ in
266
+ baseProject.config.profiles.user.${name}
267
+ else
268
+ let
269
+ availableProfiles = builtins.attrNames (baseProject.config.profiles or { });
270
+ hostnameProfiles = map (n: "hostname.${n}") (
271
+ builtins.attrNames (baseProject.config.profiles.hostname or { })
272
+ );
273
+ userProfiles = map (n: "user.${n}") (builtins.attrNames (baseProject.config.profiles.user or { }));
274
+ allAvailableProfiles = availableProfiles ++ hostnameProfiles ++ userProfiles;
275
+ in
276
+ baseProject.config.profiles.${profileName}
277
+ or (throw "Profile '${profileName}' not found. Available profiles: ${lib.concatStringsSep ", " allAvailableProfiles}");
278
+
279
+ # Fold over ordered profiles to build final list with extends
280
+ expandedProfiles = lib.foldl'
281
+ (
282
+ acc: profileName:
283
+ let
284
+ allProfileNames = resolveProfileExtends profileName [ ];
285
+ in
286
+ acc ++ allProfileNames
287
+ ) [ ]
288
+ orderedProfiles;
289
+
290
+ # Map over expanded profiles and apply priorities
291
+ allPrioritizedModules = lib.imap0
292
+ (
293
+ index: profileName:
294
+ let
295
+ profilePriority = (lib.modules.defaultOverridePriority - 1) - index;
296
+ profileConfig = getProfileConfig profileName;
297
+
298
+ typeNeedsOverride =
299
+ type:
300
+ if type == null then
301
+ false
302
+ else
303
+ let
304
+ typeName = type.name or type._type or "";
305
+
306
+ isLeafType = builtins.elem typeName [
307
+ "str"
308
+ "int"
309
+ "bool"
310
+ "enum"
311
+ "path"
312
+ "package"
313
+ "float"
314
+ "anything"
315
+ ];
316
+ in
317
+ if isLeafType then
318
+ true
319
+ else if typeName == "nullOr" then
320
+ let
321
+ innerType =
322
+ type.elemType
323
+ or (if type ? nestedTypes && type.nestedTypes ? elemType then type.nestedTypes.elemType else null);
324
+ in
325
+ if innerType != null then typeNeedsOverride innerType else false
326
+ else
327
+ false;
328
+
329
+ pathNeedsOverride =
330
+ optionPath:
331
+ let
332
+ directOption = lib.attrByPath optionPath null baseProject.options;
333
+ in
334
+ if directOption != null && lib.isOption directOption then
335
+ typeNeedsOverride directOption.type
336
+ else if optionPath != [ ] then
337
+ let
338
+ parentPath = lib.init optionPath;
339
+ parentOption = lib.attrByPath parentPath null baseProject.options;
340
+ in
341
+ if parentOption != null && lib.isOption parentOption then
342
+ let
343
+ freeformType = parentOption.type.freeformType or parentOption.type.nestedTypes.freeformType or null;
344
+ elementType =
345
+ if freeformType ? elemType then
346
+ freeformType.elemType
347
+ else if freeformType ? nestedTypes && freeformType.nestedTypes ? elemType then
348
+ freeformType.nestedTypes.elemType
349
+ else
350
+ freeformType;
351
+ in
352
+ typeNeedsOverride elementType
353
+ else
354
+ false
355
+ else
356
+ false;
357
+
358
+ applyModuleOverride =
359
+ config:
360
+ if builtins.isFunction config then
361
+ let
362
+ wrapper = args: applyOverrideRecursive (config args) [ ];
363
+ in
364
+ lib.mirrorFunctionArgs config wrapper
365
+ else
366
+ applyOverrideRecursive config [ ];
367
+
368
+ applyOverrideRecursive =
369
+ config: optionPath:
370
+ if lib.isAttrs config && config ? _type then
371
+ config
372
+ else if lib.isAttrs config then
373
+ lib.mapAttrs (name: value: applyOverrideRecursive value (optionPath ++ [ name ])) config
374
+ else if pathNeedsOverride optionPath then
375
+ lib.mkOverride profilePriority config
376
+ else
377
+ config;
378
+
379
+ prioritizedConfig = (
380
+ profileConfig.module
381
+ // {
382
+ imports = lib.map
383
+ (
384
+ importItem:
385
+ importItem
386
+ // {
387
+ imports = lib.map (nestedImport: applyModuleOverride nestedImport) (importItem.imports or [ ]);
388
+ }
389
+ )
390
+ (profileConfig.module.imports or [ ]);
391
+ }
392
+ );
393
+ in
394
+ prioritizedConfig
395
+ )
396
+ expandedProfiles;
397
+ in
398
+ if allPrioritizedModules == [ ] then
399
+ baseProject
400
+ else
401
+ baseProject.extendModules { modules = allPrioritizedModules; };
402
+
403
+ config = project.config;
404
+
405
+ # Apply config overlays to pkgs
406
+ pkgs = pkgsBootstrap.appendOverlays (config.overlays or [ ]);
407
+
408
+ options = pkgs.nixosOptionsDoc {
409
+ options = builtins.removeAttrs project.options [ "_module" ];
410
+ warningsAreErrors = false;
411
+ transformOptions =
412
+ let
413
+ isDocType =
414
+ v:
415
+ builtins.elem v [
416
+ "literalDocBook"
417
+ "literalExpression"
418
+ "literalMD"
419
+ "mdDoc"
420
+ ];
421
+ in
422
+ lib.attrsets.mapAttrs (
423
+ _: v:
424
+ if v ? _type && isDocType v._type then
425
+ v.text
426
+ else if v ? _type && v._type == "derivation" then
427
+ v.name
428
+ else
429
+ v
430
+ );
431
+ };
432
+
433
+ build =
434
+ options: config:
435
+ lib.concatMapAttrs
436
+ (
437
+ name: option:
438
+ if lib.isOption option then
439
+ let
440
+ typeName = option.type.name or "";
441
+ in
442
+ if
443
+ builtins.elem typeName [
444
+ "output"
445
+ "outputOf"
446
+ ]
447
+ then
448
+ {
449
+ ${name} = config.${name};
450
+ }
451
+ else
452
+ { }
453
+ else if builtins.isAttrs option && !lib.isDerivation option then
454
+ let
455
+ v = build option config.${name};
456
+ in
457
+ if v != { } then { ${name} = v; } else { }
458
+ else
459
+ { }
460
+ )
461
+ options;
462
+
463
+ # Helper to evaluate devenv for a specific system (for cross-compilation, e.g. macOS building Linux containers)
464
+ evalForSystem =
465
+ evalSystem:
466
+ let
467
+ evalPkgs = mkPkgsForSystem evalSystem;
468
+ evalProject = lib.evalModules {
469
+ specialArgs = inputs // {
470
+ inherit inputs secretspec primops;
471
+ };
472
+ modules = mkCommonModules evalPkgs;
473
+ };
474
+ in
475
+ {
476
+ config = evalProject.config;
477
+ };
478
+
479
+ # All supported systems for cross-compilation (lazily evaluated)
480
+ allSystems = [
481
+ "x86_64-linux"
482
+ "aarch64-linux"
483
+ "x86_64-darwin"
484
+ "aarch64-darwin"
485
+ ];
486
+
487
+ # Generate perSystem entries for all systems (only evaluated when accessed)
488
+ perSystemConfigs = lib.genAttrs allSystems (
489
+ perSystem: if perSystem == targetSystem then { config = config; } else evalForSystem perSystem
490
+ );
491
+ in
492
+ {
493
+ inherit
494
+ pkgs
495
+ config
496
+ options
497
+ project
498
+ ;
499
+ bash = pkgs.bash;
500
+ shell = config.shell;
501
+ optionsJSON = options.optionsJSON;
502
+ info = config.info;
503
+ ci = config.ciDerivation;
504
+ build = build project.options config;
505
+ devenv = {
506
+ # Backwards compatibility: wrap config in devenv attribute for code expecting devenv.config.*
507
+ config = config;
508
+ # perSystem structure for cross-compilation (e.g. macOS building Linux containers)
509
+ perSystem = perSystemConfigs;
510
+ };
511
+ };
512
+
513
+ # Simplified devenv evaluation for inputs
514
+ # This is a lightweight version suitable for evaluating an input's devenv.nix
515
+ mkDevenvForInput =
516
+ {
517
+ # The input to evaluate (must have outPath and sourceInfo)
518
+ input
519
+ , # All resolved inputs (for specialArgs)
520
+ allInputs
521
+ , # System to evaluate for
522
+ system ? builtins.currentSystem
523
+ , # Nixpkgs to use (defaults to allInputs.nixpkgs)
524
+ nixpkgs ? allInputs.nixpkgs or (throw "nixpkgs input required")
525
+ , # Devenv modules (defaults to allInputs.devenv)
526
+ devenv ? allInputs.devenv or (throw "devenv input required")
527
+ ,
528
+ }:
529
+ let
530
+ devenvPath = input.outPath + "/devenv.nix";
531
+ hasDevenv = builtins.pathExists devenvPath;
532
+ in
533
+ if !hasDevenv then
534
+ throw ''
535
+ Input does not have a devenv.nix file.
536
+ Expected file at: ${devenvPath}
537
+
538
+ To use this input's devenv configuration, the input must provide a devenv.nix file.
539
+ ''
540
+ else
541
+ let
542
+ pkgs = import nixpkgs {
543
+ inherit system;
544
+ config = { };
545
+ };
546
+ lib = pkgs.lib;
547
+
548
+ project = lib.evalModules {
549
+ specialArgs = allInputs // {
550
+ inputs = allInputs;
551
+ secretspec = null;
552
+ };
553
+ modules = [
554
+ (
555
+ { config, ... }:
556
+ {
557
+ _module.args.pkgs = pkgs.appendOverlays (config.overlays or [ ]);
558
+ }
559
+ )
560
+ (devenv.outPath + "/src/modules/top-level.nix")
561
+ (import devenvPath)
562
+ ];
563
+ };
564
+ in
565
+ {
566
+ inherit pkgs;
567
+ config = project.config;
568
+ options = project.options;
569
+ inherit project;
570
+ };
571
+ }
@@ -0,0 +1,19 @@
1
+ args@{ system
2
+ , # The project root (location of devenv.nix)
3
+ devenv_root
4
+ , ...
5
+ }:
6
+
7
+ let
8
+ inherit
9
+ (import ./resolve-lock.nix {
10
+ src = devenv_root;
11
+ inherit system;
12
+ })
13
+ inputs
14
+ ;
15
+
16
+ bootstrapLib = import ./bootstrapLib.nix { inherit inputs; };
17
+ in
18
+
19
+ bootstrapLib.mkDevenvForSystem args