Skip to content

Commit 27185eb

Browse files
authored
Merge pull request #20 from mlabs-haskell/bladyjoker/migrate-haskellFlake
Migrates haskellFlake
2 parents 1a1bba5 + 8dea673 commit 27185eb

File tree

10 files changed

+169
-150
lines changed

10 files changed

+169
-150
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ cabal.sandbox.config
2424
*.hp
2525
*.eventlog
2626
.stack-work/
27-
cabal.project.local
28-
cabal.project.local~
2927
.HTF/
3028
.ghc.environment.*
29+
.direnv/

flake-lang/build.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@
5050
'';
5151
};
5252

53+
haskellData = lib.mkOption {
54+
type = lib.types.functionTo lib.types.attrs;
55+
default = import ./haskell-data.nix pkgs;
56+
readOnly = true;
57+
description = lib.mdDoc ''Makes a derivation containing a Haskell Cabal package with data modules (using Cabal data stanzas)'';
58+
example = lib.mdDoc ''
59+
```haskell
60+
haskellData {
61+
srcs = [ ./. ];
62+
cabalDataPatterns = [ "**/*.json" ];
63+
cabalPackageName = "golden-json-data";
64+
};
65+
```
66+
'';
67+
};
68+
5369
haskellFlake = lib.mkOption {
5470
type = lib.types.functionTo lib.types.attrs;
5571
default = import ./flake-haskell.nix pkgsForHaskellNix;

flake-lang/haskell-data.nix

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Makes a Cabal package with just a 'data' directory with proper 'data-files' stanza
2+
pkgs: { srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }:
3+
let
4+
cabalTemplate = pkgs.writeTextFile {
5+
name = "haskell-data.nix-cabal-template";
6+
text = ''
7+
cabal-version: 3.0
8+
name: ${cabalPackageName}
9+
version: ${cabalPackageVersion}
10+
synopsis: A Cabal project that contains data files
11+
build-type: Simple
12+
data-files: ${builtins.concatStringsSep ", " (builtins.map (d: "data/${d}") cabalDataPatterns)}
13+
14+
library
15+
default-language: Haskell2010
16+
build-depends: base >=4.16
17+
exposed-modules: Paths_${builtins.replaceStrings ["-"] ["_"] cabalPackageName}
18+
'';
19+
};
20+
in
21+
pkgs.stdenv.mkDerivation {
22+
inherit srcs;
23+
name = cabalPackageName;
24+
buildInputs = [
25+
pkgs.cabal-install
26+
];
27+
sourceRoot = ".";
28+
buildPhase = ''
29+
mkdir data;
30+
cp -r -t data ${builtins.concatStringsSep " " (builtins.map (src: "${src}/*") srcs)};
31+
cat ${cabalTemplate} > ${cabalPackageName}.cabal;
32+
'';
33+
34+
installPhase = ''
35+
mkdir $out;
36+
cp -r data $out/;
37+
mv ${cabalPackageName}.cabal $out/;
38+
'';
39+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
repository cardano-haskell-packages
2+
url: https://input-output-hk.github.io/cardano-haskell-packages
3+
secure: True
4+
root-keys:
5+
3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f
6+
443abb7fb497a134c343faf52f0b659bd7999bc06b7f63fa76dc99d631f9bea1
7+
a86a1f6ce86c449c46666bda44268677abf29b5b2d2eb5ec7af903ec2f117a82
8+
bcec67e8e99cabfa7764d75ad9b158d72bfacf70ca1d0ec8bc6b4406d1bf8413
9+
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
10+
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee
11+
12+
allow-newer:
13+
*:base,
14+
*:flat,
15+
*:foundation,
16+
*:containers,
17+
*:directory,
18+
*:time,
19+
*:bytestring,
20+
*:aeson,
21+
*:protolude,
22+
*:template-haskell,
23+
*:ghc-prim,
24+
*:ghc,
25+
*:cryptonite,
26+
*:formatting,
27+
monoidal-containers:aeson,
28+
size-based:template-haskell,
29+
snap-server:attoparsec,
30+
*:hashable,
31+
*:text
32+
33+
constraints:
34+
text >= 2
35+
, aeson >= 2
36+
, protolude >= 0.3.2
37+
, nothunks >= 0.1.3
38+
, plutus-core >= 1.7
39+
40+
package nothunks
41+
flags: +vector +bytestring +text

flake-lang/haskell.nix/extra-hackage.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let
122122
nlib = pkgs.lib;
123123
in
124124
{
125-
_file = "lambda-buffers/extras/haskell.nix/extra-hackage.nix";
125+
_file = "flake-lang.nix/flake-lang/haskell.nix/extra-hackage.nix";
126126
options = with lib.types; {
127127
extraHackage = lib.mkOption {
128128
type = listOf str; # FIXME: Allow passing in a tuple of the src and cabal file instead.

flake-lang/haskell.nix/plutus.nix

Lines changed: 11 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,6 @@ compiler-nix-name: cardano-haskell-packages:
33
{ lib, config, pkgs, ... }:
44
let
55
pkgs' = pkgs;
6-
# https://github.com/input-output-hk/haskell.nix/issues/1177
7-
nonReinstallablePkgs = [
8-
"array"
9-
"base"
10-
"binary"
11-
"bytestring"
12-
"Cabal"
13-
"containers"
14-
"deepseq"
15-
"directory"
16-
"exceptions"
17-
"filepath"
18-
"ghc"
19-
"ghc-bignum"
20-
"ghc-boot"
21-
"ghc-boot"
22-
"ghc-boot-th"
23-
"ghc-compact"
24-
"ghc-heap"
25-
# "ghci"
26-
# "haskeline"
27-
"ghcjs-prim"
28-
"ghcjs-th"
29-
"ghc-prim"
30-
"ghc-prim"
31-
"hpc"
32-
"integer-gmp"
33-
"integer-simple"
34-
"mtl"
35-
"parsec"
36-
"pretty"
37-
"process"
38-
"rts"
39-
"stm"
40-
"template-haskell"
41-
"terminfo"
42-
"text"
43-
"time"
44-
"transformers"
45-
"unix"
46-
"Win32"
47-
"xhtml"
48-
];
496
brokenLibsModule =
507
let
518
responseFile = builtins.toFile "response-file" ''
@@ -66,66 +23,32 @@ let
6623
];
6724
in
6825
{
69-
_file = "lambda-buffers/extras/haskell.nix/plutus.nix:brokenLibsModule";
26+
_file = "flake-lang.nix/flake-lang/haskell.nix/plutus.nix:brokenLibsModule";
7027
packages = builtins.listToAttrs (builtins.map
7128
(name: {
7229
inherit name;
73-
value.components.library.setupHaddockFlags = [ "--haddock-options=@${responseFile}" ];
74-
value.components.library.ghcOptions = [ "-XFlexibleContexts" "-Wwarn" "-fplugin-opt=PlutusTx.Plugin:defer-errors" ];
75-
value.components.library.extraSrcFiles = [ responseFile ];
30+
value.components.library = {
31+
setupHaddockFlags = [ "--haddock-options=@${responseFile}" ];
32+
ghcOptions = [ "-XFlexibleContexts" "-Wwarn" "-fplugin-opt=PlutusTx.Plugin:defer-errors" ];
33+
extraSrcFiles = [ responseFile ];
34+
};
7635
})
7736
l);
7837
};
7938
module = { pkgs, ... }: {
80-
_file = "lambda-buffers/extras/haskell.nix/plutus.nix:module";
39+
_file = "flake-lang.nix/flake-lang/haskell.nix/plutus.nix:module";
8140
# FIXME: contentAddressed = true;
82-
inherit nonReinstallablePkgs; # Needed for a lot of different things
41+
reinstallableLibGhc = false; # See https://github.com/input-output-hk/haskell.nix/issues/1939
8342
packages = {
84-
cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ];
43+
cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 pkgs.libblst ] ];
8544
cardano-crypto-praos.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf ] ];
8645
};
8746
};
8847
in
8948
{
90-
_file = "lambda-buffers/extras/haskell.nix/plutus.nix";
49+
_file = "flake-lang.nix/flake-lang/haskell.nix/plutus.nix";
9150
config = {
92-
cabalProjectLocal = ''
93-
repository cardano-haskell-packages
94-
url: https://input-output-hk.github.io/cardano-haskell-packages
95-
secure: True
96-
root-keys:
97-
key-threshold: 0
98-
99-
allow-newer:
100-
*:base,
101-
*:containers,
102-
*:directory,
103-
*:time,
104-
*:bytestring,
105-
*:aeson,
106-
*:protolude,
107-
*:template-haskell,
108-
*:ghc-prim,
109-
*:ghc,
110-
*:cryptonite,
111-
*:formatting,
112-
monoidal-containers:aeson,
113-
size-based:template-haskell,
114-
snap-server:attoparsec,
115-
-- tasty-hedgehog:hedgehog,
116-
*:hashable,
117-
*:text
118-
119-
constraints:
120-
text >= 2
121-
, aeson >= 2
122-
, dependent-sum >= 0.7
123-
, protolude >= 0.3.2
124-
, nothunks >= 0.1.3
125-
126-
package nothunks
127-
flags: +vector +bytestring +text
128-
'';
51+
cabalProjectLocal = builtins.readFile ./cabal.project.local;
12952
inherit compiler-nix-name;
13053
modules = [ module brokenLibsModule ];
13154
inputMap."https://input-output-hk.github.io/cardano-haskell-packages" = "${cardano-haskell-packages}";

0 commit comments

Comments
 (0)