1# Handling git repositories in projects
3Both `stack.yaml` and `cabal.project` files can contain references
4to git repositories containing the version of a particular package
5that we wish to use. This is mostly handled automatically by
6`nix-tools` and `haskell.nix` however when we want to use a nix
7system that is configured to use restricted mode (typically hydra)
8it will need additional hashes for the referenced repositories.
10When using `project`, `cabalProject` or `stackProject` functions
11you can include the hash needed in a comment.
13To calculate the hash use `nix-prefetch-git`:
16$ nix-prefetch-git https://github.com/input-output-hk/haskell.nix.git bc01ebc05a8105035c9449943046b46c8364b932
19 "url": "https://github.com/input-output-hk/haskell.nix.git",
20 "rev": "bc01ebc05a8105035c9449943046b46c8364b932",
21 "date": "2019-05-30T13:13:18+08:00",
22 "sha256": "003lm3pm024vhbfmii7xcdd9v2rczpflxf7gdl2pyxia7p014i8z",
23 "fetchSubmodules": false
29Add a `--sha256` comment to the `cabal.project` file:
32source-repository-package
34 location: https://github.com/input-output-hk/haskell.nix.git
35 tag: bc01ebc05a8105035c9449943046b46c8364b932
36 subdir: test/cabal-simple
37 --sha256: 003lm3pm024vhbfmii7xcdd9v2rczpflxf7gdl2pyxia7p014i8z
42Add a `# nix-sha256` comment to the `stack.yaml` file:
46- git: https://github.com/input-output-hk/haskell.nix.git
47 commit: bc01ebc05a8105035c9449943046b46c8364b932
50 # nix-sha256: 003lm3pm024vhbfmii7xcdd9v2rczpflxf7gdl2pyxia7p014i8z
53## Avoiding modifying cabal.project and stack.yaml
55In some cases we cannot modify the `cabal.project` or `stack.yaml` file to add
56sha256 comments. As an alternative we can pass in a `sha256map`. For instance,
57pandoc includes a `cabal.project` file on hackage which includes a
58`source-repository-package` stanza for `pandoc-citeproc`:
61{ haskell-nix, testSrc } :
63 pandoc = haskell-nix.hackage-package {
66 index-state = "2020-04-15T00:00:00Z";
67 # Function that returns a sha256 string by looking up the location
68 # and tag in a nested attrset
70 { "https://github.com/jgm/pandoc-citeproc"."0.17"
71 = "0dxx8cp2xndpw3jwiawch2dkrkp15mil7pyx7dvd810pwc22pm2q"; };
74 pandoc.components.exes.pandoc
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list