Skip to content

Commit 8cb3b66

Browse files
committed
Add haskell.nix to release.nix and shell.nix
1 parent bef6f2d commit 8cb3b66

24 files changed

+183
-82
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ hsenv.log
3636
/ghci-tmp
3737
*.dump-*
3838
*.verbose-core2core
39+
.nix
File renamed without changes.

nix/deps/haskell.nix/github.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"owner": "input-output-hk",
3+
"repo": "haskell.nix",
4+
"branch": "master",
5+
"private": false,
6+
"rev": "d8c50dcaf3d3d589829ee9be9d5dba8279b8cc59",
7+
"sha256": "0a5hgryz6nszmy67yf1aks399h2aw0nj845518c4prs5c6ns1z7p"
8+
}
File renamed without changes.
File renamed without changes.

nix/deps/nix-haskell-ci/github.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"owner": "ymeister",
3+
"repo": "nix-haskell-ci",
4+
"branch": "main",
5+
"private": false,
6+
"rev": "d9b08e888c6c6b0e426e23ad81c7d492e519e541",
7+
"sha256": "0b6dn5y6sl24smiw20j4faa6061djv33hfb985gr9s5v17wx8wp7"
8+
}
File renamed without changes.

nix/deps/nix-haskell/default.nix

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
import (import ./thunk.nix)

nix/deps/nix-haskell/github.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"owner": "ymeister",
3+
"repo": "nix-haskell",
4+
"branch": "main",
5+
"private": false,
6+
"rev": "9f4e8b7f09060edca0fdfe1cc3e0125c6ed3bf42",
7+
"sha256": "1054n0m9f15pbg279k1dl7b9398j01mppvz83cns19xrjs2b282m"
8+
}

nix/deps/nix-haskell/thunk.nix

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
3+
if !fetchSubmodules && !private then builtins.fetchTarball {
4+
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
5+
} else (import (builtins.fetchTarball {
6+
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
7+
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
8+
}) {}).fetchFromGitHub {
9+
inherit owner repo rev sha256 fetchSubmodules private;
10+
};
11+
json = builtins.fromJSON (builtins.readFile ./github.json);
12+
in fetch json

nix/deps/nixpkgs/default.nix

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
import (import ./thunk.nix)
File renamed without changes.

nix/deps/nixpkgs/thunk.nix

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
3+
if !fetchSubmodules && !private then builtins.fetchTarball {
4+
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
5+
} else (import (builtins.fetchTarball {
6+
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
7+
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
8+
}) {}).fetchFromGitHub {
9+
inherit owner repo rev sha256 fetchSubmodules private;
10+
};
11+
json = builtins.fromJSON (builtins.readFile ./github.json);
12+
in fetch json

nix/deps/reflex-platform/default.nix

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
import (import ./thunk.nix)
File renamed without changes.

nix/deps/reflex-platform/thunk.nix

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
3+
if !fetchSubmodules && !private then builtins.fetchTarball {
4+
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
5+
} else (import (builtins.fetchTarball {
6+
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
7+
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
8+
}) {}).fetchFromGitHub {
9+
inherit owner repo rev sha256 fetchSubmodules private;
10+
};
11+
json = builtins.fromJSON (builtins.readFile ./github.json);
12+
in fetch json

nix/project/haskell.nix

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ compiler ? "ghc910" }:
2+
3+
{
4+
project = {
5+
src = ../../.;
6+
compiler-nix-name = compiler;
7+
};
8+
}

nix/release/haskell.nix

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ haskellNix ? null }:
2+
3+
let ci = import ../deps/nix-haskell-ci (if haskellNix != null then { inherit haskellNix; } else {});
4+
project = import ../project/haskell.nix {};
5+
in with ci.haskell-nix; buildMatrix { inherit project; targets = matrix.default; }

nix/release/reflex-platform.nix

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{ reflex-platform-fun ? import ../deps/reflex-platform
2+
}:
3+
4+
let native-reflex-platform = reflex-platform-fun { __useNewerCompiler = true; };
5+
inherit (native-reflex-platform.nixpkgs) lib;
6+
systems = [
7+
"x86_64-linux"
8+
# "x86_64-darwin"
9+
];
10+
11+
perPlatform = lib.genAttrs systems (system: let
12+
srcFilter =
13+
builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
14+
"release.nix"
15+
".git"
16+
"dist"
17+
"dist-newstyle"
18+
"cabal.haskell-ci"
19+
"cabal.project"
20+
".travis.yml"
21+
]));
22+
reflex-platform = reflex-platform-fun { inherit system; __useNewerCompiler = true; };
23+
compilers = [
24+
"ghc"
25+
"ghcjs"
26+
] ++ lib.optionals (reflex-platform.androidSupport) [
27+
"ghcAndroidAarch64"
28+
"ghcAndroidAarch32"
29+
] ++ lib.optionals (reflex-platform.iosSupport) [
30+
"ghcIosAarch64"
31+
];
32+
nixpkgsGhcs =
33+
let
34+
pkgs = import ../deps/nixpkgs { inherit system; };
35+
nixGhc945 = pkgs.haskell.packages.ghc945.override {
36+
};
37+
nixGhc961 = pkgs.haskell.packages.ghc961.override {
38+
};
39+
in
40+
{
41+
ghc945 = nixGhc945.callCabal2nix "patch" srcFilter {};
42+
ghc961 = nixGhc961.callCabal2nix "patch" srcFilter {};
43+
};
44+
compilerPkgs = lib.genAttrs compilers (ghc: let
45+
reflex-platform = reflex-platform-fun {
46+
inherit system;
47+
__useNewerCompiler = true;
48+
haskellOverlays = [
49+
# Use this package's source for reflex
50+
(self: super: {
51+
_dep = super._dep // {
52+
patch = srcFilter ../../.;
53+
};
54+
})
55+
];
56+
};
57+
in reflex-platform.${ghc}.patch);
58+
in compilerPkgs // nixpkgsGhcs // {
59+
cache = reflex-platform.pinBuildInputs "patch-${system}"
60+
(builtins.attrValues compilerPkgs);
61+
});
62+
63+
metaCache = native-reflex-platform.pinBuildInputs "patch-everywhere"
64+
(map (a: a.cache) (builtins.attrValues perPlatform));
65+
66+
in perPlatform // { inherit metaCache; }

