Skip to content

Commit cfbecdb

Browse files
committed
replace shell.nix with haskell.nix Flake
1 parent 79cb3a2 commit cfbecdb

File tree

15 files changed

+1003
-108
lines changed

15 files changed

+1003
-108
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/nix-shell.yml renamed to .github/workflows/nix-flake.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Test nix-shell"
1+
name: "Test Nix Flake"
22
on:
33
push:
44
branches:
@@ -15,7 +15,6 @@ jobs:
1515
- uses: actions/[email protected]
1616
- uses: cachix/install-nix-action@v18
1717
with:
18-
nix_path: nixpkgs=channel:nixos-21.11
1918
extra_nix_config: |
2019
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hackage-server.cachix.org-1:iw0iRh6+gsFIrxROFaAt5gKNgIHejKjIfyRdbpPYevY=
2120
substituters = https://hydra.iohk.io https://cache.nixos.org/ https://hackage-server.cachix.org/
@@ -24,4 +23,5 @@ jobs:
2423
# https://nix.dev/tutorials/continuous-integration-github-actions#setting-up-github-actions
2524
name: hackage-server
2625
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
27-
- run: nix-shell --pure --run ./.github/workflows/test-nix-shell.sh
26+
- run: nix build
27+
- run: nix flake check

.github/workflows/test-nix-shell.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ tags
1515
*.swp
1616
TAGS
1717
*~
18+
.direnv

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22

33
[![Build Status](https://travis-ci.org/haskell/hackage-server.png?branch=master)](https://travis-ci.org/haskell/hackage-server)
44
[![Build status](https://github.com/haskell/hackage-server/actions/workflows/haskell-ci.yml/badge.svg)](https://github.com/haskell/hackage-server/actions/workflows/haskell-ci.yml)
5-
[![Build status](https://github.com/haskell/hackage-server/actions/workflows/nix-shell.yml/badge.svg)](https://github.com/haskell/hackage-server/actions/workflows/nix-shell.yml)
5+
[![Build status](https://github.com/haskell/hackage-server/actions/workflows/nix-flake.yml/badge.svg)](https://github.com/haskell/hackage-server/actions/workflows/nix-flake.yml)
66

77
This is the `hackage-server` code. This is what powers <http://hackage.haskell.org>, and many other private hackage instances. The `master` branch is suitable for general usage. Specific policy and documentation for the central hackage instance exists in the `central-server` branch.
88

99
## Installing dependencies
1010

1111
`hackage-server` depends on `libgd` and `zlib`. You'll also need `libbrotli-dev` for enabling tests.
1212

13-
### [`nix-shell`](https://nixos.org/manual/nix/stable/command-ref/nix-shell.html)
13+
### [`nix develop`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html)
1414

15-
If you have the [Nix package manager](https://nixos.org/) installed, the easiest way to run `hackage-server` is by using the `nix-shell`. It should be unnecessary to install any dependencies manually. In this repository:
15+
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:
1616

17-
nix-shell --pure
17+
nix develop
1818

19-
[nix-shell]$ cabal v2-run -- hackage-server init
19+
(in develop shell)
20+
$ cabal v2-run -- hackage-server init
2021

21-
[nix-shell]$ cabal v2-run -- hackage-server run --static-dir=datafiles/ --base-uri=http://127.0.0.1:8080
22+
$ cabal v2-run -- hackage-server run --static-dir=datafiles/ --base-uri=http://127.0.0.1:8080
2223
hackage-server: Ready! Point your browser at http://127.0.0.1:8080
2324

2425
### Manually

cabal.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
packages: .
1010

11-
1211
allow-newer: rss:time, rss:base
1312

1413
-- Andreas, 2022-10-28: `Cabal-3.8.1.0` wants `process >= 1.6.14`

exes/Main.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,22 @@ runAction opts = do
357357
-> return n
358358
_ -> fail $ "bad port number " ++ show str
359359

360+
-- Just authority <- uriAuthority guessURI
361+
-- let portStr | port == 80 = ""
362+
363+
checkHostURI :: ServerConfig -> Maybe String -> Int -> IO URI
360364
checkHostURI defaults Nothing port = do
361365
let guessURI = confHostUri defaults
362-
Just authority = uriAuthority guessURI
366+
case uriAuthority guessURI of
367+
Nothing -> fail "No URI Authority"
368+
Just authority -> let
363369
portStr | port == 80 = ""
364370
| otherwise = ':' : show port
365371
guessURI' = guessURI { uriAuthority = Just authority { uriPort = portStr } }
366-
lognotice verbosity $ "Guessing public URI as " ++ show guessURI'
372+
in do
373+
lognotice verbosity $ "Guessing public URI as " ++ show guessURI'
367374
++ "\n(you can override with the --base-uri= flag)"
368-
return guessURI'
375+
return guessURI'
369376

370377
checkHostURI _ (Just str) _ = case parseAbsoluteURI str of
371378
Nothing -> fail $ "Cannot parse as a URI: " ++ str ++ "\n"

0 commit comments

Comments
 (0)