Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit aae2bcd

Browse files
committed
[DEVOPS-1120] Use iohk-nix and nix-tools for stack package set
This is a squashed commit. Original authors: Moritz Angermann <[email protected]> Samuel Leathers <[email protected]> Rodney Lorrimar <[email protected]>
1 parent cf02326 commit aae2bcd

File tree

14 files changed

+131
-62
lines changed

14 files changed

+131
-62
lines changed

.buildkite/pipeline.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
steps:
2-
- label: 'nix build'
3-
command: 'nix-build release.nix'
42
- label: 'stack rebuild'
53
env:
64
AWS_REGION: us-west-1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ There is an option of using just Cabal + Nix as well - use a small utility scrip
9292

9393
Adding new dependencies can be easy with, for example:
9494
```
95-
cabal2nix https://github.com/input-output-hk/cardano-prelude --revision "2d6624af423d0a5c7ced6f3ae465eaaeb4ec739e" > cardano-prelude.nix
95+
./nix/regenerate.sh
9696
```
9797

9898
## Tools

cardano-shell.nix

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

default.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ config ? {}
2+
, system ? builtins.currentSystem
3+
, iohkLib ? import ./nix/iohk-common.nix { inherit config system; application = "cardano-sl"; }
4+
, pkgs ? iohkLib.pkgs
5+
, gitrev ? iohkLib.commitIdFromGitRepo ./.
6+
}:
7+
8+
import ./nix/pkgs.nix { inherit pkgs; }

nix/.stack-pkgs.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
overlay = hackage:
3+
{
4+
packages = {
5+
"aeson-options" = hackage.aeson-options."0.0.0".revisions.default;
6+
"base58-bytestring" = hackage.base58-bytestring."0.1.0".revisions.default;
7+
"canonical-json" = hackage.canonical-json."0.5.0.1".revisions.default;
8+
"half" = hackage.half."0.2.2.3".revisions.default;
9+
"micro-recursion-schemes" = hackage.micro-recursion-schemes."5.0.2.2".revisions.default;
10+
"streaming-binary" = hackage.streaming-binary."0.3.0.1".revisions.default;
11+
"katip" = hackage.katip."0.6.3.0".revisions."55de9e007352cf3fb9de8de8b9ac17c1070824e07e6f6d5b676f9f3cff44d23c";
12+
} // {
13+
cardano-shell = ./.stack.nix/cardano-shell.nix;
14+
cardano-prelude = ./.stack.nix/cardano-prelude.nix;
15+
cardano-prelude-test = ./.stack.nix/cardano-prelude-test.nix;
16+
cborg = ./.stack.nix/cborg.nix;
17+
cardano-crypto = ./.stack.nix/cardano-crypto.nix;
18+
plutus-prototype = ./.stack.nix/plutus-prototype.nix;
19+
hedgehog = ./.stack.nix/hedgehog.nix;
20+
};
21+
compiler.version = "8.4.4";
22+
compiler.nix-name = "ghc844";
23+
};
24+
resolver = "lts-12.10";
25+
compiler = "ghc-8.4.4";
26+
}

nix/fetch-nixpkgs.nix

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

nix/iohk-common.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Imports the iohk-nix library.
2+
# The version can be overridden for debugging purposes by setting
3+
# NIX_PATH=iohk_nix=/path/to/iohk-nix
4+
5+
import (
6+
let try = builtins.tryEval <iohk_nix>;
7+
in if try.success
8+
then builtins.trace "using host <iohk_nix>" try.value
9+
else
10+
let
11+
spec = builtins.fromJSON (builtins.readFile ./iohk-nix.json);
12+
in builtins.fetchTarball {
13+
url = "${spec.url}/archive/${spec.rev}.tar.gz";
14+
inherit (spec) sha256;
15+
})

nix/iohk-nix.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"url": "https://github.com/input-output-hk/iohk-nix",
3+
"rev": "0156570e6b55b9e2c61d6fc64d49a7c78dc955fd",
4+
"date": "2018-12-13T08:08:15+10:00",
5+
"sha256": "0skbgx8l2h03azp5ww9dxc2217hxwk8za27ng1l68q9wi0vw23sl",
6+
"fetchSubmodules": false
7+
}

nix/nixpkgs-src.json

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

