Skip to content

Commit 53ef851

Browse files
authored
Nix builds work (#39)
* Changes to CI.md * changed CI notes and nixpkgs * attempt to fix universum issue, still persisting * default.nix finally overrides universum correctly * nixpkgs back to cardano-sl nixpkgs * table added for files * Improved file descriptions * minor comment * reformatting * reformatting * changed a few sections on nixpkgs-src * detailed instructions * detailed instructions fix * CI resources * CI resources * Detailed which files are unchanged from cardano sl * minor fixes to docs * Modify change * reorg * fixed quotes * quote fix * deleted repetitive parts * Minor changes to install and readme * Nix instructions added * Minor correction * Minor rename * jq command is better * minor rephasing
1 parent 0f483f8 commit 53ef851

File tree

6 files changed

+127
-24
lines changed

6 files changed

+127
-24
lines changed

CI-NIX.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Buildkite & Nix Builds
2+
3+
## Buildkite
4+
The buildkite pipeline is automatically triggered by any commits that are pushed to the log-classifier repo.
5+
The pipeline that is executed is located in the .buildkite folder.
6+
7+
8+
## Nix related files and their purposes
9+
10+
| File | How to Make | Description |
11+
| --- | --- | --- |
12+
| default.nix | Manually | Contains the primary nix expression used to build log-classifier. This is likely the only nix expression that a developer may need to modify. |
13+
| cabal2nix.nix | `$ cabal2nix . > cabal2nix.nix` | The cabal2nix generated output from the log-classifier.cabal file. |
14+
| fetch-nixpkgs.nix | [cardano sl](https://github.com/input-output-hk/cardano-sl) | Used for pinning a specific version of nixpkgs. Reads nixpkgs-src.json. |
15+
| fetchNixpkgs.nix | [cardano sl](https://github.com/input-output-hk/cardano-sl) | Used for pinning a specific version of nixpkgs. Verifies and pulls nixpkgs. |
16+
| lib.nix | [cardano sl](https://github.com/input-output-hk/cardano-sl) | Used for pinning a specific verison of nixpkgs. Checks for cardano sl pkgs and runs fetch-nixpkgs.nix otherwise. |
17+
| shell.nix | Manually | Used by nix-shell to set nix environment. |
18+
| universum.nix | `$ cabal2nix cabal://universum-1.1.0 > universum.nix` | Created by cabal2nix, essentially overrides the Universum in nixpkgs. |
19+
| nixpkgs-src.json | See Below | Where version of nixpkgs is defined. See below for instructions to update. |
20+
21+
## Developing / Building via Nix
22+
23+
These are the instructions for using nix to build log-classifier.
24+
25+
All the commands below are executed in the cloned log-classifier directory.
26+
27+
```
28+
$ nix build -f default.nix
29+
```
30+
31+
You can also build within nix-shell:
32+
33+
```
34+
$ nix-shell
35+
nix-shell $ runhaskell Setup.hs configure
36+
nix-shell $ runhaskell Setup.hs build
37+
```
38+
39+
If you would prefer to use the repl:
40+
```
41+
$ nix-env -f '<nixpkgs>' -iA haskellPackages.ghcid
42+
$ nix-shell
43+
nix-shell $ ghcid -c "runhaskell Setup.hs repl Lib" # or replace log-classifier-exe if preferred
44+
```
45+
46+
### To change version of nixpkgs
47+
48+
Get $REV from https://howoldis.herokuapp.com/ (click commit, copy the string next to commit)
49+
50+
```
51+
$ REV="d7d31fea7e7eef8ff4495e75be5dcbb37fb215d0"
52+
$ cat ./nixpkgs-src.json | jq ".rev = \"${REV}\"" | \
53+
jq ".sha256 = \"`nix-prefetch-url https://github.com/nixos/nixpkgs/archive/${REV}.tar.gz`\"" | \
54+
jq ".sha256unpacked = \"`nix-prefetch-url --unpack https://github.com/nixos/nixpkgs/archive/${REV}.tar.gz`\""
55+
```
56+
57+
### To get versions of haskell packages
58+
```
59+
nix-shell --run 'ghc-pkg list' | grep universum
60+
```
61+
62+
## Useful Nix Resources
63+
64+
- [Nix by example](https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c55)
65+
- [Nix Cheatsheet](https://nixos.wiki/wiki/Cheatsheet)
66+
- [Pinning Nixpkgs](https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs)
67+
- [Nix Overrides](https://nixos.org/nixpkgs/manual/#sec-overrides)
68+
- [How I Develop with Nix](https://ocharles.org.uk/posts/2014-02-04-how-i-develop-with-nixos.html)

CI.md

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

INSTALL.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
---
44
## Prerequisites
5+
We presently support using either Stack or Nix:
56
- [Stack](https://github.com/commercialhaskell/stack/blob/master/doc/install_and_upgrade.md)
6-
7-
---
8-
9-
## Optional
107
- [Nix](https://nixos.org/nix/download.html)
118

129
```
@@ -23,8 +20,6 @@ $ git clone https://github.com/input-output-hk/log-classifier.git /home/$USER/lo
2320
$ cd /home/$USER/log-classifier
2421
```
2522

26-
Congratulations, you have downloaded log-classifier.
27-
2823
## Configuring log-classifier
2924
You will need the following:
3025
- Numeric ID of the user assigned tickets you want to analyze ($ASSIGNED_TO)
@@ -44,3 +39,18 @@ NOTE: The -n is important, without it echo will append a newline char and it wil
4439

4540
The above instructions are reflected in the simulated terminal below.
4641
![Terminal Example](./log-classifier.svg)
42+
43+
## Stack Instructons
44+
```
45+
$ stack build
46+
$ stack exec log-classifier-exe
47+
```
48+
49+
## Nix Instructions (CI/Buildkite instructons as well)
50+
51+
```
52+
$ nix-env -i -f default.nix
53+
$ log-classifier-exe
54+
```
55+
56+
Please see [CI](CI-NIX.md) for more detailed instructions pertaining to Nix.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Original version by Hiroto Shioi (https://github.com/HirotoShioi).
77
The purpose of this project is to analyze Cardano log file and provide a solution to the end user while collecting statistics so Cardano developers can prioritize the issues.
88

99
## Installation and Configuration Instructions
10-
Please read the instructions available in [INSTALL.md](INSTALL.md)
10+
Installation Instructions are available at [INSTALL.md](INSTALL.md)
1111

1212
## What it is
1313

default.nix

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
let lib = import ./lib.nix;
1+
let
2+
config = {
3+
packageOverrides = pkgs: rec {
4+
haskellPackages = pkgs.haskell.packages.ghc822.override {
5+
overrides = haskellPackagesNew: haskellPackagesOld: rec {
6+
universum =
7+
haskellPackagesNew.callPackage ./universum.nix { };
8+
};
9+
};
10+
};
11+
};
212

3-
pkgs = import lib.fetchNixPkgs {};
13+
lib = import ./lib.nix;
14+
15+
pkgs = import lib.fetchNixPkgs {inherit config; };
416
in
5-
pkgs.haskell.packages.ghc822.callPackage ./cabal2nix.nix {}
17+
pkgs.haskellPackages.callPackage ./cabal2nix.nix {}

universum.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ mkDerivation, base, bytestring, containers, criterion, deepseq
2+
, doctest, ghc-prim, Glob, hashable, hedgehog, microlens
3+
, microlens-mtl, mtl, safe-exceptions, semigroups, stdenv, stm
4+
, tasty, tasty-hedgehog, text, text-format, transformers
5+
, type-operators, unordered-containers, utf8-string, vector
6+
}:
7+
mkDerivation {
8+
pname = "universum";
9+
version = "1.1.0";
10+
sha256 = "177635a009f38edb8fc764bf9504077fb41af033c49b2a0ae2c725b55a9a2f4c";
11+
libraryHaskellDepends = [
12+
base bytestring containers deepseq ghc-prim hashable microlens
13+
microlens-mtl mtl safe-exceptions stm text text-format transformers
14+
type-operators unordered-containers utf8-string vector
15+
];
16+
testHaskellDepends = [
17+
base bytestring doctest Glob hedgehog tasty tasty-hedgehog text
18+
utf8-string
19+
];
20+
benchmarkHaskellDepends = [
21+
base containers criterion deepseq hashable mtl semigroups text
22+
unordered-containers
23+
];
24+
homepage = "https://github.com/serokell/universum";
25+
description = "Custom prelude used in Serokell";
26+
license = stdenv.lib.licenses.mit;
27+
}

0 commit comments

Comments
 (0)