Skip to content

Commit 003411c

Browse files
authored
Rob/tsd80 buildkite ci nix (#34)
* test pipeline * Stack effort * added quotes * docker effort * fixed nix * nix test * nix fix * nix fixes * buildkite * Another nix revision * buildkite nix file reference change * pipeline edit * pipeline edit * pipeline fix * changed referenced hash to nixpkgs * CI note * build badge * Semigroup needed to be added alongside Monoid * CI Notes updated * slight polishing of notes * Forgot nix-shell -p * [TSD-80] - Removed old nix files, renamed release1 to shell, took excess comments out of stack.yaml * changed pipeline/docs to reflect rename to shell.nix * stack yaml updates * replaced stack comments * Regenerated default.nix * re-added fetchNixpkgs * nixpkgs-src.json added * readded all old nix * copied nixpkgs-src.json from cardano-sl * readded old shell.nix * pipeline edit * default modified * default/shell modified * default.nix changed * reverted to older nixpkgs * Regex issue fixed * added Hydra config Signed-off-by: Rob Cohen <[email protected]> * changed buildkite to nix build -f default.nix * changed nix * Regex change needs to stay
1 parent b1feef4 commit 003411c

File tree

13 files changed

+105
-38
lines changed

13 files changed

+105
-38
lines changed

.buildkite/pipeline.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
steps:
2+
- label: 'log-classifier-x86_64-linux-nix'
3+
command: 'nix build -f default.nix'
4+
agents:
5+
system: x86_64-linux

CI.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Buildkite
2+
3+
These are the instructions for generating nix expressions for buildkite CI for log-classifier.
4+
5+
```
6+
$ cd $LOG_CLASSIFIER_ROOT
7+
$ cabal2nix . > default.nix
8+
$ nix-shell -p nix-prefetch-git
9+
nix-shell $ nix-prefetch-git https://github.com/NixOS/nixpkgs.git > nixpkgs.json
10+
```
11+
12+
NOTE:
13+
- NIX_PATH - Get from https://github.com/NixOS/nixpkgs, click clone, copy ZIP link, rename to .tar.gz.
14+
- buildkite pipeline command is "nix-build -I nixpkgs=$NIX_PATH shell.nix"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build status](https://badge.buildkite.com/50d1fa0b6ed53deb7bca3b81419fd2c65e7c22f67d2101e552.svg)](https://buildkite.com/input-output-hk/log-classifier)
2+
13
# log-classifier
24

35
Original version by Hiroto Shioi (https://github.com/HirotoShioi).

cabal2nix.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ mkDerivation, aeson, array, attoparsec, base, bytestring
2+
, containers, directory, generics-sop, hspec, http-conduit
3+
, monad-control, mtl, optparse-applicative, QuickCheck, reflection
4+
, regex-tdfa, resource-pool, sqlite-simple, stdenv, text, time
5+
, transformers-base, universum, unliftio, zip-archive
6+
}:
7+
mkDerivation {
8+
pname = "log-classifier";
9+
version = "1.2.0.0";
10+
src = ./.;
11+
isLibrary = true;
12+
isExecutable = true;
13+
libraryHaskellDepends = [
14+
aeson array attoparsec base bytestring containers directory
15+
generics-sop http-conduit monad-control mtl optparse-applicative
16+
QuickCheck reflection regex-tdfa resource-pool sqlite-simple text
17+
time transformers-base universum unliftio zip-archive
18+
];
19+
executableHaskellDepends = [ base universum ];
20+
testHaskellDepends = [
21+
aeson array attoparsec base bytestring containers hspec
22+
http-conduit mtl QuickCheck reflection regex-tdfa text universum
23+
zip-archive
24+
];
25+
homepage = "https://github.com/input-output-hk/log-classifier#readme";
26+
description = "Log classifier for a Cardano node";
27+
license = stdenv.lib.licenses.mit;
28+
}

default.nix

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
with import <nixpkgs> {};
1+
let lib = import ./lib.nix;
22

3-
let
4-
ghc = haskellPackages.ghcWithPackages (ps: with ps; [aeson array attoparsec bytestring containers http-conduit
5-
mtl optparse-applicative regex-tdfa reflection universum zip-archive]);
6-
in runCommand "log-classifier" { buildInputs = [ ghc haskellPackages.ghcid ]; } ''
7-
cp -r ${builtins.fetchGit ./.} src
8-
chmod -R +w src
9-
cd src
10-
mkdir -p $out/bin/
11-
ghc src/Lib.hs -o $out/bin/log-classifier -Wall
12-
''
3+
pkgs = import lib.fetchNixPkgs {};
4+
in
5+
pkgs.haskell.packages.ghc822.callPackage ./cabal2nix.nix {}

fetch-nixpkgs.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
let
2-
spec = builtins.fromJSON (builtins.readFile ./nixpkgs-src.json);
3-
in
4-
import ./fetchNixpkgs.nix spec
2+
# temporary hack until scripts/nix-shell.sh ceases to use -p
3+
pkgs_path = import ./fetchNixpkgs.nix (builtins.fromJSON (builtins.readFile ./nixpkgs-src.json));
4+
pkgs = import pkgs_path { config = {}; overlays = []; };
5+
wrapped = pkgs.runCommand "nixpkgs" {} ''
6+
ln -sv ${pkgs_path} $out
7+
'';
8+
in if 0 <= builtins.compareVersions builtins.nixVersion "1.12" then wrapped else pkgs_path
9+

fetchNixpkgs.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ else
3838
gzip = builtins.storePath builtin-paths.gzip;
3939
coreutils = builtins.storePath builtin-paths.coreutils;
4040
};
41-
}).nixpkgs
41+
}).nixpkgs