nix/pkgs.nix

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{ pkgs ? import <nixpkgs> {}
2+
}:
3+
let
4+
overrideWith = override: default:
5+
let
6+
try = builtins.tryEval (builtins.findFile builtins.nixPath override);
7+
in if try.success then
8+
builtins.trace "using search host <${override}>" try.value
9+
else
10+
default;
11+
in
12+
let
13+
# all packages from hackage as nix expressions
14+
hackage = import (overrideWith "hackage"
15+
(pkgs.fetchFromGitHub { owner = "angerman";
16+
repo = "hackage.nix";
17+
rev = "d8e03ec0e3c99903d970406ae5bceac7d993035d";
18+
sha256 = "0c7camspw7v5bg23hcas0r10c40fnwwwmz0adsjpsxgdjxayws3v";
19+
name = "hackage-exprs-source"; }))
20+
;
21+
# a different haskell infrastructure
22+
haskell = import (overrideWith "haskell"
23+
(pkgs.fetchFromGitHub { owner = "angerman";
24+
repo = "haskell.nix";
25+
rev = "03026b7bb95a6713f4d50b841abadabb343f83d2";
26+
sha256 = "05ma2qmmn4p2xcgyy8waissfj953b7wyq97yx80d936074gyyw4s";
27+
name = "haskell-lib-source"; }))
28+
hackage;
29+
30+
# the set of all stackage snapshots
31+
stackage = import (overrideWith "stackage"
32+
(pkgs.fetchFromGitHub { owner = "angerman";
33+
repo = "stackage.nix";
34+
rev = "67675ea78ae5c321ed0b8327040addecc743a96c";
35+
sha256 = "1ds2xfsnkm2byg8js6c9032nvfwmbx7lgcsndjgkhgq56bmw5wap";
36+
name = "stackage-snapshot-source"; }))
37+
;
38+
39+
# our packages
40+
stack-pkgs = import ./.stack-pkgs.nix;
41+
42+
# Build the packageset with module support.
43+
# We can essentially override anything in the modules
44+
# section.
45+
#
46+
# packages.cbors.patches = [ ./one.patch ];
47+
# packages.cbors.flags.optimize-gmp = false;
48+
#
49+
pkgSet = haskell.mkNewPkgSet {
50+
inherit pkgs;
51+
pkg-def = stackage.${stack-pkgs.resolver};
52+
pkg-def-overlays = [
53+
stack-pkgs.overlay
54+
];
55+
modules = [
56+
];
57+
};
58+
59+
packages = pkgSet.config.hsPkgs // { _config = pkgSet.config; };
60+
61+
in packages

nix/regenerate.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
exec $(nix-build `dirname $0`/iohk-common.nix -A nix-tools.regeneratePackages --no-out-link)

release.nix

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
let
2-
config = {
3-
packageOverrides = pkgs: rec {
4-
haskellPackages = pkgs.haskell.packages.ghc843.override {
5-
overrides = haskellPackagesNew: haskellPackagesOld: rec {
6-
cardano-prelude = haskellPackagesNew.callPackage ./cardano-prelude.nix {
7-
#canonical-json = pkgs.haskell.lib.dontCheck (haskellPackagesNew.callHackage "canonical-json" "0.5.0.1" {});
8-
canonical-json = pkgs.haskell.lib.dontCheck (haskellPackagesNew.callPackage ./canonical-json.nix {});
9-
};
10-
cardano-shell = haskellPackagesNew.callPackage ./cardano-shell.nix { };
11-
};
12-
};
13-
};
14-
};
15-
nixpkgs = builtins.fetchTarball {
16-
url = "https://github.com/NixOS/nixpkgs/archive/069bf7aee30faf7b3ed773cfae2154d761b2d6c2.tar.gz";
17-
sha256 = "1c44vjb60fw2r8ck8yqwkj1w4288wixi59c6w1vazjixa79mvjvg";
18-
};
19-
20-
pkgs = import nixpkgs { inherit config; };
21-
in
22-
{ cardano-shell = pkgs.haskellPackages.cardano-shell;
23-
}
1+
with import ./default.nix {};
2+
{ cardano-shell-execs = cardano-shell.components.exes;
3+
cardano-shell-tests = cardano-shell.components.tests;
4+
cardano-shell = cardano-shell.components.library;
5+
}

scripts/buildkite/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{ pkgs ? import (import ../../nix/fetch-nixpkgs.nix) { }
1+
{ iohkLib ? import ../../nix/iohk-common.nix { application = "cardano-sl"; }
2+
, pkgs ? iohkLib.pkgs
23
, buildTools ? with pkgs; [ git nix gnumake ]
34
}:
45

shell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(import ./release.nix).cardano-shell.env
1+
(import ./release.nix).cardano-shell

0 commit comments

Comments
 (0)