You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the Nix package manager to provide these dependencies, or install them manually.
13
13
14
-
If you have the [Nix package manager](https://nixos.org/) installed, the easiest way to run `hackage-server` is by using `nix develop`. It should be unnecessary to install any dependencies manually. In this repository:
14
+
### Using the [Nix package manager](https://nixos.org/) and provided [Nix Flake](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html)
15
+
16
+
If you have the Nix package manager installed, you can build and run `hackage-server` without manually installing any dependencies.
17
+
18
+
This uses `flake.nix`, implemented with [`srid/haskell-flake`](https://github.com/srid/haskell-flake).
19
+
20
+
There are at least three ways to use this `flake.nix`. Clone this repository, enter the repository directory, then choose one of these options:
$ cabal v2-run -- hackage-server run --static-dir=datafiles/ --base-uri=http://127.0.0.1:8080
29
+
$ cabal v2-run -- hackage-server run --static-dir=datafiles --base-uri=http://127.0.0.1:8080
22
30
hackage-server: Ready! Point your browser at http://127.0.0.1:8080
23
31
24
-
`flake.nix` is provided; it uses [`srid/haskell-flake`](https://github.com/srid/haskell-flake).
32
+
Note the `init` command will create a new folder `state` in your working directory.
25
33
26
34
If you have [direnv](https://direnv.net/), `direnv allow` will load this `nix develop` shell automatically.
27
35
28
-
`nix build` will build a `hackage-server` executable in `result/`. The Hackage dependencies are provided by the inputs specified in `flake.nix`. Because some of these inputs are unpublished commits on GitHub, this build should not be considered authoritative.
This will produce a `hackage-server` executable in `result/`.
41
+
42
+
For this executable, Hackage dependencies are not pulled from Hackage directly like usual. Hackage dependencies are provided by the [Nixpkgs](https://search.nixos.org/packages)[`haskell-updates`](https://github.com/NixOS/nixpkgs/tree/haskell-updates) branch, and a few [overrides in `flake.nix`](https://zero-to-flakes.com/haskell-flake/dependency#using-hackage-versions).
`nix run` is more convenient to use than `nix build`.
47
+
48
+
As with `nix build`, Hackage dependencies are not pulled from Hackage directly like usual. See caveat above.
49
+
50
+
List the available [Flake Apps](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run#apps) with [`nix flake show`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-show.html):
51
+
52
+
$ nix flake show
53
+
...
54
+
├───apps
55
+
...
56
+
│ │ ├───hackage-build: app
57
+
│ │ ├───hackage-import: app
58
+
│ │ ├───hackage-mirror: app
59
+
│ │ └───hackage-server: app
60
+
...
61
+
62
+
Run the `hackage-server` App:
63
+
64
+
nix run .#hackage-server -- init --static-dir=datafiles
65
+
66
+
nix run .#hackage-server -- run --static-dir=datafiles --base-uri=http://127.0.0.1:8080
67
+
68
+
The `.` refers to the `flake.nix` in your working directory. `#hackage-server` refers to the App specified in that `flake.nix`.
69
+
70
+
`hackage-server` is the default App, so those commands can be shortened:
71
+
72
+
nix run . -- init --static-dir=datafiles
73
+
74
+
nix run . -- run --static-dir=datafiles --base-uri=http://127.0.0.1:8080
75
+
76
+
##### Not working
77
+
78
+
Please note this App *cannot* be run [directly from GitHub](https://determinate.systems/posts/nix-run) like this:
79
+
80
+
nix run github:haskell/hackage-server -- init --static-dir=datafiles
81
+
82
+
nix run github:haskell/hackage-server -- run --static-dir=datafiles --base-uri=http://127.0.0.1:8080
83
+
84
+
because `hackage-server` expects the directories `state` and `datafiles` to exist in the working directory.
0 commit comments