• Stars
    star
    415
  • Rank 104,301 (Top 3 %)
  • Language
    Haskell
  • License
    Other
  • Created over 11 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hackage-Server: A Haskell Package Repository

hackage-server

Build status Build status

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.

Installing dependencies

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

nix develop

If you have the Nix package manager 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:

nix develop

(in develop shell)
$ cabal v2-run -- hackage-server init

$ cabal v2-run -- hackage-server run --static-dir=datafiles/ --base-uri=http://127.0.0.1:8080
hackage-server: Ready! Point your browser at http://127.0.0.1:8080

flake.nix is provided; it uses srid/haskell-flake.

If you have direnv, direnv allow will load this nix develop shell automatically.

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.

Manually

You can also install dependencies manually via your operating system's package manager.

Libgd

You'll need to do the following to get hackage-server's dependency hs-captcha (and transitively gd) to build:

  • Mac OS X

    brew install libgd
    
  • Ubuntu/Debian

    sudo apt-get update
    sudo apt-get install unzip libgd-dev
    
  • Fedora/CentOS

    sudo dnf install unzip libgd-devel
    
  • Nix/NixOS

    nix-shell --packages gd
    

libbrotli

  • Ubuntu/Debian

    sudo apt update
    sudo apt install libbrotli-dev
    
  • Fedora/CentOS

    sudo dnf install brotli-devel
    

openssl

  • Fedora/CentOS

    sudo dnf install openssl-devel

zlib

  • Mac OS X

    brew install zlib
    
  • Ubuntu/Debian

    sudo apt-get update
    sudo apt-get install zlib
    
  • Fedora/CentOS

    sudo dnf install zlib
    
  • Nix/NixOS

    nix-shell --packages zlib
    

Setting up security infrastructure

Out of the box the server comes with some example keys and TUF metadata. The example keys are in example-keys/; these keys were used to create

datafiles/TUF/root.json
datafiles/TUF/mirrors.json
datafiles/TUF/timestamp.private
datafiles/TUF/snapshot.private

While these files will enable you to start the server without doing anything else, you should replace all these files before deploying your server. In the remainder of this section we will explain how to do that.

The first step is to create your own keys using the hackage-repo-tool:

hackage-repo-tool create-keys --keys /path/to/keys

Then copy over the timestamp and snapshot keys to the TUF directory:

cp /path/to/keys/timestamp/<id>.private datafiles/TUF/timestamp.private
cp /path/to/keys/snapshot/<id>.private  datafiles/TUF/snapshot.private

Create root information:

hackage-repo-tool create-root --keys /path/to/keys -o datafiles/TUF/root.json

