mirror of
https://github.com/infinisil/all-hies.git
synced 2024-11-29 10:02:34 +03:00
Change Nix file to work with multiple versions
This commit is contained in:
parent
536ca14796
commit
b8c0a965e1
41
default.nix
41
default.nix
@ -19,7 +19,7 @@ let
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ghcSpecific = ghcVersion: rec {
|
ghcSpecific = buildName: ghcVersion: rec {
|
||||||
|
|
||||||
# Reformats the ghc version into the format "8.6.4"
|
# Reformats the ghc version into the format "8.6.4"
|
||||||
versionString = lib.concatStringsSep "."
|
versionString = lib.concatStringsSep "."
|
||||||
@ -32,7 +32,7 @@ let
|
|||||||
# Evaluates to a nixpkgs that has the given ghc version in it
|
# Evaluates to a nixpkgs that has the given ghc version in it
|
||||||
pkgs = let
|
pkgs = let
|
||||||
rev = builtins.readFile (./nixpkgsForGhc + "/${ghcVersion}");
|
rev = builtins.readFile (./nixpkgsForGhc + "/${ghcVersion}");
|
||||||
sha256 = builtins.readFile (./generated/nixpkgsHashes + "/${rev}");
|
sha256 = builtins.readFile (./generated + "/${buildName}/nixpkgsHashes/${rev}");
|
||||||
in import (fetchTarball {
|
in import (fetchTarball {
|
||||||
url = "https://github.com/NixOS/nixpkgs/tarball/${rev}";
|
url = "https://github.com/NixOS/nixpkgs/tarball/${rev}";
|
||||||
inherit sha256;
|
inherit sha256;
|
||||||
@ -42,7 +42,7 @@ let
|
|||||||
# (minus a select few)
|
# (minus a select few)
|
||||||
baseLibraryNuller = self: super: let
|
baseLibraryNuller = self: super: let
|
||||||
libs = lib.splitString " "
|
libs = lib.splitString " "
|
||||||
(builtins.readFile (./generated/ghcBaseLibraries + "/${ghcVersion}"));
|
(builtins.readFile (./generated + "/${buildName}/ghcBaseLibraries/${ghcVersion}"));
|
||||||
libNames = map (lib: (builtins.parseDrvName lib).name) libs;
|
libNames = map (lib: (builtins.parseDrvName lib).name) libs;
|
||||||
# It seems that some versions require Cabal and some don't
|
# It seems that some versions require Cabal and some don't
|
||||||
filtered = lib.filter (name: ! lib.elem name [ "ghc" "Cabal" ]) libNames;
|
filtered = lib.filter (name: ! lib.elem name [ "ghc" "Cabal" ]) libNames;
|
||||||
@ -57,10 +57,10 @@ let
|
|||||||
|
|
||||||
|
|
||||||
# Build for a specific GHC version
|
# Build for a specific GHC version
|
||||||
hieBuild = ghcVersion: let
|
hieBuild = buildName: ghcVersion: let
|
||||||
forGhc = ghcSpecific ghcVersion;
|
forGhc = ghcSpecific buildName ghcVersion;
|
||||||
hlib = forGhc.pkgs.haskell.lib;
|
hlib = forGhc.pkgs.haskell.lib;
|
||||||
revision = builtins.readFile ./generated/stack2nix/revision;
|
revision = builtins.readFile (./generated + "/${buildName}/stack2nix/revision");
|
||||||
|
|
||||||
hieOverride = self: super: {
|
hieOverride = self: super: {
|
||||||
haskell-ide-engine = (hlib.overrideCabal super.haskell-ide-engine (old: {
|
haskell-ide-engine = (hlib.overrideCabal super.haskell-ide-engine (old: {
|
||||||
@ -103,7 +103,7 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
expr = import (./generated/stack2nix + "/${ghcVersion}.nix") {
|
expr = import (./generated + "/${buildName}/stack2nix/${ghcVersion}.nix") {
|
||||||
pkgs = forGhc.pkgs;
|
pkgs = forGhc.pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,16 +114,15 @@ let
|
|||||||
# { stable = { ghc864 = <derivation ..>; ... }; unstable = ...; }
|
# { stable = { ghc864 = <derivation ..>; ... }; unstable = ...; }
|
||||||
# Each of which contain binaries hie and hie-$major.$minor.$patch for their
|
# Each of which contain binaries hie and hie-$major.$minor.$patch for their
|
||||||
# GHC version, along with a hie-wrapper binary that knows about this version
|
# GHC version, along with a hie-wrapper binary that knows about this version
|
||||||
allVersions =
|
allVersions = lib.mapAttrs (buildName: _:
|
||||||
let ghcVersionFiles = lib.filterAttrs (file: _: file != "revision")
|
let ghcVersionFiles = lib.filterAttrs (file: _: file != "revision")
|
||||||
(builtins.readDir ./generated/stack2nix);
|
(builtins.readDir (./generated + "/${buildName}/stack2nix"));
|
||||||
in lib.mapAttrs' (ghcVersionFile: _:
|
in lib.mapAttrs' (ghcVersionFile: _:
|
||||||
|
|
||||||
let ghcVersion = lib.removeSuffix ".nix" ghcVersionFile;
|
let ghcVersion = lib.removeSuffix ".nix" ghcVersionFile;
|
||||||
in lib.nameValuePair ghcVersion (hieBuild ghcVersion)
|
in lib.nameValuePair ghcVersion (hieBuild buildName ghcVersion)
|
||||||
|
|
||||||
) ghcVersionFiles;
|
|
||||||
|
|
||||||
|
) ghcVersionFiles) (builtins.readDir ./generated);
|
||||||
|
|
||||||
# Combine a set of HIE versions (given as { <ghcVersion> = <derivation>; })
|
# Combine a set of HIE versions (given as { <ghcVersion> = <derivation>; })
|
||||||
# into a single derivation with the following binaries:
|
# into a single derivation with the following binaries:
|
||||||
@ -180,11 +179,17 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
# Generates a set with the utility functions from a set of versions
|
||||||
|
mkSet = versions: {
|
||||||
inherit combined;
|
inherit combined versions;
|
||||||
versions = allVersions;
|
selection = { selector }: combined (selector versions);
|
||||||
selection = { selector }: combined (selector allVersions);
|
latest = lib.last (lib.attrValues versions);
|
||||||
latest = lib.last (lib.attrValues allVersions);
|
};
|
||||||
|
|
||||||
|
in mkSet allVersions.stable
|
||||||
|
// lib.mapAttrs (_: mkSet) (builtins.removeAttrs allVersions ["stable"])
|
||||||
|
// {
|
||||||
|
# Stable, but fall back to unstable if stable doesn't have a certain GHC
|
||||||
|
# version
|
||||||
|
unstableFallback = mkSet (allVersions.unstable // allVersions.stable);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user