Skip to content

Commit c197b1b

Browse files
committed
new patching instructions to readme
1 parent 4302051 commit c197b1b

File tree

1 file changed

+11
-45
lines changed

1 file changed

+11
-45
lines changed

README.md

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,31 @@
66

77
**Mirrors:** [**GitHub**](https://github.com/Glistix/stdlib) | [**Codeberg**](https://codeberg.org/Glistix/stdlib)
88

9-
This is a port of Gleam's standard library (https://github.com/gleam-lang/stdlib) to Glistix's Nix target. Its original documentation is available on [HexDocs](https://hexdocs.pm/gleam_stdlib/).
9+
This is a port of Gleam's standard library (https://github.com/gleam-lang/stdlib) to Glistix's Nix target. Documentation is available on [HexDocs](https://hexdocs.pm/glistix_stdlib/).
1010

1111
**Note:** This is a Glistix project, and as such may require the
1212
[Glistix compiler](https://github.com/glistix/glistix) to be used.
1313

1414
## Installation
1515

16-
_(NOTE: These instructions will change in a future Glistix version, please check out the [Glistix book](https://glistix.github.io/book) for updated instructions.)_
16+
_For the most recent instructions, please see [the Glistix handbook](https://glistix.github.io/book/recipes/overriding-packages.html)._
1717

18-
**It is recommended to use this repository as a Git dependency** for now, in order to override the `gleam_stdlib` dependency of transitive dependencies as well.
18+
This fork is available on Hex and already installed by default on any new Glistix projects using `glistix new`.
1919

20-
However, since Gleam (and thus Glistix) doesn't support Git dependencies, **you will have to add this repository as a local dependency to a Git submodule**
21-
(at least for now).
22-
23-
If `glistix new` didn't automatically do this for you, follow the steps below.
24-
25-
1. Create a folder named `external` in your repository.
26-
27-
2. Run the command below to add this repository as a submodule. Whenever you clone your repository again, run `git submodule init` to restore the submodule's contents.
28-
29-
```sh
30-
git submodule add --name stdlib -- https://github.com/Glistix/stdlib external/stdlib
31-
```
32-
33-
3. Make `gleam_stdlib` a path dependency to the cloned repository instead of a Hex dependency.
34-
To do this, edit the `[dependencies]` section in `gleam.toml` as below:
20+
For existing projects, you can use this fork by running `glistix add gleam_stdlib` followed by adding the line below to your Glistix project's `gleam.toml` file (as of Glistix v0.7.0):
3521

3622
```toml
37-
[dependencies]
38-
gleam_stdlib = { path = "./external/stdlib" }
23+
[glistix.preview.patch]
24+
# ... Existing patches ...
25+
# Add this line:
26+
gleam_stdlib = { name = "glistix_stdlib", version = ">= 0.34.0 and < 2.0.0" }
3927
```
4028

41-
4. Hex doesn't allow local dependencies on packages. Therefore, as a temporary workaround,
42-
**add the following section to `gleam.toml` so you can publish to Hex:**
43-
44-
```toml
45-
[glistix.preview.hex-patch]
46-
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
47-
```
48-
49-
5. Note that you may also have to add the section below if you use other submodules which also depend on stdlib
50-
(otherwise you might have conflicts between different patches) - again, a temporary workaround for now:
51-
52-
```toml
53-
[glistix.preview]
54-
local-overrides = ["gleam_stdlib"]
55-
```
56-
57-
6. Done, your code will now compile, and your dependencies will use the ported version of the standard library.
58-
59-
(**Note:** You may have to update your `flake.nix` as well to add the repository as a Flake input and pass it
60-
to the `submodules` list given to `loadGlistixPackage` so that building through Nix works as well.
61-
This is also done by default for `stdlib` by `glistix new`, but is something to consider when adding other
62-
Git submodules as dependencies of your project.)
29+
This ensures transitive dependencies on `gleam_stdlib` will also use the patch.
6330

64-
The same procedure is done for any Nix ports you may want to use in your project, e.g. [`json`](https://github.com/Glistix/json), [`birl`](https://github.com/Glistix/birl) and so on.
31+
Keep in mind that patches only have an effect on end users' projects - they are ignored when publishing a package to Hex, so end users are responsible for any patches their dependencies may need.
6532

66-
It is expected that this procedure will become simpler in the future, once Gleam gets Git dependencies and built-in patching
67-
of dependencies.
33+
If your project or package is only meant for the Nix target, you can also use this fork in `[dependencies]` directly through `glistix add glistix_stdlib` in order to not rely on patching. However, the patch above is still going to be necessary for end users to fix other dependencies which depend on `gleam_stdlib`.
6834

6935
## Inconsistencies and missing features on Nix
7036

0 commit comments

Comments
 (0)