···11+# Custom added colors to the default color scheme:
22+#
33+# #292929 (Currently used for inactive tabs, active line background)
44+# #212121 (Currently used for the background variable)
55+#
66+# Default color scheme
77+#
88+# "purple" = "#AE81FF"
99+# "yellow" = "#E6DB74"
1010+# "pink" = "#f92a72"
1111+# "white" = "#cfcfc2"
1212+# "gray" = "#75715e"
1313+# "darkgray" = "#444444"
1414+# "black" = "#222222"
1515+# "blue" = "#66d9ef"
1616+# "green" = "#a6e22e"
1717+# "softorange" = "#f59762"
1818+# "orange" = "#fd971f"
1919+# "background" = "#191919"
2020+2121+{
2222+ "$schema" = "https://zed.dev/schema/themes/v0.2.0.json";
2323+ name = "Puppy Soda";
2424+ author = "roufpup";
2525+ themes = [
2626+ {
2727+ name = "Puppy Soda";
2828+ appearance = "dark";
2929+ style = {
3030+ "accents" = [
3131+ "#f92a72"
3232+ "#66d9ef"
3333+ "#AE81FF"
3434+ "f59762"
3535+ "a6e22e"
3636+ ];
3737+ "border" = "#444444"; # Borders around things like terminal tabs or tabs etc.
3838+ "border.variant" = "#444444"; # Border separating elements like the tabs and the editor
3939+ "border.focused" = "#191919"; # Border around elements like radio button in settings when they are focused
4040+ "border.selected" = "#d003e2"; # Unmodified
4141+ "border.transparent" = "#191919"; # Border around elements like radio buttons in settings
4242+ "border.disabled" = "#d003e2"; # Unmodified
4343+ "elevated_surface.background" = "#191919";
4444+ "surface.background" = "#444444"; # Scrollbar for example
4545+ "background" = "#212121"; # So only use i found this for is when u have a tool tip and it acts as background of the rust type for the tooltip
4646+ "element.background" = "#444444"; # Background for elements like in settings for drop down menu
4747+ "element.hover" = "#444444"; # Backgrounf for an element that is hovered like a hovered text
4848+ "element.active" = "#444444"; # Backgrounf for an element that is active like a selected section in the settings on the side
4949+ "element.selected" = "#444444"; # Color for selected element like a file in the file browser
5050+ "element.disabled" = "#444444"; # Color for an element like a turned off radio button in settings
5151+ "drop_target.background" = "#444444"; # Only place i found this is when dragging a file in the file tree and that's the background color for where it will drop
5252+ "ghost_element.background" = "#00000000"; # Background for elements that are just not selected and are staying on the UI like all kinds of buttons, for example repo or project button or fullscreen and context menu to show all options
5353+ "ghost_element.hover" = "#444444"; # Same as above but hover
5454+ "ghost_element.active" = "#75715e"; # Same as above but if u click on the button
5555+ "ghost_element.selected" = "#444444"; # Background for selected element when opening LSP options with Ctrl + Space
5656+ "ghost_element.disabled" = "#d003e2"; # Unmodified
5757+ "text" = "#cfcfc2"; # Just color for most of the text
5858+ "text.muted" = "#cfcfc2"; # Subtitle text color
5959+ "text.placeholder" = "#75715e"; # Text for example in searchbar
6060+ "text.disabled" = "#75715e"; # Text color for when it's disabled like the forward and backward button on the tab bar
6161+ "text.accent" = "#cfcfc2"; # Text when a button is selected+clicked like in settings
6262+ "icon" = "#cfcfc2"; # Text color for icons like minimize maximize buttons
6363+ "icon.muted" = "#cfcfc2"; # Text color for icon like minimize maximize buttons when u hover over them
6464+ "icon.disabled" = "#d003e2"; # Unmodified
6565+ "icon.placeholder" = "#d003e2"; # Unmodified
6666+ "icon.accent" = "#d003e2"; # Unmodified
6767+ "status_bar.background" = "#191919"; # Background for the bottom most bar
6868+ "title_bar.background" = "#191919"; # Background for the top most bar
6969+ "title_bar.inactive_background" = "#191919"; # Background for the top most bar when inactive for example settings window when inavtive
7070+ "toolbar.background" = "#191919"; # Background for the bar right under the tabs where the path of the file and other buttons are shown
7171+ "tab_bar.background" = "#191919"; # Background for the bar where the tabs are
7272+ "tab.inactive_background" = "#292929"; # Background for when a tab is not selected
7373+ "tab.active_background" = "#191919"; # Background for when a tab is selected
7474+ "search.match_background" = "#cfcfc259"; # Background for when searching for text and the found text is selected
7575+ "panel.background" = "#191919"; # Background for the pannels like the file browser
7676+ "panel.focused_border" = "#444444"; # The border color for the pannels like the file browser
7777+ "pane.focused_border" = "#191919"; # The only place i found this color being used is in the debug menu on the borders of the central console and the top border of the right terminal
7878+ "scrollbar.thumb.background" = "#44444466"; # Background for the scrollbar thumb
7979+ "scrollbar.thumb.hover_background" = "#75715e66"; # Background for the scrollbar thumb when clicked
8080+ "scrollbar.thumb.border" = "#444444"; # Border for the scrollbar thumb
8181+ "scrollbar.track.background" = "#00000000"; # Background for the whole track where the scrollbar is
8282+ "scrollbar.track.border" = "#44444480"; # Border for the whole track where the scrollbar is
8383+ "editor.foreground" = "#cfcfc2"; # Idk what this changes but should be text for the editor
8484+ "editor.background" = "#191919"; # Background for the editor
8585+ "editor.gutter.background" = "#191919"; # Backgrounf for the left side where the number of the lines and such are displayed
8686+ "editor.subheader.background" = "#191919"; # The only place i encountered this was when globally searching it's each results foldable header
8787+ "editor.active_line.background" = "#29292980"; # The backgrounf for the currently active line
8888+ "editor.highlighted_line.background" = "#44444499"; # The backgrounf for the higlighted items in line for example when doing a batch rename and such
8989+ "editor.line_number" = "#444444"; # Color for the numbers displayed next to each line
9090+ "editor.active_line_number" = "#cfcfc2"; # Same as above but for the currently active line
9191+ "editor.hover_line_number" = "#AE81FF"; # Unmodified
9292+ "editor.invisible" = "#75715e"; # The color for the little dots or other patteern that you can display for showing the whitespaces
9393+ "editor.wrap_guide" = "#d003e2"; # Unmodified
9494+ "editor.active_wrap_guide" = "#d003e2"; # Unmodified
9595+ "editor.document_highlight.read_background" = "#44444499"; # Background color for when higlighting things like brackets when you are inside of them or when selecting text and it finds the same text somewhere else
9696+ "editor.document_highlight.write_background" = "#44444499"; # Background color for when highlighting things possibly like variables, i found it to highlight arguments in nix
9797+ "editor.document_highlight.bracket_background" = "#44444499"; # Background color for higlighting brackets
9898+ "terminal.background" = "#191919"; # Background color of the terminal
9999+ "terminal.foreground" = "#cfcfc2"; # Text color of the terminal
100100+ "terminal.bright_foreground" = "#cfcfc2"; # Idk cuz the same as above
101101+ "terminal.dim_foreground" = "#444444"; # dim terminal text
102102+ "terminal.ansi.black" = "#222222"; # terminal black
103103+ "terminal.ansi.bright_black" = "#222222"; # same as above
104104+ "terminal.ansi.dim_black" = "#222222"; # same as above
105105+ "terminal.ansi.red" = "#f92a72"; # terminal red ( pink actually )
106106+ "terminal.ansi.bright_red" = "#f92a72"; # same as above
107107+ "terminal.ansi.dim_red" = "#f92a72"; # same as above
108108+ "terminal.ansi.green" = "#a6e22e"; # terminal green
109109+ "terminal.ansi.bright_green" = "#a6e22e"; # same as above
110110+ "terminal.ansi.dim_green" = "#a6e22e"; # same as above
111111+ "terminal.ansi.yellow" = "#E6DB74"; # terminal yellow
112112+ "terminal.ansi.bright_yellow" = "#E6DB74"; # same as above
113113+ "terminal.ansi.dim_yellow" = "#E6DB74"; # same as above
114114+ "terminal.ansi.blue" = "#AE81FF"; # terminal blue
115115+ "terminal.ansi.bright_blue" = "#AE81FF"; # same as above
116116+ "terminal.ansi.dim_blue" = "#AE81FF"; # same as above
117117+ "terminal.ansi.magenta" = "#f92a72"; # terminal magenta ( pink actually )
118118+ "terminal.ansi.bright_magenta" = "#f92a72"; # same as above
119119+ "terminal.ansi.dim_magenta" = "#f92a72"; # same as above
120120+ "terminal.ansi.cyan" = "#66d9ef"; # terminal cyan ( blue actually )
121121+ "terminal.ansi.bright_cyan" = "#66d9ef"; # same as above
122122+ "terminal.ansi.dim_cyan" = "#66d9ef"; # same as above
123123+ "terminal.ansi.white" = "#cfcfc2"; # terminal white
124124+ "terminal.ansi.bright_white" = "#cfcfc2"; # same as above
125125+ "terminal.ansi.dim_white" = "#cfcfc2"; # same as above
126126+ "link_text.hover" = "#f59762"; # Color for when holding down ctrl and hovering over text that can be a link
127127+ "conflict" = "#d003e2"; # Unmodified
128128+ "conflict.background" = "#d003e2"; # Unmodified
129129+ "conflict.border" = "#d003e2"; # Unmodified
130130+ "created" = "#a6e22e"; # Color for created files in git
131131+ "created.background" = "#d003e2"; # Unmodified
132132+ "created.border" = "#d003e2"; # Unmodified
133133+ "deleted" = "#f92a72"; # Color for deleted files in git
134134+ "deleted.background" = "#d003e2"; # Unmodified
135135+ "deleted.border" = "#d003e2"; # Unmodified
136136+ "error" = "#f92a72"; # Color for an error under text
137137+ "error.background" = "#191919"; # Background color for popup of error
138138+ "error.border" = "#f92a72"; # Border color for popup of error
139139+ "hidden" = "#cfcfc2"; # Unmodified
140140+ "hidden.background" = "#d003e2"; # Unmodified
141141+ "hidden.border" = "#d003e2"; # Unmodified
142142+ "hint" = "#AE81FF"; # Color for help KEEP THIS FOR NOW??? IT IS ALSO THE COLOR FOR THE BREAKPOINT FOR DEBUGGING, AND INLINE GIT MESSAGE??
143143+ "hint.background" = "#191919"; # Background color for help popup
144144+ "hint.border" = "#AE81FF"; # Border color for help popup
145145+ "ignored" = "#d003e2"; # Unmodified
146146+ "ignored.background" = "#d003e2"; # Unmodified
147147+ "ignored.border" = "#d003e2"; # Unmodified
148148+ "info" = "#cfcfc2"; # Color for information
149149+ "info.background" = "#191919"; # Background color for information popup
150150+ "info.border" = "#cfcfc2"; # Border color for information popup
151151+ "modified" = "#E6DB74"; # Color for modified file in git
152152+ "modified.background" = "#d003e2"; # Unmodified
153153+ "modified.border" = "#d003e2"; # Unmodified
154154+ "predictive" = "#d003e2"; # Unmodified
155155+ "predictive.background" = "#d003e2"; # Unmodified
156156+ "predictive.border" = "#d003e2"; # Unmodified
157157+ "renamed" = "#d003e2"; # Unmodified
158158+ "renamed.background" = "#d003e2"; # Unmodified
159159+ "renamed.border" = "#d003e2"; # Unmodified
160160+ "success" = "#a6e22e"; # The only place i found this was on the LSP menu for whether an LSP is succesfully running as well as diagnostic tab if there are no problems it would use this color for the icon
161161+ "success.background" = "#d003e2"; # Unmodified
162162+ "success.border" = "#d003e2"; # Unmodified
163163+ "unreachable" = "#d003e2"; # Unmodified
164164+ "unreachable.background" = "#d003e2"; # Unmodified
165165+ "unreachable.border" = "#d003e2"; # Unmodified
166166+ "warning" = "#E6DB74";
167167+ "warning.background" = "#191919";
168168+ "warning.border" = "#E6DB74";
169169+ "players" = [
170170+ {
171171+ cursor = "#cfcfc2";
172172+ background = "#d003e2"; # Unmodified
173173+ selection = "#cfcfc23d";
174174+ }
175175+ {
176176+ cursor = "#d003e2"; # Unmodified
177177+ background = "#d003e2"; # Unmodified
178178+ selection = "#d003e2"; # Unmodified
179179+ }
180180+ {
181181+ cursor = "#d003e2"; # Unmodified
182182+ background = "#d003e2"; # Unmodified
183183+ selection = "#d003e2"; # Unmodified
184184+ }
185185+ {
186186+ cursor = "#d003e2"; # Unmodified
187187+ background = "#d003e2"; # Unmodified
188188+ selection = "#d003e2"; # Unmodified
189189+ }
190190+ {
191191+ cursor = "#d003e2"; # Unmodified
192192+ background = "#d003e2"; # Unmodified
193193+ selection = "#d003e2"; # Unmodified
194194+ }
195195+ {
196196+ cursor = "#d003e2"; # Unmodified
197197+ background = "#d003e2"; # Unmodified
198198+ selection = "#d003e2"; # Unmodified
199199+ }
200200+ {
201201+ cursor = "#d003e2"; # Unmodified
202202+ background = "#d003e2"; # Unmodified
203203+ selection = "#d003e2"; # Unmodified
204204+ }
205205+ {
206206+ cursor = "#d003e2"; # Unmodified
207207+ background = "#d003e2"; # Unmodified
208208+ selection = "#d003e2"; # Unmodified
209209+ }
210210+ ];
211211+ "syntax" = {
212212+ attribute = {
213213+ color = "#AE81FF";
214214+ font_style = null;
215215+ font_weight = null;
216216+ };
217217+ "boolean" = {
218218+ color = "#f92a72";
219219+ font_style = null;
220220+ font_weight = null;
221221+ };
222222+ "comment" = {
223223+ color = "#75715e";
224224+ font_style = null;
225225+ font_weight = null;
226226+ };
227227+ "comment.doc" = {
228228+ color = "#75715e";
229229+ font_style = null;
230230+ font_weight = null;
231231+ };
232232+ "constant" = {
233233+ color = "#cfcfc2";
234234+ font_style = null;
235235+ font_weight = null;
236236+ };
237237+ "constructor" = {
238238+ color = "#AE81FF";
239239+ font_style = null;
240240+ font_weight = null;
241241+ };
242242+ "embedded" = {
243243+ color = "#d003e2"; # Unmodified
244244+ font_style = null;
245245+ font_weight = null;
246246+ };
247247+ "emphasis" = {
248248+ color = "#fd971f"; # Unmodified
249249+ font_style = null;
250250+ font_weight = null;
251251+ };
252252+ "emphasis.strong" = {
253253+ color = "#d003e2"; # Unmodified
254254+ font_style = null;
255255+ font_weight = 700;
256256+ };
257257+ "enum" = {
258258+ color = "#AE81FF";
259259+ font_style = null;
260260+ font_weight = null;
261261+ };
262262+ "function" = {
263263+ color = "#a6e22e";
264264+ font_style = null;
265265+ font_weight = null;
266266+ };
267267+ "hint" = {
268268+ color = "#cfcfc2";
269269+ font_style = null;
270270+ font_weight = null;
271271+ };
272272+ "keyword" = {
273273+ color = "#f92a72";
274274+ font_style = null;
275275+ font_weight = null;
276276+ };
277277+ "label" = {
278278+ color = "#E6DB74";
279279+ font_style = null;
280280+ font_weight = null;
281281+ };
282282+ "link_text" = {
283283+ color = "#E6DB74";
284284+ font_style = "italic";
285285+ font_weight = null;
286286+ };
287287+ "link_uri" = {
288288+ color = "#fd971f";
289289+ font_style = null;
290290+ font_weight = null;
291291+ };
292292+ "namespace" = {
293293+ color = "#f92a72";
294294+ font_style = null;
295295+ font_weight = null;
296296+ };
297297+ "number" = {
298298+ color = "#cfcfc2";
299299+ font_style = null;
300300+ font_weight = null;
301301+ };
302302+ "operator" = {
303303+ color = "#f92a72";
304304+ font_style = null;
305305+ font_weight = null;
306306+ };
307307+ "predictive" = {
308308+ color = "#d003e2"; # Unmodified
309309+ font_style = "italic";
310310+ font_weight = null;
311311+ };
312312+ "preproc" = {
313313+ color = "#d003e2"; # Unmodified
314314+ font_style = null;
315315+ font_weight = null;
316316+ };
317317+ "primary" = {
318318+ color = "#d003e2"; # Unmodified
319319+ font_style = null;
320320+ font_weight = null;
321321+ };
322322+ "property" = {
323323+ color = "#cfcfc2";
324324+ font_style = null;
325325+ font_weight = null;
326326+ };
327327+ "punctuation" = {
328328+ color = "#75715e";
329329+ font_style = null;
330330+ font_weight = null;
331331+ };
332332+ "punctuation.bracket" = {
333333+ color = "#75715e";
334334+ font_style = null;
335335+ font_weight = null;
336336+ };
337337+ "punctuation.delimiter" = {
338338+ color = "#cfcfc2";
339339+ font_style = null;
340340+ font_weight = null;
341341+ };
342342+ "punctuation.list_marker" = {
343343+ color = "#d003e2"; # Unmodified
344344+ font_style = null;
345345+ font_weight = null;
346346+ };
347347+ "punctuation.markup" = {
348348+ color = "#fd971f"; # The color of a lot of markdown symbols like - and `
349349+ font_style = null;
350350+ font_weight = null;
351351+ };
352352+ "punctuation.special" = {
353353+ color = "#75715e"; # Unmodified
354354+ font_style = null;
355355+ font_weight = null;
356356+ };
357357+ "selector" = {
358358+ color = "#d003e2"; # Unmodified
359359+ font_style = null;
360360+ font_weight = null;
361361+ };
362362+ "selector.pseudo" = {
363363+ color = "#d003e2"; # Unmodified
364364+ font_style = null;
365365+ font_weight = null;
366366+ };
367367+ "string" = {
368368+ color = "#E6DB74";
369369+ font_style = null;
370370+ font_weight = null;
371371+ };
372372+ "string.escape" = {
373373+ color = "#AE81FF";
374374+ font_style = null;
375375+ font_weight = null;
376376+ };
377377+ "string.regex" = {
378378+ color = "#d003e2"; # Unmodified
379379+ font_style = null;
380380+ font_weight = null;
381381+ };
382382+ "string.special" = {
383383+ color = "#f59762"; # Color of special strings like paths
384384+ font_style = null;
385385+ font_weight = null;
386386+ };
387387+ "string.special.symbol" = {
388388+ color = "#d003e2"; # Unmodified
389389+ font_style = null;
390390+ font_weight = null;
391391+ };
392392+ "tag" = {
393393+ color = "#d003e2"; # Unmodified
394394+ font_style = null;
395395+ font_weight = null;
396396+ };
397397+ "text.literal" = {
398398+ color = "#fd971f"; # The place i found this gets affect is for example when you put `<example>` in a mark down file
399399+ font_style = null;
400400+ font_weight = null;
401401+ };
402402+ "title" = {
403403+ color = "#fd971f"; # The color of text when we have for example header titles in markdown
404404+ font_style = null;
405405+ font_weight = 700;
406406+ };
407407+ "type" = {
408408+ color = "#AE81FF";
409409+ font_style = null;
410410+ font_weight = null;
411411+ };
412412+ "variable" = {
413413+ color = "#bfbdb6ff";
414414+ font_style = null;
415415+ font_weight = null;
416416+ };
417417+ "variant" = {
418418+ color = "#cfcfc2";
419419+ font_style = null;
420420+ font_weight = null;
421421+ };
422422+ };
423423+ };
424424+ }
425425+ ];
426426+}
···11+/*
22+ This file is provided under the MIT licence:
33+44+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55+66+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
77+88+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
99+*/
1010+# Generated by npins. Do not modify; will be overwritten regularly
1111+let
1212+ # Backwards-compatibly make something that previously didn't take any arguments take some
1313+ # The function must return an attrset, and will unfortunately be eagerly evaluated
1414+ # Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments
1515+ mkFunctor =
1616+ fn:
1717+ let
1818+ e = builtins.tryEval (fn { });
1919+ in
2020+ (if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; };
2121+2222+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
2323+ range =
2424+ first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
2525+2626+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
2727+ stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
2828+2929+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
3030+ stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
3131+ concatStrings = builtins.concatStringsSep "";
3232+3333+ # If the environment variable NPINS_OVERRIDE_${name} is set, then use
3434+ # the path directly as opposed to the fetched source.
3535+ # (Taken from Niv for compatibility)
3636+ mayOverride =
3737+ name: path:
3838+ let
3939+ envVarName = "NPINS_OVERRIDE_${saneName}";
4040+ saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
4141+ ersatz = builtins.getEnv envVarName;
4242+ in
4343+ if ersatz == "" then
4444+ path
4545+ else
4646+ # this turns the string into an actual Nix path (for both absolute and
4747+ # relative paths)
4848+ builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
4949+ if builtins.substring 0 1 ersatz == "/" then
5050+ /. + ersatz
5151+ else
5252+ /. + builtins.getEnv "PWD" + "/${ersatz}"
5353+ );
5454+5555+ mkSource =
5656+ name: spec:
5757+ {
5858+ pkgs ? null,
5959+ }:
6060+ assert spec ? type;
6161+ let
6262+ # Unify across builtin and pkgs fetchers.
6363+ # `fetchGit` requires a wrapper because of slight API differences.
6464+ fetchers =
6565+ if pkgs == null then
6666+ {
6767+ inherit (builtins) fetchTarball fetchurl;
6868+ # For some fucking reason, fetchGit has a different signature than the other builtin fetchers …
6969+ fetchGit = args: (builtins.fetchGit args).outPath;
7070+ }
7171+ else
7272+ {
7373+ fetchTarball =
7474+ {
7575+ url,
7676+ sha256,
7777+ }:
7878+ pkgs.fetchzip {
7979+ inherit url sha256;
8080+ extension = "tar";
8181+ };
8282+ inherit (pkgs) fetchurl;
8383+ fetchGit =
8484+ {
8585+ url,
8686+ submodules,
8787+ rev,
8888+ name,
8989+ narHash,
9090+ }:
9191+ pkgs.fetchgit {
9292+ inherit url rev name;
9393+ fetchSubmodules = submodules;
9494+ hash = narHash;
9595+ };
9696+ };
9797+9898+ # Dispatch to the correct code path based on the type
9999+ path =
100100+ if spec.type == "Git" then
101101+ mkGitSource fetchers spec
102102+ else if spec.type == "GitRelease" then
103103+ mkGitSource fetchers spec
104104+ else if spec.type == "PyPi" then
105105+ mkPyPiSource fetchers spec
106106+ else if spec.type == "Channel" then
107107+ mkChannelSource fetchers spec
108108+ else if spec.type == "Tarball" then
109109+ mkTarballSource fetchers spec
110110+ else if spec.type == "Container" then
111111+ mkContainerSource pkgs spec
112112+ else
113113+ builtins.throw "Unknown source type ${spec.type}";
114114+ in
115115+ spec // { outPath = mayOverride name path; };
116116+117117+ mkGitSource =
118118+ {
119119+ fetchTarball,
120120+ fetchGit,
121121+ ...
122122+ }:
123123+ {
124124+ repository,
125125+ revision,
126126+ url ? null,
127127+ submodules,
128128+ hash,
129129+ ...
130130+ }:
131131+ assert repository ? type;
132132+ # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
133133+ # In the latter case, there we will always be an url to the tarball
134134+ if url != null && !submodules then
135135+ fetchTarball {
136136+ inherit url;
137137+ sha256 = hash;
138138+ }
139139+ else
140140+ let
141141+ url =
142142+ if repository.type == "Git" then
143143+ repository.url
144144+ else if repository.type == "GitHub" then
145145+ "https://github.com/${repository.owner}/${repository.repo}.git"
146146+ else if repository.type == "GitLab" then
147147+ "${repository.server}/${repository.repo_path}.git"
148148+ else if repository.type == "Forgejo" then
149149+ "${repository.server}/${repository.owner}/${repository.repo}.git"
150150+ else
151151+ throw "Unrecognized repository type ${repository.type}";
152152+ urlToName =
153153+ url: rev:
154154+ let
155155+ matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
156156+157157+ short = builtins.substring 0 7 rev;
158158+159159+ appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
160160+ in
161161+ "${if matched == null then "source" else builtins.head matched}${appendShort}";
162162+ name = urlToName url revision;
163163+ in
164164+ fetchGit {
165165+ rev = revision;
166166+ narHash = hash;
167167+168168+ inherit name submodules url;
169169+ };
170170+171171+ mkPyPiSource =
172172+ { fetchurl, ... }:
173173+ {
174174+ url,
175175+ hash,
176176+ ...
177177+ }:
178178+ fetchurl {
179179+ inherit url;
180180+ sha256 = hash;
181181+ };
182182+183183+ mkChannelSource =
184184+ { fetchTarball, ... }:
185185+ {
186186+ url,
187187+ hash,
188188+ ...
189189+ }:
190190+ fetchTarball {
191191+ inherit url;
192192+ sha256 = hash;
193193+ };
194194+195195+ mkTarballSource =
196196+ { fetchTarball, ... }:
197197+ {
198198+ url,
199199+ locked_url ? url,
200200+ hash,
201201+ ...
202202+ }:
203203+ fetchTarball {
204204+ url = locked_url;
205205+ sha256 = hash;
206206+ };
207207+208208+ mkContainerSource =
209209+ pkgs:
210210+ {
211211+ image_name,
212212+ image_tag,
213213+ image_digest,
214214+ ...
215215+ }:
216216+ if pkgs == null then
217217+ builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers"
218218+ else
219219+ pkgs.dockerTools.pullImage {
220220+ imageName = image_name;
221221+ imageDigest = image_digest;
222222+ finalImageTag = image_tag;
223223+ };
224224+in
225225+mkFunctor (
226226+ {
227227+ input ? ./sources.json,
228228+ }:
229229+ let
230230+ data =
231231+ if builtins.isPath input then
232232+ # while `readFile` will throw an error anyways if the path doesn't exist,
233233+ # we still need to check beforehand because *our* error can be caught but not the one from the builtin
234234+ # *piegames sighs*
235235+ if builtins.pathExists input then
236236+ builtins.fromJSON (builtins.readFile input)
237237+ else
238238+ throw "Input path ${toString input} does not exist"
239239+ else if builtins.isAttrs input then
240240+ input
241241+ else
242242+ throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset";
243243+ version = data.version;
244244+ in
245245+ if version == 7 then
246246+ builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins
247247+ else
248248+ throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
249249+)