Skip to content

Commit f5bd760

Browse files
committed
Update nix and fix Cabal upper bound
1 parent 5868624 commit f5bd760

File tree

5 files changed

+185
-18
lines changed

5 files changed

+185
-18
lines changed

default.nix

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
{ pkgs ? import nixpkgs (haskellNixpkgsArgs // {
2-
overlays = haskellNixpkgsArgs.overlays ++ [ (import ./nix/overlays/gtk-debug.nix) ];
3-
} // (if system == null then {} else { inherit system; }))
4-
, nixpkgs ? haskellNixSrc + "/nixpkgs"
5-
, haskellNixpkgsArgs ? import haskellNixSrc
6-
, haskellNixSrc ? builtins.fetchTarball {
7-
url = "https://github.com/input-output-hk/haskell.nix/archive/1dd6951d6a56115fd368c5b37b8dab47a90ec45c.tar.gz";
8-
sha256 = "02nhjy90xwg9wrp81cnlczndxags966c71wlbz6n91423a13mc99";
9-
}
10-
, haskellCompiler ? "ghc881"
1+
{ sourcesOverride ? {}
2+
, sources ? import ./nix/sources.nix {} // sourcesOverride
3+
, pkgs ? (import sources."haskell.nix" {}).pkgs
4+
, compiler-nix-name ? "ghc8101"
115
, system ? null
126
}:
13-
pkgs.haskell-nix.cabalProject' {
14-
src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
15-
ghc = pkgs.haskell-nix.compiler.${haskellCompiler};
7+
pkgs.haskell-nix.project {
8+
inherit compiler-nix-name;
9+
src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; name = "jsaddle"; };
1610
}

nix/sources.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"haskell.nix": {
3+
"branch": "master",
4+
"description": "Alternative Haskell Infrastructure for Nixpkgs",
5+
"homepage": "https://input-output-hk.github.io/haskell.nix",
6+
"owner": "input-output-hk",
7+
"repo": "haskell.nix",
8+
"rev": "dddef063af3ea4b76a4d106725f8588766f171bf",
9+
"sha256": "0i7iwvbn4acbmy533lk3a4bv71kpa5ja2mxx7ky3y14rwb1radzr",
10+
"type": "tarball",
11+
"url": "https://github.com/input-output-hk/haskell.nix/archive/dddef063af3ea4b76a4d106725f8588766f171bf.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
14+
"niv": {
15+
"branch": "master",
16+
"description": "Easy dependency management for Nix projects",
17+
"homepage": "https://github.com/nmattia/niv",
18+
"owner": "nmattia",
19+
"repo": "niv",
20+
"rev": "c27f5a6c57de4495045450b6587d4a2c489851c8",
21+
"sha256": "064lyr1661pk7hh7npgxsmk4cni9bc34hb2d6r76qp4cs2hcazim",
22+
"type": "tarball",
23+
"url": "https://github.com/nmattia/niv/archive/c27f5a6c57de4495045450b6587d4a2c489851c8.tar.gz",
24+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+
},
26+
"nixpkgs": {
27+
"branch": "nixos-19.09",
28+
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
29+
"homepage": "https://github.com/NixOS/nixpkgs",
30+
"owner": "NixOS",
31+
"repo": "nixpkgs-channels",
32+
"rev": "289466dd6a11c65a7de4a954d6ebf66c1ad07652",
33+
"sha256": "0r5ja052s86fr54fm1zlhld3fwawz2w1d1gd6vbvpjrpjfyajibn",
34+
"type": "tarball",
35+
"url": "https://github.com/NixOS/nixpkgs-channels/archive/289466dd6a11c65a7de4a954d6ebf66c1ad07652.tar.gz",
36+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
37+
}
38+
}

