Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Fix cabal and nix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi committed Jun 16, 2020
1 parent 50bfa2c commit e72075f
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
dist-newstyle/
*~
tags
result*
121 changes: 115 additions & 6 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,21 +1,118 @@
index-state: 2020-01-31T00:00:00Z
index-state: 2020-04-01T00:00:00Z

packages:
.
./.

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: fe76ec64f6b45259cc407a6d840dad79ee6063b6
--sha256: 1w39806djx7vmps47vvc72i20w4dkam3l8687kkw5ih1isvl671x
tag: e0257be9d745a04f85ab8287a48a9c193acafec8
--sha256: 09cxfa0vzny8xhjskc6khrfwsnajjawas6j574i2qfd71yd8mrrg

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: fe76ec64f6b45259cc407a6d840dad79ee6063b6
--sha256: 1w39806djx7vmps47vvc72i20w4dkam3l8687kkw5ih1isvl671x
tag: e0257be9d745a04f85ab8287a48a9c193acafec8
--sha256: 09cxfa0vzny8xhjskc6khrfwsnajjawas6j574i2qfd71yd8mrrg
subdir: test

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: contra-tracer

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: iohk-monitoring

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: plugins/backend-aggregation

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: plugins/backend-ekg

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: plugins/backend-monitoring

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: plugins/backend-trace-forwarder

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: plugins/scribe-systemd

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 71df15f7b888d2671f619cc632080aaaaca48087
--sha256: 02shwi4qppf88biq2y9amfzkzif9j0fdj0d77zdjrfjacldvc6ci
subdir: tracer-transformers

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 16bca08140fb37746538edff9fe77220acf91d55
--sha256: 1m6z6qfy6y5rvlj0isrzf3wcm1vsmlzvhmn988dp14r6fycljvca
subdir: Win32-network

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto
tag: 2547ad1e80aeabca2899951601079408becbc92c
--sha256: 1p2kg2w02q5w1cvqzhfhqmxviy4xrzada3mmb096j2n6hfr20kri

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 4a457f44e68132ce2bd978ab45a3188e64327abc
--sha256: 1yzbhkil119hkcb36ykwrchxk3zqmshpp57an17zjjqh7n2nw392
subdir: binary

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 4a457f44e68132ce2bd978ab45a3188e64327abc
--sha256: 1yzbhkil119hkcb36ykwrchxk3zqmshpp57an17zjjqh7n2nw392
subdir: binary/test

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 4a457f44e68132ce2bd978ab45a3188e64327abc
--sha256: 1yzbhkil119hkcb36ykwrchxk3zqmshpp57an17zjjqh7n2nw392
subdir: cardano-crypto-class

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 4a457f44e68132ce2bd978ab45a3188e64327abc
--sha256: 1yzbhkil119hkcb36ykwrchxk3zqmshpp57an17zjjqh7n2nw392
subdir: slotting

constraints:
ip < 1.5,
hedgehog >= 1.0,
Expand All @@ -27,3 +124,15 @@ allow-newer: katip:Win32

package comonad
flags: -test-doctests

package cardano-prelude
tests: False

package iohk-monitoring
tests: False

package cardano-binary
tests: False

package cardano-crypto-class
tests: False
9 changes: 4 additions & 5 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@
let
sources = import ./sources.nix { inherit pkgs; }
// sourcesOverride;
iohKNix = import sources.iohk-nix {};
iohkNix = import sources.iohk-nix {};
haskellNix = import sources."haskell.nix";
# use our own nixpkgs if it exists in our sources,
# otherwise use iohkNix default nixpkgs.
nixpkgs = if (sources ? nixpkgs)
then (builtins.trace "Not using IOHK default nixpkgs (use 'niv drop nixpkgs' to use default for better sharing)"
sources.nixpkgs)
else (builtins.trace "Using IOHK default nixpkgs"
iohKNix.nixpkgs);
else iohkNix.nixpkgs;