And finally create a list of mirrors (this is necessary even if you don't have any mirrors):

hackage-repo-tool create-mirrors --keys /path/to/keys -o datafiles/TUF/mirrors.json

The create-mirrors command takes a list of mirrors as additional arguments if you do want to list mirrors.

In order for secure clients to bootstrap the root security metadata from your server, you will need to provide them with the public key IDs of your root keys; you can find these as the file names of the files created in /path/to/keys/root (as well as in the generated root.json under the signed.roles.root.keyids). An example cabal client configuration might look something like

repository my-private-hackage
  url: http://example.com:8080/
  secure: True
  root-keys: 865cc6ce84231ccc990885b1addc92646b7377dd8bb920bdfe3be4d20c707796
             dd86074061a8a6570348e489aae306b997ed3ccdf87d567260c4568f8ac2cbee
             e4182227adac4f3d0f60c9e9392d720e07a8586e6f271ddcc1697e1eeab73390
  key-threshold: 2

Note that if you elect to not use a secure client, the hackage server will not provide your client the most recent versions of packages from its index. The cabal-version:2.0 format packages are thus only available in the newer secure repository mode. See Issue #4625 for further information.

Running

cabal install

hackage-server init
hackage-server run

If you want to run the server directly from the build tree, run

cabal v2-run -- hackage-server init

once to initialise the state. After that you can run the server with

cabal v2-run -- hackage-server run --static-dir=datafiles/ --base-uri=http://127.0.0.1:8080

By default the server runs on port 8080 with the following settings:

URL:      http://localhost:8080/
username: admin
password: admin

To specify something different, see hackage-server init --help for details.

The http://127.0.0.1:8080/packages/uploaders/edit is used to add users (e.g. admin) to Uploaders group.

The server can be stopped by using Control-C.

This will save the current state and shutdown cleanly. Running again will resume with the same state.

Resetting

To reset everything, kill the server and delete the server state:

rm -rf state/

Note that the datafiles/ and state/ directories differ: datafiles is for static html, templates and other files. The state directory holds the database (using acid-state and a separate blob store).

Creating users & uploading packages

Currently there is no restriction on registering, but only an admin user can grant privileges to registered users e.g. by adding them to other groups. In particular there are groups:

  • admins http://localhost:8080/users/admins/ -- administrators can do things with user accounts like disabling, deleting, changing other groups etc.
  • trustees http://localhost:8080/packages/trustees/ -- trustees can do janitorial work on all packages
  • mirrors http://localhost:8080/packages/mirrorers/ -- for special mirroring clients that are trusted to upload packages
  • per-package maintainer groups http://localhost:8080/package/foo/maintainers -- users allowed to upload packages
  • uploaders http://localhost:8080/packages/uploaders/ -- for uploading new packages

Mirroring

There is a client program included in the hackage-server package called hackage-mirror. It's intended to run against two servers, syncing all the packages from one to the other, e.g. getting all the packages from the old hackage and uploading them to a local instance of a hackage-server.

To try it out:

  1. On the target server, add a user to the mirrorers group via http://localhost:8080/packages/mirrorers/.

  2. Create a config file that contains the source and target servers. Assuming you are cloning the packages on http://hackage.haskell.org locally, create the file servers.cfg:

    source "hackage"
      uri: http://hackage.haskell.org
      type: secure
    
    target "mirror"
      uri: http://admin:admin@localhost:8080
      type: hackage2
    
      post-mirror-hook: "shell command to execute"
    

    Recognized types are hackage2, secure and local. The target server name was displayed when you ran.

    Note, the target must not have a trailing slash, or confusion will tend to occur. Additionally, if you have ipv6 setup on the machine, you may need to replace localhost with 127.0.0.1.

    Also note that you should mirror from hackage2 or secure typically and mirror to hackage2. Only mirroring from secure will include dependency revision information.

    hackage-server run
  3. Run the client, pointing to the config file:

    hackage-mirror servers.cfg

    This will do a one-time sync, and will bail out at the first sign of trouble. You can also do more robust and continuous mirroring. Use the flag --continuous. It will sync every 30 minutes (configurable with --interval). In this mode it carries on even when some packages cannot be mirrored for some reason and remembers them so it doesn't try them again and again. You can force it to try again by deleting the state files it mentions.

More Repositories

1

haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Haskell
2,709
star
2

haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
Haskell
2,383
star
3

cabal

Official upstream development repository for Cabal and cabal-install
Haskell
1,623
star
4

haskell-mode

Emacs mode for Haskell
Emacs Lisp
1,329
star
5

aeson

A fast Haskell JSON library
Haskell
1,254
star
6

stylish-haskell

Haskell code prettifier
Haskell
986
star
7

parsec

A monadic parser combinator library
Haskell
844
star
8

ghcide

A library for building Haskell IDE tooling
Haskell
584
star
9

vscode-haskell

VS Code extension for Haskell, powered by haskell-language-server
TypeScript
561
star
10

attoparsec

A fast Haskell library for parsing ByteStrings
Haskell
514
star
11

criterion

A powerful but simple library for measuring the performance of Haskell code.
Haskell
501
star
12

text

Haskell library for space- and time-efficient operations over Unicode text.
Haskell
406
star
13

haskell-platform

Distribution of Haskell with batteries included
Haskell
381
star
14

wreq

Haskell
379
star
15

lsp

Haskell library for the Microsoft Language Server Protocol
Haskell
366
star
16

mtl

The Monad Transformer Library
Haskell
366
star
17

vector

An efficient implementation of Int-indexed arrays (both mutable and immutable), with a powerful loop optimisation framework .
Haskell
363
star
18

haddock

Haskell Documentation Tool
HTML
361
star
19

network

Low-level networking interface
Haskell
326
star
20

containers

Assorted concrete container types
Haskell
315
star
21

statistics

A fast, high quality library for computing with statistics in Haskell.
Haskell
300
star
22

alex

A lexical analyser generator for Haskell
Haskell
298
star
23

bytestring

An efficient compact, immutable byte string type (both strict and lazy) suitable for binary or 8-bit character data.
Haskell
291
star
24

happy

The Happy parser generator for Haskell
Haskell
287
star
25

ghcup-hs

Haskell
284
star
26

ghcup

DEPRECATED IN FAVOR OF haskell/ghcup-hs
Shell
263
star
27

haskeline

A Haskell library for line input in command-line programs.
Haskell
222
star
28

c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
Haskell
198
star
29

fgl

A Functional Graph Library for Haskell
Haskell
184
star
30

hie-bios

Set up a GHC API session for various Haskell Projects
Haskell
180
star
31

HTTP

Haskell HTTP package
Haskell
177
star
32

ThreadScope

A graphical tool for profiling parallel Haskell programs
Haskell
153
star
33

actions

Github actions for Haskell CI
TypeScript
147
star
34

critbit

A Haskell implementation of crit-bit trees.
Haskell
138
star
35

play-haskell

Haskell Playground
Haskell
129
star
36

time

A time library
Haskell
119
star
37

primitive

This package provides various primitive memory-related operations.
Haskell
114
star
38

unix

POSIX functionality
Haskell
107
star
39

binary

Efficient, pure binary serialisation using ByteStrings in Haskell.
Haskell
106
star
40

rfcs

This repo is archived, consider using https://github.com/ghc-proposals/ghc-proposals instead
TeX
98
star
41

win32

Haskell support for the Win32 API
Haskell
98
star
42

stm

Software Transactional Memory
Haskell
97
star
43

core-libraries-committee

95
star
44

haskell-report

Haskell Language Report
TeX
91
star
45

parallel

a library for parallel programming
Haskell
91
star
46

process

Library for dealing with system processes
Haskell
87
star
47

hoopl

Higher-order optimization library
Haskell
73
star
48

error-messages

72
star
49

pretty

Haskell Pretty-printer library
Haskell
69
star
50

filepath

Haskell FilePath core library
Haskell
66
star
51

docker-haskell

Dockerfile
63
star
52

directory

Platform-independent library for basic file system operations
Haskell
58
star
53

hackage-security

Hackage security framework based on TUF (The Update Framework)
Haskell
56
star
54

mwc-random

A very fast Haskell library for generating high quality pseudo-random numbers.
Haskell
55
star
55

random

Random number library
Haskell
53
star
56

ecosystem-proposals

Proposals for the Haskell Ecosystem
51
star
57

text-icu

This package provides the Haskell Data.Text.ICU library, for performing complex manipulation of Unicode text.
Haskell
47
star
58

base64-bytestring

Fast base64 encoding and decoding for Haskell.
Haskell
45
star
59

security-advisories

Haskell
44
star
60

deepseq

Deep evaluation of data structures
Haskell
41
star
61

tar

Reading, writing and manipulating ".tar" archive files.
Haskell
40
star
62

math-functions

Special mathematical functions
Haskell
40
star
63

hsc2hs

Pre-processor for .hsc files
Haskell
38
star
64

pvp

Haskell Package Version Policy (PVP)
CSS
38
star
65

zlib

Compression and decompression in the gzip and zlib formats
C
35
star
66

ghc-events

Library and tool for parsing .eventlog files from GHC
Haskell
33
star
67

text-format

A Haskell text formatting library optimized for ease of use and high performance.
Haskell
32
star
68

ghcup-metadata

GHCup metadata repository
Haskell
32
star
69

cabal-userguide

A handy user guide for the Cabal build tool
Nix
28
star
70

base16-bytestring

Fast base16 (hexadecimal) encoding and decoding for Haskell bytestrings.
Haskell
27
star
71

network-uri

URI manipulation facilities
Haskell
25
star
72

entropy

Easy entropy source for Haskell users.
Haskell
23
star
73

winghci

Simple Windows GUI for GHCi.
C
17
star
74

double-conversion

A fast Haskell library for converting between double precision floating point numbers and text strings. It is implemented as a binding to the V8-derived C++ double-conversion library.
C++
15
star
75

file-io

File IO (read/write/open) for OsPath API
Haskell
11
star
76

terminfo

Haskell bindings to the terminfo API.
Haskell
10
star
77

array

Haskell
10
star
78

xhtml

XHTML combinator library
Haskell
9
star
79

old-time

This package provides the old time library.
Haskell
7
star
80

meta

A place for discussing & documenting the github.com/haskell organization
7
star
81

blog.haskell.org

Repository of the Haskell Blog
JavaScript
7
star
82

ghc-builder

ghc builder bot
Haskell
6
star
83

cabal-website

The http://www.haskell.org/cabal/ website
HTML
4
star
84

network-bsd

POSIX network database (<netdb.h>) API
Haskell
4
star
85

haskell-wiki-configuration

Issue tracking for Haskell Wiki
PHP
4
star
86

clc-stackage

Meta-package to facilitate impact assessment for CLC proposals
Nix
3
star
87

hiw

Haskell Implementors Workshop
TeX
3
star
88

text-test-data

Test data for the Haskell text project
Text
3
star
89

old-locale

This package provides the ability to adapt to locale conventions such as date and time formats.
Haskell
3
star
90

tokenize

Simple tokenizer for English text
Haskell
3
star
91

bzlib

Compression and decompression in the bzip2 format
Haskell
2
star
92

os-string

Haskell
2
star
93

hpc

1
star