Skip to content

Commit

Permalink
Merge pull request #204 from DougBurke/stackage-update
Browse files Browse the repository at this point in the history
Bump stackage versions
  • Loading branch information
DougBurke committed Jun 26, 2023
2 parents cbcf93c + 285f02a commit eced5e8
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 96 deletions.
45 changes: 15 additions & 30 deletions .github/workflows/hvega-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,22 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["latest"]
ghc:
- "8.4"
- "8.6"
- "8.8"
- "8.10"
- "9.0"
- "9.2"
exclude:
- os: macOS-latest
ghc: 8.4
- os: macOS-latest
ghc: 8.6
- os: macOS-latest
ghc: 8.8
- os: macOS-latest
ghc: 9.2
- os: windows-latest
ghc: 8.4
- os: windows-latest
ghc: 8.6
- os: windows-latest
ghc: 8.8
- os: windows-latest
ghc: 9.2

os: [ubuntu-latest]
ghc-version: ["9.6", "9.4", "9.2", "9.0", "8.10"]

include:
- os: macOS-latest
ghc-version: '9.4'
- os: windows-latest
ghc-version: '9.4'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main'

- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
Expand Down Expand Up @@ -107,16 +91,17 @@ jobs:
strategy:
matrix:
stack: ["latest"]
ghc: ["8.10"]
ghc: ["9.4"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main'

- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
name: Setup Haskell Stack
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
stack-version: ${{ matrix.stack }}

- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
ihaskell-hvega = ps.callCabal2nix "ihaskell-hvega" (gitignore ihaskellvegaDir) {};

in import "${sources.IHaskell}/release.nix" {
compiler = "ghc8107";
compiler = "ghc8107"; # what version is supported nowadays?
nixpkgs = pkgs;
# packages = p: [ hvega ihaskell-hvega ];
packages = p: [ hvega ihaskell-hvega p.aeson p.aeson-pretty p.Frames p.foldl p.formatting p.microlens ];
Expand Down
4 changes: 2 additions & 2 deletions hvega/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{ sources ? import ../nix/sources.nix
, pkgs ? import sources.nixpkgs {}
, compiler ? "ghc8107"
, compiler ? "ghc928"
}:

let
# There must be a better way than this! I just want to avoid
# excessive compilation when using a non-standard compiler.
#
isDefaultCompiler = compiler == "ghc8107";
isDefaultCompiler = compiler == "ghc8107"; # drop HLS for now

# since we are in a sub-directory
# gitignore = pkgs.nix-gitignore.gitignoreSourcePure [ ./.gitignore ];
Expand Down
2 changes: 1 addition & 1 deletion hvega/shell.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ compiler ? "ghc8107"
{ compiler ? "ghc928"
}:
(import ./default.nix { compiler = compiler; }).shell
2 changes: 1 addition & 1 deletion hvega/stack-9.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ packages:

extra-deps: []

resolver: lts-19.11
resolver: lts-19.33
2 changes: 1 addition & 1 deletion hvega/stack-9.2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ packages:

extra-deps: []

resolver: nightly-2022-06-15
resolver: lts-20.26
8 changes: 8 additions & 0 deletions hvega/stack-nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
flags: {}

packages:
- .

extra-deps: []

resolver: nightly-2023-06-26
2 changes: 1 addition & 1 deletion hvega/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ packages:

extra-deps: []

resolver: lts-18.28
resolver: lts-21.0
2 changes: 1 addition & 1 deletion ihaskell-hvega/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ sources ? import ../nix/sources.nix
, pkgs ? import sources.nixpkgs {}
, compiler ? "ghc8107"
, compiler ? "ghc928"
}:

let
Expand Down
2 changes: 1 addition & 1 deletion ihaskell-hvega/shell.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ compiler ? "ghc8107"
{ compiler ? "ghc928"
}:
(import ./default.nix { compiler = compiler; }).shell
20 changes: 10 additions & 10 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": null,
"owner": "gibiansky",
"repo": "IHaskell",
"rev": "7e69c7e176ba234d29a57fcdff8d1bba04e34ab4",
"sha256": "0ry2l1g5z04n5l3991p361fs9andbr7disiwamx09sbx0cn7wwm2",
"rev": "c547ee2fdc0a09cf4129b19292147fec38527a55",
"sha256": "0ail2r2kn1zlsny6f4sjrw6zs9kfj69ip82cf46da7kn2rv155cn",
"type": "tarball",
"url": "https://github.com/gibiansky/IHaskell/archive/7e69c7e176ba234d29a57fcdff8d1bba04e34ab4.tar.gz",
"url": "https://github.com/gibiansky/IHaskell/archive/c547ee2fdc0a09cf4129b19292147fec38527a55.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
Expand All @@ -17,22 +17,22 @@
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c",
"sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm",
"rev": "914aba08a26cb10538b84d00d6cfb01c9776d80c",
"sha256": "0gx316gc7prjay5b0cr13x4zc2pdbiwxkfkpjvrlb2rml80lm4pm",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz",
"url": "https://github.com/nmattia/niv/archive/914aba08a26cb10538b84d00d6cfb01c9776d80c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-21.11",
"branch": "release-23.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "93a707704d0ba1316cd01a205c3163e764f05fad",
"sha256": "0wd54yc2yih3h43rzyb2k7xj58gnk3wi2lpjh3pgnrq4xmlnvfnl",
"rev": "09798f0dd4c11b431765275893d9d395c1e203b8",
"sha256": "0722086ipwl49a1dxqc4clz3yqa7086a41ya3f2hf67gnnk4xr7q",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/93a707704d0ba1316cd01a205c3163e764f05fad.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/09798f0dd4c11b431765275893d9d395c1e203b8.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
118 changes: 71 additions & 47 deletions nix/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,50 @@ let
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };

fetch_tarball = pkgs: name: spec:
let
name' = sanitizeName 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; };
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 = name: spec:
let
ref =
if spec ? ref then spec.ref else
spec.ref or (
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"
);
submodules = spec.submodules or false;
submoduleArg =
let
nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0;
emptyArgWithWarning =
if submodules
then
builtins.trace
(
"The niv input \"${name}\" uses submodules "
+ "but your nix's (${builtins.nixVersion}) builtins.fetchGit "
+ "does not support them"
)
{ }
else { };
in
if nixSupportsSubmodules
then { inherit submodules; }
else emptyArgWithWarning;
in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
builtins.fetchGit
({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg);

fetch_local = spec: spec.path;

Expand Down Expand Up @@ -66,16 +87,16 @@ let
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> { }
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';

# The actual fetching function.
fetch = pkgs: name: spec:
Expand All @@ -95,13 +116,13 @@ let
# the path directly as opposed to the fetched source.
replace = name: drv:
let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";

# Ports of functions for older nix versions

Expand All @@ -112,7 +133,7 @@ let
);

# 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);
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));
Expand All @@ -123,43 +144,46 @@ let
concatStrings = builtins.concatStringsSep "";

# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {};
optionalAttrs = cond: as: if cond then as else { };

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

# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (name != null) { inherit name; }))
else
fetchurl attrs;

# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
) config.sources;
mapAttrs
(
name: spec:
if builtins.hasAttr "outPath" spec
then
abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
)
config.sources;

# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
, sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem
, pkgs ? mkPkgs sources system
}: rec {
Expand All @@ -171,4 +195,4 @@ let
};

in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

0 comments on commit eced5e8

Please sign in to comment.