···1{ lib, ... }:
2rec {
3 /*
4- Compute the fixed point of the given function `f`, which is usually an
5- attribute set that expects its final, non-recursive representation as an
6- argument:
000000070000000008 ```
9- f = self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; }
000000000010 ```
1112- Nix evaluates this recursion until all references to `self` have been
13- resolved. At that point, the final result is returned and `f x = x` holds:
0000000140000015 ```
000016 nix-repl> fix f
17 { bar = "bar"; foo = "foo"; foobar = "foobar"; }
18 ```
00001920 Type: fix :: (a -> a) -> a
2122- See https://en.wikipedia.org/wiki/Fixed-point_combinator for further
23- details.
000024 */
25 fix = f: let x = f x; in x;
26
···1{ lib, ... }:
2rec {
3 /*
4+ `fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
5+6+ `f` must be a lazy function.
7+ This means that `x` must be a value that can be partially evaluated,
8+ such as an attribute set, a list, or a function.
9+ This way, `f` can use one part of `x` to compute another part.
10+11+ **Relation to syntactic recursion**
12+13+ This section explains `fix` by refactoring from syntactic recursion to a call of `fix` instead.
1415+ For context, Nix lets you define attributes in terms of other attributes syntactically using the [`rec { }` syntax](https://nixos.org/manual/nix/stable/language/constructs.html#recursive-sets).
16+17+ ```nix
18+ nix-repl> rec {
19+ foo = "foo";
20+ bar = "bar";
21+ foobar = foo + bar;
22+ }
23+ { bar = "bar"; foo = "foo"; foobar = "foobar"; }
24 ```
25+26+ This is convenient when constructing a value to pass to a function for example,
27+ but an equivalent effect can be achieved with the `let` binding syntax:
28+29+ ```nix
30+ nix-repl> let self = {
31+ foo = "foo";
32+ bar = "bar";
33+ foobar = self.foo + self.bar;
34+ }; in self
35+ { bar = "bar"; foo = "foo"; foobar = "foobar"; }
36 ```
3738+ But in general you can get more reuse out of `let` bindings by refactoring them to a function.
39+40+ ```nix
41+ nix-repl> f = self: {
42+ foo = "foo";
43+ bar = "bar";
44+ foobar = self.foo + self.bar;
45+ }
46+ ```
4748+ This is where `fix` comes in, it contains the syntactic that's not in `f` anymore.
49+50+ ```nix
51+ nix-repl> fix = f:
52+ let self = f self; in self;
53 ```
54+55+ By applying `fix` we get the final result.
56+57+ ```nix
58 nix-repl> fix f
59 { bar = "bar"; foo = "foo"; foobar = "foobar"; }
60 ```
61+62+ Such a refactored `f` using `fix` is not useful by itself.
63+ See [`extends`](#function-library-lib.fixedPoints.extends) for an example use case.
64+ There `self` is also often called `final`.
6566 Type: fix :: (a -> a) -> a
6768+ Example:
69+ fix (self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; })
70+ => { bar = "bar"; foo = "foo"; foobar = "foobar"; }
71+72+ fix (self: [ 1 2 (elemAt self 0 + elemAt self 1) ])
73+ => [ 1 2 3 ]
74 */
75 fix = f: let x = f x; in x;
76
···13, nativeImageBuildArgs ? [
14 (lib.optionalString stdenv.isDarwin "-H:-CheckToolchain")
15 "-H:Name=${executable}"
016 "--verbose"
17 ]
18 # Extra arguments to be passed to the native-image
···13, nativeImageBuildArgs ? [
14 (lib.optionalString stdenv.isDarwin "-H:-CheckToolchain")
15 "-H:Name=${executable}"
16+ "-march=compatibility"
17 "--verbose"
18 ]
19 # Extra arguments to be passed to the native-image
···1+# This file tracks the Clojure tools version required by babashka.
2+# See https://github.com/borkdude/deps.clj#deps_clj_tools_version for background.
3+# The `updateScript` provided in default.nix takes care of keeping it in sync, as well.
4+{ clojure
5+, fetchurl
6+}:
7+clojure.overrideAttrs (previousAttrs: {
8+ pname = "babashka-clojure-tools";
9+ version = "1.11.1.1403";
10+11+ src = fetchurl {
12+ url = previousAttrs.src.url;
13+ hash = "sha256-bVNHEEzpPanPF8pfDP51d13bxv9gZGzqczNmFQOk6zI=";
14+ };
15+})
···6, writeScript
7}:
89-buildGraalvmNativeImage rec {
10- pname = "babashka-unwrapped";
11- version = "1.3.184";
000000001213- src = fetchurl {
14- url = "https://github.com/babashka/babashka/releases/download/v${version}/babashka-${version}-standalone.jar";
15- sha256 = "sha256-O3pLELYmuuB+Bf1vHTWQ+u7Ymi3qYiMRpCwvEq+GeBQ=";
16- };
1718- graalvmDrv = graalvmCEPackages.graalvm-ce;
1920- executable = "bb";
000002122- nativeBuildInputs = [ removeReferencesTo ];
2324- extraNativeImageBuildArgs = [
25- "-H:+ReportExceptionStackTraces"
26- "--no-fallback"
27- "--native-image-info"
28- "--enable-preview"
29- ];
3031- doInstallCheck = true;
000003233- installCheckPhase = ''
34- $out/bin/bb --version | grep '${version}'
35- $out/bin/bb '(+ 1 2)' | grep '3'
36- $out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | grep '[1 2]'
37- '';
3839- # As of v1.2.174, this will remove references to ${graalvmDrv}/conf/chronology,
40- # not sure the implications of this but this file is not available in
41- # graalvm-ce anyway.
42- postInstall = ''
43- remove-references-to -t ${graalvmDrv} $out/bin/${executable}
44- '';
4546- passthru.updateScript = writeScript "update-babashka" ''
47- #!/usr/bin/env nix-shell
48- #!nix-shell -i bash -p curl common-updater-scripts jq
04950- set -euo pipefail
0005152- readonly latest_version="$(curl \
53- ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
54- -s "https://api.github.com/repos/babashka/babashka/releases/latest" \
55- | jq -r '.tag_name')"
05657- # v0.6.2 -> 0.6.2
58- update-source-version babashka "''${latest_version/v/}"
59- '';
6061- meta = with lib; {
62- description = "A Clojure babushka for the grey areas of Bash";
63- longDescription = ''
64- The main idea behind babashka is to leverage Clojure in places where you
65- would be using bash otherwise.
6667- As one user described it:
6869- I’m quite at home in Bash most of the time, but there’s a substantial
70- grey area of things that are too complicated to be simple in bash, but
71- too simple to be worth writing a clj/s script for. Babashka really
72- seems to hit the sweet spot for those cases.
7374- Goals:
7576- - Low latency Clojure scripting alternative to JVM Clojure.
77- - Easy installation: grab the self-contained binary and run. No JVM needed.
78- - Familiarity and portability:
79- - Scripts should be compatible with JVM Clojure as much as possible
80- - Scripts should be platform-independent as much as possible. Babashka
81- offers support for linux, macOS and Windows.
82- - Allow interop with commonly used classes like java.io.File and System
83- - Multi-threading support (pmap, future, core.async)
84- - Batteries included (tools.cli, cheshire, ...)
85- - Library support via popular tools like the clojure CLI
86- '';
87- homepage = "https://github.com/babashka/babashka";
88- changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md";
89- sourceProvenance = with sourceTypes; [ binaryBytecode ];
90- license = licenses.epl10;
91- maintainers = with maintainers; [
92- bandresen
93- bhougland
94- DerGuteMoritz
95- jlesquembre
96- thiagokokada
97- ];
098 };
99-}
0
···6, writeScript
7}:
89+let
10+ babashka-unwrapped = buildGraalvmNativeImage rec {
11+ pname = "babashka-unwrapped";
12+ version = "1.3.184";
13+14+ src = fetchurl {
15+ url = "https://github.com/babashka/babashka/releases/download/v${version}/babashka-${version}-standalone.jar";
16+ sha256 = "sha256-O3pLELYmuuB+Bf1vHTWQ+u7Ymi3qYiMRpCwvEq+GeBQ=";
17+ };
18+19+ graalvmDrv = graalvmCEPackages.graalvm-ce;
2021+ executable = "bb";
0002223+ nativeBuildInputs = [ removeReferencesTo ];
2425+ extraNativeImageBuildArgs = [
26+ "-H:+ReportExceptionStackTraces"
27+ "--no-fallback"
28+ "--native-image-info"
29+ "--enable-preview"
30+ ];
3132+ doInstallCheck = true;
3334+ installCheckPhase = ''
35+ $out/bin/bb --version | grep '${version}'
36+ $out/bin/bb '(+ 1 2)' | grep '3'
37+ $out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | grep '[1 2]'
38+ '';
03940+ # As of v1.2.174, this will remove references to ${graalvmDrv}/conf/chronology,
41+ # not sure the implications of this but this file is not available in
42+ # graalvm-ce anyway.
43+ postInstall = ''
44+ remove-references-to -t ${graalvmDrv} $out/bin/${executable}
45+ '';
4647+ passthru.updateScript = writeScript "update-babashka" ''
48+ #!/usr/bin/env nix-shell
49+ #!nix-shell -i bash -p curl common-updater-scripts jq libarchive
005051+ set -euo pipefail
52+ shopt -s inherit_errexit
00005354+ latest_version="$(curl \
55+ ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
56+ -fsL "https://api.github.com/repos/babashka/babashka/releases/latest" \
57+ | jq -r '.tag_name')"
5859+ if [ "$(update-source-version babashka-unwrapped "''${latest_version/v/}" --print-changes)" = "[]" ]; then
60+ # no need to update babashka.clojure-tools when babashka-unwrapped wasn't updated
61+ exit 0
62+ fi
6364+ clojure_tools_version=$(curl \
65+ -fsL \
66+ "https://github.com/babashka/babashka/releases/download/''${latest_version}/babashka-''${latest_version/v/}-standalone.jar" \
67+ | bsdtar -qxOf - borkdude/deps.clj \
68+ | ${babashka-unwrapped}/bin/bb -I -o -e "(or (some->> *input* (filter #(= '(def version) (take 2 %))) first last last last) (throw (ex-info \"Couldn't find expected '(def version ...)' form in 'borkdude/deps.clj'.\" {})))")
6970+ update-source-version babashka.clojure-tools "$clojure_tools_version" \
71+ --file="pkgs/development/interpreters/babashka/clojure-tools.nix"
72+ '';
7374+ meta = with lib; {
75+ description = "A Clojure babushka for the grey areas of Bash";
76+ longDescription = ''
77+ The main idea behind babashka is to leverage Clojure in places where you
78+ would be using bash otherwise.
7980+ As one user described it:
8182+ I’m quite at home in Bash most of the time, but there’s a substantial
83+ grey area of things that are too complicated to be simple in bash, but
84+ too simple to be worth writing a clj/s script for. Babashka really
85+ seems to hit the sweet spot for those cases.
8687+ Goals:
8889+ - Low latency Clojure scripting alternative to JVM Clojure.
90+ - Easy installation: grab the self-contained binary and run. No JVM needed.
91+ - Familiarity and portability:
92+ - Scripts should be compatible with JVM Clojure as much as possible
93+ - Scripts should be platform-independent as much as possible. Babashka
94+ offers support for linux, macOS and Windows.
95+ - Allow interop with commonly used classes like java.io.File and System
96+ - Multi-threading support (pmap, future, core.async)
97+ - Batteries included (tools.cli, cheshire, ...)
98+ - Library support via popular tools like the clojure CLI
99+ '';
100+ homepage = "https://github.com/babashka/babashka";
101+ changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md";
102+ sourceProvenance = with sourceTypes; [ binaryBytecode ];
103+ license = licenses.epl10;
104+ maintainers = with maintainers; [
105+ bandresen
106+ bhougland
107+ DerGuteMoritz
108+ jlesquembre
109+ thiagokokada
110+ ];
111+ };
112 };
113+in
114+babashka-unwrapped
···268269@cli.command("update-all")
270def update_all():
271- repos = Parallel(n_jobs=2, require='sharedmem')(delayed(get_electron_info)(major_version) for major_version in range(27, 24, -1))
272 out = {n[0]: n[1] for n in Parallel(n_jobs=2, require='sharedmem')(delayed(get_update)(repo) for repo in repos)}
273274 with open('info.json', 'w') as f:
···268269@cli.command("update-all")
270def update_all():
271+ repos = Parallel(n_jobs=2, require='sharedmem')(delayed(get_electron_info)(major_version) for major_version in range(28, 24, -1))
272 out = {n[0]: n[1] for n in Parallel(n_jobs=2, require='sharedmem')(delayed(get_update)(repo) for repo in repos)}
273274 with open('info.json', 'w') as f:
···781 sane-backends-git = sane-backends; # Added 2021-02-19
782 scantailor = scantailor-advanced; # Added 2022-05-26
783 sdlmame = throw "'sdlmame' has been renamed to/replaced by 'mame'"; # Converted to throw 2023-09-10
0784 session-desktop-appimage = session-desktop;
785 sequoia = sequoia-sq; # Added 2023-06-26
786 sexp = sexpp; # Added 2023-07-03
···926 win-qemu = throw "'win-qemu' has been replaced by 'win-virtio'"; # Added 2023-08-16
927 win-signed-gplpv-drivers = throw "win-signed-gplpv-drivers has been removed from nixpkgs, as it's unmaintained: https://help.univention.com/t/installing-signed-gplpv-drivers/21828"; # Added 2023-08-17
928 wlroots_0_14 = throw "'wlroots_0_14' has been removed in favor of newer versions"; # Added 2023-07-29
00929 wormhole-rs = magic-wormhole-rs; # Added 2022-05-30. preserve, reason: Arch package name, main binary name
930 wmii_hg = wmii;
931 wxGTK30 = throw "wxGTK30 has been removed from nixpkgs as it has reached end of life"; # Added 2023-03-22
···781 sane-backends-git = sane-backends; # Added 2021-02-19
782 scantailor = scantailor-advanced; # Added 2022-05-26
783 sdlmame = throw "'sdlmame' has been renamed to/replaced by 'mame'"; # Converted to throw 2023-09-10
784+ searx = throw "'searx' has been removed as it is unmaintained. Please switch to searxng"; # Added 2023-10-03
785 session-desktop-appimage = session-desktop;
786 sequoia = sequoia-sq; # Added 2023-06-26
787 sexp = sexpp; # Added 2023-07-03
···927 win-qemu = throw "'win-qemu' has been replaced by 'win-virtio'"; # Added 2023-08-16
928 win-signed-gplpv-drivers = throw "win-signed-gplpv-drivers has been removed from nixpkgs, as it's unmaintained: https://help.univention.com/t/installing-signed-gplpv-drivers/21828"; # Added 2023-08-17
929 wlroots_0_14 = throw "'wlroots_0_14' has been removed in favor of newer versions"; # Added 2023-07-29
930+ wordpress6_1 = throw "'wordpress6_1' has been removed in favor of the latest version"; # Added 2023-10-10
931+ wordpress6_2 = throw "'wordpress6_2' has been removed in favor of the latest version"; # Added 2023-10-10
932 wormhole-rs = magic-wormhole-rs; # Added 2022-05-30. preserve, reason: Arch package name, main binary name
933 wmii_hg = wmii;
934 wxGTK30 = throw "wxGTK30 has been removed from nixpkgs as it has reached end of life"; # Added 2023-03-22