Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add haskell.nix to release.nix and shell.nix #58

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ hsenv.log
/ghci-tmp
*.dump-*
*.verbose-core2core
.nix
File renamed without changes.
8 changes: 8 additions & 0 deletions nix/deps/nix-haskell-ci/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "reflex-frp",
"repo": "nix-haskell-ci",
"branch": "main",
"private": false,
"rev": "17d1de24e89b9ca2c769d467b093d9c7fe58854e",
"sha256": "01f0dm2rjyiz6dfx8sshdyipmp6vvzx671qnvv88sk6947l0v3cr"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions nix/deps/reflex-platform/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
File renamed without changes.
12 changes: 12 additions & 0 deletions nix/deps/reflex-platform/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
}) {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
8 changes: 8 additions & 0 deletions nix/project/haskell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ compiler ? "ghc910" }:

{
project = {
src = ../../.;
compiler-nix-name = compiler;
};
}
5 changes: 5 additions & 0 deletions nix/release/haskell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ haskellNix ? null }:

let ci = import ../deps/nix-haskell-ci (if haskellNix != null then { inherit haskellNix; } else {});
project = import ../project/haskell.nix {};
in with ci.haskell-nix; buildMatrix { inherit project; targets = matrix.default; }
66 changes: 66 additions & 0 deletions nix/release/reflex-platform.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{ reflex-platform-fun ? import ../deps/reflex-platform
}:

let native-reflex-platform = reflex-platform-fun { __useNewerCompiler = true; };
inherit (native-reflex-platform.nixpkgs) lib;
systems = [
"x86_64-linux"
# "x86_64-darwin"
];

perPlatform = lib.genAttrs systems (system: let
srcFilter =
builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
"release.nix"
".git"
"dist"
"dist-newstyle"
"cabal.haskell-ci"
"cabal.project"
".travis.yml"
]));
reflex-platform = reflex-platform-fun { inherit system; __useNewerCompiler = true; };
compilers = [
"ghc"
"ghcjs"
] ++ lib.optionals (reflex-platform.androidSupport) [
"ghcAndroidAarch64"
"ghcAndroidAarch32"
] ++ lib.optionals (reflex-platform.iosSupport) [
"ghcIosAarch64"
];
nixpkgsGhcs =
let
pkgs = import ../deps/nixpkgs { inherit system; };
nixGhc945 = pkgs.haskell.packages.ghc945.override {
};
nixGhc961 = pkgs.haskell.packages.ghc961.override {
};
in
{
ghc945 = nixGhc945.callCabal2nix "patch" srcFilter {};
ghc961 = nixGhc961.callCabal2nix "patch" srcFilter {};
};
compilerPkgs = lib.genAttrs compilers (ghc: let
reflex-platform = reflex-platform-fun {
inherit system;
__useNewerCompiler = true;
haskellOverlays = [
# Use this package's source for reflex
(self: super: {
_dep = super._dep // {
patch = srcFilter ../../.;
};
})
];
};
in reflex-platform.${ghc}.patch);
in compilerPkgs // nixpkgsGhcs // {
cache = reflex-platform.pinBuildInputs "patch-${system}"
(builtins.attrValues compilerPkgs);
});

metaCache = native-reflex-platform.pinBuildInputs "patch-everywhere"
(map (a: a.cache) (builtins.attrValues perPlatform));

in perPlatform // { inherit metaCache; }
6 changes: 6 additions & 0 deletions nix/shell/haskell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ haskellNix ? null }:

let ci = import ../deps/nix-haskell-ci (if haskellNix != null then { inherit haskellNix; } else {});
haskell = ci.nix-haskell;
project = import ../project/haskell.nix {};
in haskell.project project
15 changes: 15 additions & 0 deletions nix/shell/reflex-platform.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let
rp = import ../deps/reflex-platform { __useNewerCompiler = true; };
pkgs = rp.nixpkgs;
system = builtins.currentSystem;
in
pkgs.mkShell {
name = "shell";
buildInputs = [
pkgs.cabal-install
pkgs.ghcid
];
inputsFrom = [
(import ../release/reflex-platform.nix {}).${system}.ghc.env
];
}
67 changes: 8 additions & 59 deletions release.nix
Original file line number Diff line number Diff line change
@@ -1,62 +1,11 @@
{ reflex-platform-fun ? import ./dep/reflex-platform
}:
{ pkgs ? import <nixpkgs> {} }:

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

perPlatform = lib.genAttrs systems (system: let
reflex-platform = reflex-platform-fun { inherit system; __useNewerCompiler = true; };
compilers = [
"ghc"
"ghcjs"
] ++ lib.optionals (reflex-platform.androidSupport) [
"ghcAndroidAarch64"
"ghcAndroidAarch32"
] ++ lib.optionals (reflex-platform.iosSupport) [
"ghcIosAarch64"
];
nixpkgsGhcs =
let
pkgs = import ./nixpkgs { inherit system; };
nixGhc945 = pkgs.haskell.packages.ghc945.override {
};
nixGhc961 = pkgs.haskell.packages.ghc961.override {
};
in
{
ghc945 = nixGhc945.callCabal2nix "patch" (import ./src.nix) {};
ghc961 = nixGhc961.callCabal2nix "patch" (import ./src.nix) {};
};
compilerPkgs = lib.genAttrs compilers (ghc: let
reflex-platform = reflex-platform-fun {
inherit system;
__useNewerCompiler = true;
haskellOverlays = [
# Use this package's source for reflex
(self: super: {
_dep = super._dep // {
patch = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
"release.nix"
".git"
"dist"
"dist-newstyle"
"cabal.haskell-ci"
"cabal.project"
".travis.yml"
])) ./.;
};
})
];
};
in reflex-platform.${ghc}.patch);
in compilerPkgs // nixpkgsGhcs // {
cache = reflex-platform.pinBuildInputs "patch-${system}"
(builtins.attrValues compilerPkgs);
});
in pkgs.runCommand "release" {} ''
mkdir -p $out

metaCache = native-reflex-platform.pinBuildInputs "patch-everywhere"
(map (a: a.cache) (builtins.attrValues perPlatform));

in perPlatform // { inherit metaCache; }
ln -s ${reflex-platform-release.metaCache} $out/reflex-platform
ln -s ${haskell-nix-release} $out/haskell-nix
''
24 changes: 9 additions & 15 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
let
rp = import ./dep/reflex-platform { __useNewerCompiler = true; };
pkgs = rp.nixpkgs;
system = builtins.currentSystem;
in
pkgs.mkShell {
name = "shell";
buildInputs = [
pkgs.cabal-install
pkgs.ghcid
];
inputsFrom = [
(import ./release.nix {}).${system}.ghc.env
];
}
{ pkgs ? import <nixpkgs> {} }:

let reflex-platform-shell = import ./nix/shell/reflex-platform.nix;
haskell-nix-shell = import ./nix/shell/haskell.nix {};

in {
inherit reflex-platform-shell;
inherit haskell-nix-shell;
}
8 changes: 0 additions & 8 deletions src.nix

This file was deleted.

Loading