# for inclusion in pkgs:
overlays =
# Haskell.nix (https://github.com/input-output-hk/haskell.nix)
haskellNix.overlays
# haskell-nix.haskellLib.extra: some useful extra utility functions for haskell.nix
++ iohKNix.overlays.haskell-nix-extra
++ iohkNix.overlays.haskell-nix-extra
# iohkNix: nix utilities and niv:
++ iohKNix.overlays.iohkNix
++ iohkNix.overlays.iohkNix
# our own overlays:
++ [
(pkgs: _: with pkgs; {
Expand Down
20 changes: 15 additions & 5 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
}:
let

src = haskell-nix.haskellLib.cleanGit {
name = "smash-src";
src = ../.;
};

projectPackages = lib.attrNames (haskell-nix.haskellLib.selectProjectPackages
(haskell-nix.cabalProject { inherit src; }));

# This creates the Haskell package set.
# https://input-output-hk.github.io/haskell.nix/user-guide/projects/
pkgSet = haskell-nix.cabalProject {
src = haskell-nix.haskellLib.cleanGit { src = ../. ; };
ghc = buildPackages.haskell-nix.compiler.${compiler};
inherit src;
compiler-nix-name = compiler;
modules = [
# Allow reinstallation of Win32
{ nonReinstallablePkgs =
Expand All @@ -35,9 +43,11 @@ let
# "stm" "terminfo"
];
}
{
packages.smash.configureFlags = [ "--ghc-option=-Werror" ];
}
# TODO: Compile all local packages with -Werror:
#{
# packages = lib.genAttrs projectPackages
# (name: { configureFlags = [ "--ghc-option=-Werror" ]; });
#}
];
};
in
Expand Down
12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "480177ce8308d7baa9e060c4163f158d8584c4e2",
"sha256": "00mcb5r7c1w52jbiig0qrjhqfyrlrlq67jv0w5n1ll8l6zic6sss",
"rev": "c474dcec4a435698cd7978ef25e6fea25ff6795b",
"sha256": "149n40p56njpzibbkxlqj7rv8f2yvgfqni9m6xr8rvl5yry1lxd0",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/480177ce8308d7baa9e060c4163f158d8584c4e2.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/c474dcec4a435698cd7978ef25e6fea25ff6795b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"iohk-nix": {
Expand All @@ -17,10 +17,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "6ce1a519cc139781dfd4d68760d8596f0a6e4e84",
"sha256": "058lfjbinjn7ra8h5mpy7l191z2pzyqihrsw0a6kmy46v9xlm7gi",
"rev": "8b1d65ba294708b12d7b15103ac35431d9b60819",
"sha256": "1z23lw28s3wa5bf5yr89i61m413ad299lyhv02i9r36p28wjl94g",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/6ce1a519cc139781dfd4d68760d8596f0a6e4e84.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/8b1d65ba294708b12d7b15103ac35431d9b60819.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
62 changes: 33 additions & 29 deletions nix/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,29 @@ let
else
pkgs.fetchurl { inherit (spec) url sha256; };

fetch_tarball = pkgs: spec:
if spec.builtin or true then
builtins_fetchTarball { inherit (spec) url sha256; }
else
pkgs.fetchzip { inherit (spec) url sha256; };
fetch_tarball = pkgs: name: spec:
let
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
# sanitize the name, though nix will still fail if name starts with period
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };

fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };

fetch_builtin-tarball = spec:
builtins.trace
''
WARNING:
The niv type "builtin-tarball" will soon be deprecated. You should
instead use `builtin = true`.
fetch_local = spec: spec.path;

$ niv modify <package> -a type=tarball -a builtin=true
''
builtins_fetchTarball { inherit (spec) url sha256; };
fetch_builtin-tarball = name: throw
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=tarball -a builtin=true'';

fetch_builtin-url = spec:
builtins.trace
''
WARNING:
The niv type "builtin-url" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=file -a builtin=true
''
(builtins_fetchurl { inherit (spec) url sha256; });
fetch_builtin-url = name: throw
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=file -a builtin=true'';

#
# Various helpers
Expand Down Expand Up @@ -72,10 +65,11 @@ let
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs spec
else if spec.type == "tarball" then fetch_tarball pkgs spec
else if spec.type == "tarball" then fetch_tarball pkgs name spec
else if spec.type == "git" then fetch_git spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
else if spec.type == "builtin-url" then fetch_builtin-url spec
else if spec.type == "local" then fetch_local spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
else if spec.type == "builtin-url" then fetch_builtin-url name
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";

Expand All @@ -87,13 +81,23 @@ let
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatStrings = builtins.concatStringsSep "";

# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, sha256 }@attrs:
builtins_fetchTarball = { url, name, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit url; }
fetchTarball { inherit name url; }
else
fetchTarball attrs;

Expand Down
Loading

0 comments on commit e72075f

Please sign in to comment.