···11{ lib, ... }:
22rec {
33 /*
44- Compute the fixed point of the given function `f`, which is usually an
55- attribute set that expects its final, non-recursive representation as an
66- argument:
44+ `fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
55+66+ `f` must be a lazy function.
77+ This means that `x` must be a value that can be partially evaluated,
88+ such as an attribute set, a list, or a function.
99+ This way, `f` can use one part of `x` to compute another part.
1010+1111+ **Relation to syntactic recursion**
1212+1313+ This section explains `fix` by refactoring from syntactic recursion to a call of `fix` instead.
7141515+ 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).
1616+1717+ ```nix
1818+ nix-repl> rec {
1919+ foo = "foo";
2020+ bar = "bar";
2121+ foobar = foo + bar;
2222+ }
2323+ { bar = "bar"; foo = "foo"; foobar = "foobar"; }
824 ```
99- f = self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; }
2525+2626+ This is convenient when constructing a value to pass to a function for example,
2727+ but an equivalent effect can be achieved with the `let` binding syntax:
2828+2929+ ```nix
3030+ nix-repl> let self = {
3131+ foo = "foo";
3232+ bar = "bar";
3333+ foobar = self.foo + self.bar;
3434+ }; in self
3535+ { bar = "bar"; foo = "foo"; foobar = "foobar"; }
1036 ```
11371212- Nix evaluates this recursion until all references to `self` have been
1313- resolved. At that point, the final result is returned and `f x = x` holds:
3838+ But in general you can get more reuse out of `let` bindings by refactoring them to a function.
3939+4040+ ```nix
4141+ nix-repl> f = self: {
4242+ foo = "foo";
4343+ bar = "bar";
4444+ foobar = self.foo + self.bar;
4545+ }
4646+ ```
14474848+ This is where `fix` comes in, it contains the syntactic that's not in `f` anymore.
4949+5050+ ```nix
5151+ nix-repl> fix = f:
5252+ let self = f self; in self;
1553 ```
5454+5555+ By applying `fix` we get the final result.
5656+5757+ ```nix
1658 nix-repl> fix f
1759 { bar = "bar"; foo = "foo"; foobar = "foobar"; }
1860 ```
6161+6262+ Such a refactored `f` using `fix` is not useful by itself.
6363+ See [`extends`](#function-library-lib.fixedPoints.extends) for an example use case.
6464+ There `self` is also often called `final`.
19652066 Type: fix :: (a -> a) -> a
21672222- See https://en.wikipedia.org/wiki/Fixed-point_combinator for further
2323- details.
6868+ Example:
6969+ fix (self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; })
7070+ => { bar = "bar"; foo = "foo"; foobar = "foobar"; }
7171+7272+ fix (self: [ 1 2 (elemAt self 0 + elemAt self 1) ])
7373+ => [ 1 2 3 ]
2474 */
2575 fix = f: let x = f x; in x;
2676
···11+# This file tracks the Clojure tools version required by babashka.
22+# See https://github.com/borkdude/deps.clj#deps_clj_tools_version for background.
33+# The `updateScript` provided in default.nix takes care of keeping it in sync, as well.
44+{ clojure
55+, fetchurl
66+}:
77+clojure.overrideAttrs (previousAttrs: {
88+ pname = "babashka-clojure-tools";
99+ version = "1.11.1.1403";
1010+1111+ src = fetchurl {
1212+ url = previousAttrs.src.url;
1313+ hash = "sha256-bVNHEEzpPanPF8pfDP51d13bxv9gZGzqczNmFQOk6zI=";
1414+ };
1515+})
···66, writeScript
77}:
8899-buildGraalvmNativeImage rec {
1010- pname = "babashka-unwrapped";
1111- version = "1.3.184";
99+let
1010+ babashka-unwrapped = buildGraalvmNativeImage rec {
1111+ pname = "babashka-unwrapped";
1212+ version = "1.3.184";
1313+1414+ src = fetchurl {
1515+ url = "https://github.com/babashka/babashka/releases/download/v${version}/babashka-${version}-standalone.jar";
1616+ sha256 = "sha256-O3pLELYmuuB+Bf1vHTWQ+u7Ymi3qYiMRpCwvEq+GeBQ=";
1717+ };
1818+1919+ graalvmDrv = graalvmCEPackages.graalvm-ce;
12201313- src = fetchurl {
1414- url = "https://github.com/babashka/babashka/releases/download/v${version}/babashka-${version}-standalone.jar";
1515- sha256 = "sha256-O3pLELYmuuB+Bf1vHTWQ+u7Ymi3qYiMRpCwvEq+GeBQ=";
1616- };
2121+ executable = "bb";
17221818- graalvmDrv = graalvmCEPackages.graalvm-ce;
2323+ nativeBuildInputs = [ removeReferencesTo ];
19242020- executable = "bb";
2525+ extraNativeImageBuildArgs = [
2626+ "-H:+ReportExceptionStackTraces"
2727+ "--no-fallback"
2828+ "--native-image-info"
2929+ "--enable-preview"
3030+ ];
21312222- nativeBuildInputs = [ removeReferencesTo ];
3232+ doInstallCheck = true;
23332424- extraNativeImageBuildArgs = [
2525- "-H:+ReportExceptionStackTraces"
2626- "--no-fallback"
2727- "--native-image-info"
2828- "--enable-preview"
2929- ];
3434+ installCheckPhase = ''
3535+ $out/bin/bb --version | grep '${version}'
3636+ $out/bin/bb '(+ 1 2)' | grep '3'
3737+ $out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | grep '[1 2]'
3838+ '';
30393131- doInstallCheck = true;
4040+ # As of v1.2.174, this will remove references to ${graalvmDrv}/conf/chronology,
4141+ # not sure the implications of this but this file is not available in
4242+ # graalvm-ce anyway.
4343+ postInstall = ''
4444+ remove-references-to -t ${graalvmDrv} $out/bin/${executable}
4545+ '';
32463333- installCheckPhase = ''
3434- $out/bin/bb --version | grep '${version}'
3535- $out/bin/bb '(+ 1 2)' | grep '3'
3636- $out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | grep '[1 2]'
3737- '';
4747+ passthru.updateScript = writeScript "update-babashka" ''
4848+ #!/usr/bin/env nix-shell
4949+ #!nix-shell -i bash -p curl common-updater-scripts jq libarchive
38503939- # As of v1.2.174, this will remove references to ${graalvmDrv}/conf/chronology,
4040- # not sure the implications of this but this file is not available in
4141- # graalvm-ce anyway.
4242- postInstall = ''
4343- remove-references-to -t ${graalvmDrv} $out/bin/${executable}
4444- '';
5151+ set -euo pipefail
5252+ shopt -s inherit_errexit
45534646- passthru.updateScript = writeScript "update-babashka" ''
4747- #!/usr/bin/env nix-shell
4848- #!nix-shell -i bash -p curl common-updater-scripts jq
5454+ latest_version="$(curl \
5555+ ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
5656+ -fsL "https://api.github.com/repos/babashka/babashka/releases/latest" \
5757+ | jq -r '.tag_name')"
49585050- set -euo pipefail
5959+ if [ "$(update-source-version babashka-unwrapped "''${latest_version/v/}" --print-changes)" = "[]" ]; then
6060+ # no need to update babashka.clojure-tools when babashka-unwrapped wasn't updated
6161+ exit 0
6262+ fi
51635252- readonly latest_version="$(curl \
5353- ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
5454- -s "https://api.github.com/repos/babashka/babashka/releases/latest" \
5555- | jq -r '.tag_name')"
6464+ clojure_tools_version=$(curl \
6565+ -fsL \
6666+ "https://github.com/babashka/babashka/releases/download/''${latest_version}/babashka-''${latest_version/v/}-standalone.jar" \
6767+ | bsdtar -qxOf - borkdude/deps.clj \
6868+ | ${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'.\" {})))")
56695757- # v0.6.2 -> 0.6.2
5858- update-source-version babashka "''${latest_version/v/}"
5959- '';
7070+ update-source-version babashka.clojure-tools "$clojure_tools_version" \
7171+ --file="pkgs/development/interpreters/babashka/clojure-tools.nix"
7272+ '';
60736161- meta = with lib; {
6262- description = "A Clojure babushka for the grey areas of Bash";
6363- longDescription = ''
6464- The main idea behind babashka is to leverage Clojure in places where you
6565- would be using bash otherwise.
7474+ meta = with lib; {
7575+ description = "A Clojure babushka for the grey areas of Bash";
7676+ longDescription = ''
7777+ The main idea behind babashka is to leverage Clojure in places where you
7878+ would be using bash otherwise.
66796767- As one user described it:
8080+ As one user described it:
68816969- I’m quite at home in Bash most of the time, but there’s a substantial
7070- grey area of things that are too complicated to be simple in bash, but
7171- too simple to be worth writing a clj/s script for. Babashka really
7272- seems to hit the sweet spot for those cases.
8282+ I’m quite at home in Bash most of the time, but there’s a substantial
8383+ grey area of things that are too complicated to be simple in bash, but
8484+ too simple to be worth writing a clj/s script for. Babashka really
8585+ seems to hit the sweet spot for those cases.
73867474- Goals:
8787+ Goals:
75887676- - Low latency Clojure scripting alternative to JVM Clojure.
7777- - Easy installation: grab the self-contained binary and run. No JVM needed.
7878- - Familiarity and portability:
7979- - Scripts should be compatible with JVM Clojure as much as possible
8080- - Scripts should be platform-independent as much as possible. Babashka
8181- offers support for linux, macOS and Windows.
8282- - Allow interop with commonly used classes like java.io.File and System
8383- - Multi-threading support (pmap, future, core.async)
8484- - Batteries included (tools.cli, cheshire, ...)
8585- - Library support via popular tools like the clojure CLI
8686- '';
8787- homepage = "https://github.com/babashka/babashka";
8888- changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md";
8989- sourceProvenance = with sourceTypes; [ binaryBytecode ];
9090- license = licenses.epl10;
9191- maintainers = with maintainers; [
9292- bandresen
9393- bhougland
9494- DerGuteMoritz
9595- jlesquembre
9696- thiagokokada
9797- ];
8989+ - Low latency Clojure scripting alternative to JVM Clojure.
9090+ - Easy installation: grab the self-contained binary and run. No JVM needed.
9191+ - Familiarity and portability:
9292+ - Scripts should be compatible with JVM Clojure as much as possible
9393+ - Scripts should be platform-independent as much as possible. Babashka
9494+ offers support for linux, macOS and Windows.
9595+ - Allow interop with commonly used classes like java.io.File and System
9696+ - Multi-threading support (pmap, future, core.async)
9797+ - Batteries included (tools.cli, cheshire, ...)
9898+ - Library support via popular tools like the clojure CLI
9999+ '';
100100+ homepage = "https://github.com/babashka/babashka";
101101+ changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md";
102102+ sourceProvenance = with sourceTypes; [ binaryBytecode ];
103103+ license = licenses.epl10;
104104+ maintainers = with maintainers; [
105105+ bandresen
106106+ bhougland
107107+ DerGuteMoritz
108108+ jlesquembre
109109+ thiagokokada
110110+ ];
111111+ };
98112 };
9999-}
113113+in
114114+babashka-unwrapped
···268268269269@cli.command("update-all")
270270def update_all():
271271- repos = Parallel(n_jobs=2, require='sharedmem')(delayed(get_electron_info)(major_version) for major_version in range(27, 24, -1))
271271+ repos = Parallel(n_jobs=2, require='sharedmem')(delayed(get_electron_info)(major_version) for major_version in range(28, 24, -1))
272272 out = {n[0]: n[1] for n in Parallel(n_jobs=2, require='sharedmem')(delayed(get_update)(repo) for repo in repos)}
273273274274 with open('info.json', 'w') as f:
···781781 sane-backends-git = sane-backends; # Added 2021-02-19
782782 scantailor = scantailor-advanced; # Added 2022-05-26
783783 sdlmame = throw "'sdlmame' has been renamed to/replaced by 'mame'"; # Converted to throw 2023-09-10
784784+ searx = throw "'searx' has been removed as it is unmaintained. Please switch to searxng"; # Added 2023-10-03
784785 session-desktop-appimage = session-desktop;
785786 sequoia = sequoia-sq; # Added 2023-06-26
786787 sexp = sexpp; # Added 2023-07-03
···926927 win-qemu = throw "'win-qemu' has been replaced by 'win-virtio'"; # Added 2023-08-16
927928 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
928929 wlroots_0_14 = throw "'wlroots_0_14' has been removed in favor of newer versions"; # Added 2023-07-29
930930+ wordpress6_1 = throw "'wordpress6_1' has been removed in favor of the latest version"; # Added 2023-10-10
931931+ wordpress6_2 = throw "'wordpress6_2' has been removed in favor of the latest version"; # Added 2023-10-10
929932 wormhole-rs = magic-wormhole-rs; # Added 2022-05-30. preserve, reason: Arch package name, main binary name
930933 wmii_hg = wmii;
931934 wxGTK30 = throw "wxGTK30 has been removed from nixpkgs as it has reached end of life"; # Added 2023-03-22