nix/sources.nix

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# This file has been generated by Niv.
2+
3+
let
4+
5+
#
6+
# The fetchers. fetch_<type> fetches specs of type <type>.
7+
#
8+
9+
fetch_file = pkgs: spec:
10+
if spec.builtin or true then
11+
builtins_fetchurl { inherit (spec) url sha256; }
12+
else
13+
pkgs.fetchurl { inherit (spec) url sha256; };
14+
15+
fetch_tarball = pkgs: spec:
16+
if spec.builtin or true then
17+
builtins_fetchTarball { inherit (spec) url sha256; }
18+
else
19+
pkgs.fetchzip { inherit (spec) url sha256; };
20+
21+
fetch_git = spec:
22+
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
23+
24+
fetch_builtin-tarball = spec:
25+
builtins.trace
26+
''
27+
WARNING:
28+
The niv type "builtin-tarball" will soon be deprecated. You should
29+
instead use `builtin = true`.
30+
31+
$ niv modify <package> -a type=tarball -a builtin=true
32+
''
33+
builtins_fetchTarball { inherit (spec) url sha256; };
34+
35+
fetch_builtin-url = spec:
36+
builtins.trace
37+
''
38+
WARNING:
39+
The niv type "builtin-url" will soon be deprecated. You should
40+
instead use `builtin = true`.
41+
42+
$ niv modify <package> -a type=file -a builtin=true
43+
''
44+
(builtins_fetchurl { inherit (spec) url sha256; });
45+
46+
#
47+
# Various helpers
48+
#
49+
50+
# The set of packages used when specs are fetched using non-builtins.
51+
mkPkgs = sources:
52+
let
53+
sourcesNixpkgs =
54+
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
55+
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
56+
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
57+
in
58+
if builtins.hasAttr "nixpkgs" sources
59+
then sourcesNixpkgs
60+
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
61+
import <nixpkgs> {}
62+
else
63+
abort
64+
''
65+
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
66+
add a package called "nixpkgs" to your sources.json.
67+
'';
68+
69+
# The actual fetching function.
70+
fetch = pkgs: name: spec:
71+
72+
if ! builtins.hasAttr "type" spec then
73+
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
74+
else if spec.type == "file" then fetch_file pkgs spec
75+
else if spec.type == "tarball" then fetch_tarball pkgs spec
76+
else if spec.type == "git" then fetch_git spec
77+
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
78+
else if spec.type == "builtin-url" then fetch_builtin-url spec
79+
else
80+
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
81+
82+
# Ports of functions for older nix versions
83+
84+
# a Nix version of mapAttrs if the built-in doesn't exist
85+
mapAttrs = builtins.mapAttrs or (
86+
f: set: with builtins;
87+
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
88+
);
89+
90+
# fetchTarball version that is compatible between all the versions of Nix
91+
builtins_fetchTarball = { url, sha256 }@attrs:
92+
let
93+
inherit (builtins) lessThan nixVersion fetchTarball;
94+
in
95+
if lessThan nixVersion "1.12" then
96+
fetchTarball { inherit url; }
97+
else
98+
fetchTarball attrs;
99+
100+
# fetchurl version that is compatible between all the versions of Nix
101+
builtins_fetchurl = { url, sha256 }@attrs:
102+
let
103+
inherit (builtins) lessThan nixVersion fetchurl;
104+
in
105+
if lessThan nixVersion "1.12" then
106+
fetchurl { inherit url; }
107+
else
108+
fetchurl attrs;
109+
110+
# Create the final "sources" from the config
111+
mkSources = config:
112+
mapAttrs (
113+
name: spec:
114+
if builtins.hasAttr "outPath" spec
115+
then abort
116+
"The values in sources.json should not have an 'outPath' attribute"
117+
else
118+
spec // { outPath = fetch config.pkgs name spec; }
119+
) config.sources;
120+
121+
# The "config" used by the fetchers
122+
mkConfig =
123+
{ sourcesFile ? ./sources.json
124+
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
125+
, pkgs ? mkPkgs sources
126+
}: rec {
127+
# The sources, i.e. the attribute set of spec name to spec
128+
inherit sources;
129+
130+
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
131+
inherit pkgs;
132+
};
133+
in
134+
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

shell.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
{ haskellCompiler ? "ghc881" }:
2-
(import ./. { inherit haskellCompiler; }).hsPkgs.shellFor {}
3-
1+
{ sourcesOverride ? {}, compiler-nix-name ? "ghc8101" }:
2+
(import ./. { inherit sourcesOverride compiler-nix-name; }).shellFor {
3+
tools = { cabal = "3.2.0.0"; };
4+
}

webkit2gtk3-javascriptcore.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: webkit2gtk3-javascriptcore
2-
Version: 0.14.4.0
2+
Version: 0.14.4.1
33
Synopsis: JavaScriptCore FFI from webkitgtk
44
Description: FFI for JavaScriptCore module from webkitgtk
55
License: BSD3
@@ -25,7 +25,7 @@ Source-Repository head
2525

2626
custom-setup
2727
setup-depends: base >= 4.6,
28-
Cabal >= 1.24 && < 3.1,
28+
Cabal >= 1.24 && < 3.3,
2929
gtk2hs-buildtools >= 0.13.5.4 && < 0.14
3030

3131
Library

0 commit comments

Comments
 (0)