lib.nix

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,40 @@ let
1212
then result
1313
else default;
1414

15+
# Removes files within a Haskell source tree which won't change the
16+
# result of building the package.
17+
# This is so that cached build products can be used whenever possible.
18+
# It also applies the lib.cleanSource filter from nixpkgs which
19+
# removes VCS directories, emacs backup files, etc.
20+
cleanSourceTree = src:
21+
if (builtins.typeOf src) == "path"
22+
then lib.cleanSourceWith {
23+
filter = with pkgs.stdenv;
24+
name: type: let baseName = baseNameOf (toString name); in ! (
25+
# Filter out cabal build products.
26+
baseName == "dist" || baseName == "dist-newstyle" ||
27+
baseName == "cabal.project.local" ||
28+
# Filter out stack build products.
29+
lib.hasPrefix ".stack-work" baseName ||
30+
# Filter out files which are commonly edited but don't
31+
# affect the cabal build.
32+
lib.hasSuffix ".nix" baseName
33+
);
34+
src = lib.cleanSource src;
35+
} else src;
36+
1537
pkgs = import fetchNixPkgs {};
1638
lib = pkgs.lib;
1739
in lib // (rec {
18-
inherit fetchNixPkgs;
40+
inherit fetchNixPkgs cleanSourceTree;
41+
isCardanoSL = lib.hasPrefix "cardano-sl";
42+
isBenchmark = args: !((args.isExecutable or false) || (args.isLibrary or true));
43+
44+
# Insert this into builder scripts where programs require a UTF-8
45+
# locale to work.
46+
utf8LocaleSetting = ''
47+
export LC_ALL=en_GB.UTF-8
48+
export LANG=en_GB.UTF-8
49+
'';
1950
})
51+

nixpkgs-src.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"rev": "5c09cdc187b014143302551e62d4973b5bf52814",
3-
"sha256": "1qzba4apgm9v1vnvmar89b1g9h2z741daiimrc0d3idxv1q97im0",
4-
"sha256unpacked": "1qzba4apgm9v1vnvmar89b1g9h2z741daiimrc0d3idxv1q97im0"
2+
"rev": "120b013e0c082d58a5712cde0a7371ae8b25a601",
3+
"sha256": "1hbc3ng4iy4wv0kyr1zc7n4qx3wy5qlank42zq8h87wa8z3zdf14",
4+
"sha256unpacked": "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f"
55
}

release.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
log-classifier = import ./.;
3+
}

0 commit comments

Comments
 (0)