@ifunny/ifunny-api-types 1.0.4 → 1.2.2
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.
- package/.devenv/bootstrap/bootstrapLib.nix +650 -0
- package/.devenv/bootstrap/default.nix +22 -0
- package/.devenv/bootstrap/lock-sources.nix +123 -0
- package/.devenv/bootstrap/resolve-input-paths.nix +34 -0
- package/.devenv/bootstrap/resolve-lock.nix +116 -0
- package/.devenv/changelog-cache.json +13 -0
- package/.devenv/devenv.fish +252 -0
- package/.devenv/imports.txt +0 -0
- package/.devenv/input-paths.txt +8 -0
- package/.devenv/load-exports +1 -0
- package/.devenv/nix-eval-cache.db +0 -0
- package/.devenv/nix-eval-cache.db.init.lock +0 -0
- package/.devenv/nixpkgs-config-99f33fda17d41bc9.nix +17 -0
- package/.devenv/nixpkgs-config-c46eff8321b73149.nix +29 -0
- package/.devenv/profiles/nix/bootstrap/bootstrapLib.nix +571 -0
- package/.devenv/profiles/nix/bootstrap/default.nix +19 -0
- package/.devenv/profiles/nix/bootstrap/resolve-lock.nix +157 -0
- package/.devenv/profiles/nix/imports.txt +0 -0
- package/.devenv/profiles/nix/input-paths.txt +4 -0
- package/.devenv/profiles/nix/load-exports +1 -0
- package/.devenv/profiles/nix/nix-eval-cache.db +0 -0
- package/.devenv/profiles/nix/nix-eval-cache.db-shm +0 -0
- package/.devenv/profiles/nix/nix-eval-cache.db-wal +0 -0
- package/.devenv/profiles/nix/nixpkgs-config-99f33fda17d41bc9.nix +17 -0
- package/.devenv/profiles/nix/shell-0d722b4fe4724c8e.sh +2270 -0
- package/.devenv/profiles/nix/shell-314b72302fb2c916.sh +2270 -0
- package/.devenv/profiles/nix/shell-6a4b00b5ca837a3b.sh +2270 -0
- package/.devenv/profiles/nix/shell-956adc1e664f64c3.sh +2270 -0
- package/.devenv/profiles/nix/shell-9dbff87fad44e8d9.sh +2270 -0
- package/.devenv/profiles/nix/shell-b1e9e1f82076662f.sh +2270 -0
- package/.devenv/profiles/nix/shell-b4f4bbfa36797bee.sh +2270 -0
- package/.devenv/profiles/nix/shell-c4b190d331c48d67.sh +2270 -0
- package/.devenv/profiles/nix/state/files.json +1 -0
- package/.devenv/profiles/nix/state/tasks.db +0 -0
- package/.devenv/profiles/nix/state/tasks.db-shm +0 -0
- package/.devenv/profiles/nix/state/tasks.db-wal +0 -0
- package/.devenv/profiles/nix/task-names.txt +5 -0
- package/.devenv/shell-086ca2c39799e6a6.sh +2270 -0
- package/.devenv/shell-2c06a35dd99be3d1.sh +2270 -0
- package/.devenv/shell-36f1fe0faec08873.sh +2270 -0
- package/.devenv/shell-676361065bda5b43.sh +2270 -0
- package/.devenv/shell-9f6cb513d1721fef.sh +2270 -0
- package/.devenv/shell-c0e4459b4f5922d7.sh +2270 -0
- package/.devenv/shell-c862a0db6e9ad5f4.sh +2270 -0
- package/.devenv/shell-d71ade933a43e837.sh +2270 -0
- package/.devenv/shell-dd73aac05b182946.sh +2270 -0
- package/.devenv/shell-e39d0b30a7e0eb13.sh +2270 -0
- package/.devenv/shell-env.sh +2275 -0
- package/.devenv/shell-f924d749ff8c17ee.sh +2270 -0
- package/.devenv/shell-rcfile.sh +152 -0
- package/.devenv/state/files.json +5 -0
- package/.devenv/state/git-hooks-install/hooks +1 -0
- package/.devenv/state/git-hooks-install/key +4 -0
- package/.devenv/state/prek/.lock +0 -0
- package/.devenv/state/prek/README +2 -0
- package/.devenv/state/prek/config-tracking.json +3 -0
- package/.devenv/state/prek/patches/1793595918715-562072.patch +26 -0
- package/.devenv/state/prek/patches/1793596283854-574354.patch +22881 -0
- package/.devenv/state/prek/patches/1793596332255-574728.patch +22870 -0
- package/.devenv/state/prek/patches/1793597557669-617911.patch +284 -0
- package/.devenv/state/prek/patches/1793856046749-331249.patch +2906 -0
- package/.devenv/state/prek/patches/1793856096552-331868.patch +2998 -0
- package/.devenv/state/prek/patches/1793856146786-332328.patch +3009 -0
- package/.devenv/state/prek/patches/1793856181490-332981.patch +11401 -0
- package/.devenv/state/prek/patches/1793856203087-333510.patch +11388 -0
- package/.devenv/state/prek/patches/1793856277935-334258.patch +11372 -0
- package/.devenv/state/prek/patches/1793856646955-337912.patch +8488 -0
- package/.devenv/state/prek/patches/1793856682905-338572.patch +8260 -0
- package/.devenv/state/prek/patches/1793857035751-356215.patch +8295 -0
- package/.devenv/state/tasks.db +0 -0
- package/.devenv/state/tasks.db.init.lock +0 -0
- package/.devenv/task-names.txt +7 -0
- package/.github/workflows/codeql.yml +72 -72
- package/.github/workflows/test.yml +31 -31
- package/.prettierignore +9 -0
- package/CHANGELOG.md +609 -427
- package/LICENSE +121 -121
- package/README.md +2 -2
- package/devenv.lock +103 -0
- package/devenv.nix +35 -0
- package/devenv.yaml +23 -0
- package/dist/errors/bad_request.js +7 -7
- package/dist/errors/bad_request.js.map +1 -1
- package/dist/errors/captcha_required.js +18 -18
- package/dist/errors/captcha_required.js.map +1 -1
- package/dist/errors/email_exists.js +7 -7
- package/dist/errors/email_exists.js.map +1 -1
- package/dist/errors/error.js +2 -2
- package/dist/errors/error_base.js +42 -42
- package/dist/errors/error_base.js.map +1 -1
- package/dist/errors/index.js +28 -28
- package/dist/errors/invalid_client.js +7 -7
- package/dist/errors/invalid_client.js.map +1 -1
- package/dist/errors/invalid_email.js +7 -7
- package/dist/errors/invalid_email.js.map +1 -1
- package/dist/errors/invalid_grant.js +7 -7
- package/dist/errors/invalid_grant.js.map +1 -1
- package/dist/errors/not_found.js +2 -2
- package/dist/errors/permission_denied.js +7 -7
- package/dist/errors/permission_denied.js.map +1 -1
- package/dist/errors/unauthorized.js +7 -7
- package/dist/errors/unauthorized.js.map +1 -1
- package/dist/errors/wrong_params.js +7 -7
- package/dist/errors/wrong_params.js.map +1 -1
- package/dist/index.js +20 -20
- package/dist/payloads/activity.js +49 -49
- package/dist/payloads/activity.js.map +1 -1
- package/dist/payloads/app.js +2 -2
- package/dist/payloads/appeal.js +13 -13
- package/dist/payloads/appeal.js.map +1 -1
- package/dist/payloads/ban.js +35 -35
- package/dist/payloads/ban.js.map +1 -1
- package/dist/payloads/base.js +2 -2
- package/dist/payloads/chat.js +37 -0
- package/dist/payloads/chat.js.map +1 -0
- package/dist/payloads/client.js +12 -12
- package/dist/payloads/client.js.map +1 -1
- package/dist/payloads/comment.js +41 -41
- package/dist/payloads/comment.js.map +1 -1
- package/dist/payloads/content.js +175 -175
- package/dist/payloads/content.js.map +1 -1
- package/dist/payloads/index.js +28 -26
- package/dist/payloads/index.js.map +1 -1
- package/dist/payloads/strike.js +2 -2
- package/dist/payloads/topics.js +72 -0
- package/dist/payloads/topics.js.map +1 -0
- package/dist/payloads/user.js +214 -214
- package/dist/payloads/user.js.map +1 -1
- package/dist/rest/account.js +2 -2
- package/dist/rest/content.js +53 -53
- package/dist/rest/content.js.map +1 -1
- package/dist/rest/counters.js +2 -2
- package/dist/rest/endpoints.js +198 -198
- package/dist/rest/endpoints.js.map +1 -1
- package/dist/rest/explore.js +81 -81
- package/dist/rest/explore.js.map +1 -1
- package/dist/rest/feeds.js +2 -2
- package/dist/rest/index.js +24 -24
- package/dist/rest/issues.js +2 -2
- package/dist/rest/oauth2.js +8 -8
- package/dist/rest/oauth2.js.map +1 -1
- package/dist/utils/index.js +18 -18
- package/dist/utils/rest.js +2 -2
- package/dist/utils/util.js +2 -2
- package/eslint.config.mjs +18 -0
- package/package.json +66 -50
- package/prettier.config.js +15 -0
- package/tag-check.sh +111 -0
- package/types/errors/bad_request.d.ts +11 -11
- package/types/errors/bad_request.d.ts.map +1 -1
- package/types/errors/captcha_required.d.ts +32 -32
- package/types/errors/captcha_required.d.ts.map +1 -1
- package/types/errors/email_exists.d.ts +14 -14
- package/types/errors/email_exists.d.ts.map +1 -1
- package/types/errors/error.d.ts +28 -28
- package/types/errors/error.d.ts.map +1 -1
- package/types/errors/error_base.d.ts +60 -60
- package/types/errors/error_base.d.ts.map +1 -1
- package/types/errors/index.d.ts +12 -12
- package/types/errors/invalid_client.d.ts +14 -14
- package/types/errors/invalid_client.d.ts.map +1 -1
- package/types/errors/invalid_email.d.ts +14 -14
- package/types/errors/invalid_email.d.ts.map +1 -1
- package/types/errors/invalid_grant.d.ts +11 -11
- package/types/errors/invalid_grant.d.ts.map +1 -1
- package/types/errors/not_found.d.ts +7 -7
- package/types/errors/permission_denied.d.ts +11 -11
- package/types/errors/permission_denied.d.ts.map +1 -1
- package/types/errors/unauthorized.d.ts +11 -11
- package/types/errors/unauthorized.d.ts.map +1 -1
- package/types/errors/wrong_params.d.ts +10 -10
- package/types/errors/wrong_params.d.ts.map +1 -1
- package/types/index.d.ts +4 -4
- package/types/payloads/activity.d.ts +113 -113
- package/types/payloads/activity.d.ts.map +1 -1
- package/types/payloads/app.d.ts +265 -265
- package/types/payloads/appeal.d.ts +21 -21
- package/types/payloads/appeal.d.ts.map +1 -1
- package/types/payloads/ban.d.ts +84 -84
- package/types/payloads/ban.d.ts.map +1 -1
- package/types/payloads/base.d.ts +4 -4
- package/types/payloads/chat.d.ts +117 -0
- package/types/payloads/chat.d.ts.map +1 -0
- package/types/payloads/client.d.ts +107 -107
- package/types/payloads/client.d.ts.map +1 -1
- package/types/payloads/comment.d.ts +123 -123
- package/types/payloads/comment.d.ts.map +1 -1
- package/types/payloads/content.d.ts +676 -677
- package/types/payloads/content.d.ts.map +1 -1
- package/types/payloads/index.d.ts +12 -10
- package/types/payloads/index.d.ts.map +1 -1
- package/types/payloads/strike.d.ts +14 -14
- package/types/payloads/topics.d.ts +45 -0
- package/types/payloads/topics.d.ts.map +1 -0
- package/types/payloads/user.d.ts +522 -522
- package/types/payloads/user.d.ts.map +1 -1
- package/types/rest/account.d.ts +3 -3
- package/types/rest/account.d.ts.map +1 -1
- package/types/rest/content.d.ts +95 -95
- package/types/rest/content.d.ts.map +1 -1
- package/types/rest/counters.d.ts +9 -9
- package/types/rest/counters.d.ts.map +1 -1
- package/types/rest/endpoints.d.ts +152 -152
- package/types/rest/explore.d.ts +112 -112
- package/types/rest/explore.d.ts.map +1 -1
- package/types/rest/feeds.d.ts +16 -16
- package/types/rest/index.d.ts +8 -8
- package/types/rest/issues.d.ts +15 -15
- package/types/rest/oauth2.d.ts +36 -36
- package/types/rest/oauth2.d.ts.map +1 -1
- package/types/utils/index.d.ts +2 -2
- package/types/utils/rest.d.ts +49 -49
- package/types/utils/rest.d.ts.map +1 -1
- package/types/utils/util.d.ts +79 -79
- package/types/utils/util.d.ts.map +1 -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
|