Skip to content

Commit 7fac30f

Browse files
Naxdyadisbladis
authored andcommitted
workspace: allow specifying custom contents for uv.lock and pyproject.toml
1 parent 5d0e883 commit 7fac30f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/workspace.nix

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ fix (self: {
9999
# - An attribute set
100100
# - A function taking the generated config as an argument, and returning the augmented config
101101
config ? { },
102+
# Contents of the workspace's `uv.lock` file.
103+
# Will default to `lib.importTOML "${workspaceRoot}/uv.lock"` if not set.
104+
uvLock ? importTOML (workspaceRoot + "/uv.lock"),
105+
# Contents of the workspace's `pyproject.toml` file.
106+
# Will default to `lib.importTOML "${workspaceRoot}/pyproject.toml"` if not set.
107+
pyproject ? importTOML (workspaceRoot + "/pyproject.toml"),
102108
}:
103109
assert (
104110
isPath workspaceRoot
@@ -107,13 +113,11 @@ fix (self: {
107113
);
108114
assert isAttrs config || isFunction config;
109115
let
110-
pyproject = importTOML (workspaceRoot + "/pyproject.toml");
111-
uvLock = lock1.parseLock (importTOML (workspaceRoot + "/uv.lock"));
112-
113-
localPackages = filter lock1.isLocalPackage uvLock.package;
116+
parsedUvLock = lock1.parseLock uvLock;
117+
localPackages = filter lock1.isLocalPackage parsedUvLock.package;
114118

115119
workspaceProjects = lock1.getLocalProjects {
116-
lock = uvLock;
120+
lock = parsedUvLock;
117121
inherit localPackages workspaceRoot;
118122
};
119123

@@ -153,7 +157,7 @@ fix (self: {
153157
Python constraints for project
154158
.
155159
*/
156-
inherit (uvLock) requires-python;
160+
inherit (parsedUvLock) requires-python;
157161

158162
# inherit (uvLock) requires-python;
159163

@@ -181,7 +185,7 @@ fix (self: {
181185
inherit sourcePreference environ workspaceRoot;
182186
localProjects = workspaceProjects;
183187
spec = dependencies;
184-
lock = uvLock;
188+
lock = parsedUvLock;
185189
config = config';
186190
};
187191

0 commit comments

Comments
 (0)