nix/shell/haskell.nix

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ haskellNix ? ../deps/haskell.nix }:
2+
3+
let haskell = import ../deps/nix-haskell { inherit haskellNix; };
4+
project = import ../project/haskell.nix {};
5+
in haskell.project project;

nix/shell/reflex-platform.nix

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let
2+
rp = import ../deps/reflex-platform { __useNewerCompiler = true; };
3+
pkgs = rp.nixpkgs;
4+
system = builtins.currentSystem;
5+
in
6+
pkgs.mkShell {
7+
name = "shell";
8+
buildInputs = [
9+
pkgs.cabal-install
10+
pkgs.ghcid
11+
];
12+
inputsFrom = [
13+
(import ../release/reflex-platform.nix {}).${system}.ghc.env
14+
];
15+
}

release.nix

+8-59
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,11 @@
1-
{ reflex-platform-fun ? import ./dep/reflex-platform
2-
}:
1+
{ pkgs ? import <nixpkgs> {} }:
32

4-
let
5-
native-reflex-platform = reflex-platform-fun { __useNewerCompiler = true; };
6-
inherit (native-reflex-platform.nixpkgs) lib;
7-
systems = ["x86_64-linux"];
3+
let reflex-platform-release = import ./nix/release/reflex-platform.nix {};
4+
haskell-nix-release = import ./nix/release/haskell.nix {};
85

9-
perPlatform = lib.genAttrs systems (system: let
10-
reflex-platform = reflex-platform-fun { inherit system; __useNewerCompiler = true; };
11-
compilers = [
12-
"ghc"
13-
"ghcjs"
14-
] ++ lib.optionals (reflex-platform.androidSupport) [
15-
"ghcAndroidAarch64"
16-
"ghcAndroidAarch32"
17-
] ++ lib.optionals (reflex-platform.iosSupport) [
18-
"ghcIosAarch64"
19-
];
20-
nixpkgsGhcs =
21-
let
22-
pkgs = import ./nixpkgs { inherit system; };
23-
nixGhc945 = pkgs.haskell.packages.ghc945.override {
24-
};
25-
nixGhc961 = pkgs.haskell.packages.ghc961.override {
26-
};
27-
in
28-
{
29-
ghc945 = nixGhc945.callCabal2nix "patch" (import ./src.nix) {};
30-
ghc961 = nixGhc961.callCabal2nix "patch" (import ./src.nix) {};
31-
};
32-
compilerPkgs = lib.genAttrs compilers (ghc: let
33-
reflex-platform = reflex-platform-fun {
34-
inherit system;
35-
__useNewerCompiler = true;
36-
haskellOverlays = [
37-
# Use this package's source for reflex
38-
(self: super: {
39-
_dep = super._dep // {
40-
patch = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
41-
"release.nix"
42-
".git"
43-
"dist"
44-
"dist-newstyle"
45-
"cabal.haskell-ci"
46-
"cabal.project"
47-
".travis.yml"
48-
])) ./.;
49-
};
50-
})
51-
];
52-
};
53-
in reflex-platform.${ghc}.patch);
54-
in compilerPkgs // nixpkgsGhcs // {
55-
cache = reflex-platform.pinBuildInputs "patch-${system}"
56-
(builtins.attrValues compilerPkgs);
57-
});
6+
in pkgs.runCommand "release" {} ''
7+
mkdir -p $out
588
59-
metaCache = native-reflex-platform.pinBuildInputs "patch-everywhere"
60-
(map (a: a.cache) (builtins.attrValues perPlatform));
61-
62-
in perPlatform // { inherit metaCache; }
9+
ln -s ${reflex-platform-release.metaCache} $out/reflex-platform
10+
ln -s ${haskell-nix-release} $out/haskell-nix
11+
''

shell.nix

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
let
2-
rp = import ./dep/reflex-platform { __useNewerCompiler = true; };
3-
pkgs = rp.nixpkgs;
4-
system = builtins.currentSystem;
5-
in
6-
pkgs.mkShell {
7-
name = "shell";
8-
buildInputs = [
9-
pkgs.cabal-install
10-
pkgs.ghcid
11-
];
12-
inputsFrom = [
13-
(import ./release.nix {}).${system}.ghc.env
14-
];
15-
}
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
let reflex-platform-shell = import ./nix/shell/reflex-platform.nix;
4+
haskell-nix-shell = import ./nix/shell/haskell.nix {};
5+
6+
in {
7+
inherit reflex-platform-shell;
8+
inherit haskell-nix-shell;
9+
}

src.nix

-8
This file was deleted.

0 commit comments

Comments
 (0)