mirror of
https://github.com/malob/prefmanager.git
synced 2024-12-14 11:57:49 +00:00
Add support for multiple GHC versions
This commit is contained in:
parent
ce89169795
commit
a7404783f8
4 changed files with 66 additions and 37 deletions
5
constants.nix
Normal file
5
constants.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
name = "prefmanager";
|
||||
ghcVersions = map (v: "ghc${v}") [ "8107" "902" "928" "945" "962" ];
|
||||
defaultGhcVersion = "ghc928";
|
||||
}
|
64
flake.nix
64
flake.nix
|
@ -10,34 +10,54 @@
|
|||
devshell.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, devshell, nixpkgs, flake-utils, plist-source, ... }: {
|
||||
overlays.prefmanager = _: prev: {
|
||||
inherit (self.packages.${prev.stdenv.system}) prefmanager;
|
||||
outputs = { self, devshell, nixpkgs, flake-utils, plist-source, ... }:
|
||||
let
|
||||
inherit (import ./constants.nix) name ghcVersions defaultGhcVersion;
|
||||
in
|
||||
{
|
||||
overlays.${name} = final: prev: {
|
||||
haskell = prev.haskell // {
|
||||
packageOverrides = final.lib.composeExtensions
|
||||
prev.haskell.packageOverrides
|
||||
(hfinal: hprev: {
|
||||
plist = final.haskell.lib.markUnbroken (final.haskell.lib.overrideSrc hprev.plist {
|
||||
src = plist-source;
|
||||
});
|
||||
${name} = hfinal.callCabal2nix name ./. { };
|
||||
});
|
||||
};
|
||||
|
||||
${name} = final.haskell.packages.${defaultGhcVersion}.${name};
|
||||
};
|
||||
} // flake-utils.lib.eachSystem [ "x86_64-darwin" "aarch64-darwin" ] (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
compiler = pkgs.haskell.packages.ghc928;
|
||||
hlib = pkgs.haskell.lib;
|
||||
plist = hlib.markUnbroken (hlib.overrideSrc compiler.plist { src = plist-source; });
|
||||
prefmanager = compiler.callCabal2nix "prefmanager" ./. { inherit plist; };
|
||||
inherit (devshell.legacyPackages.${system}) mkShell;
|
||||
pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.${name} ]; };
|
||||
in
|
||||
{
|
||||
# Built by `nix build .`
|
||||
packages.default = prefmanager;
|
||||
packages.prefmanager = prefmanager;
|
||||
packages = {
|
||||
default = pkgs.${name};
|
||||
${name} = pkgs.${name};
|
||||
|
||||
# Create package for all `ghcVersions`.
|
||||
} // builtins.listToAttrs (map
|
||||
(v: { name = "${name}-${v}"; value = pkgs.haskell.packages.${v}.${name}; })
|
||||
ghcVersions
|
||||
);
|
||||
|
||||
devShells.default = devshell.legacyPackages.${system}.mkShell {
|
||||
inherit name;
|
||||
|
||||
packages = builtins.attrValues {
|
||||
inherit (pkgs.haskell.packages.${defaultGhcVersion})
|
||||
haskell-language-server
|
||||
hlint
|
||||
implicit-hie
|
||||
weeder
|
||||
;
|
||||
|
||||
inherit (pkgs) stack;
|
||||
};
|
||||
|
||||
# # This is used by `nix develop .`
|
||||
devShells.default = mkShell {
|
||||
name = "prefmanager";
|
||||
packages = [
|
||||
compiler.haskell-language-server
|
||||
compiler.implicit-hie
|
||||
# compiler.weeder
|
||||
pkgs.stack
|
||||
pkgs.hlint
|
||||
];
|
||||
commands = [
|
||||
{
|
||||
help = "Regenerate hie.yaml (run from project root)";
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
with import (import ./default.nix).inputs.nixpkgs {};
|
||||
let
|
||||
inherit (import ./constants.nix) name defaultGhcVersion;
|
||||
inherit (import (import ./default.nix).inputs.nixpkgs { }) haskell;
|
||||
in
|
||||
haskell.lib.buildStackProject {
|
||||
ghc = haskell.compiler.ghc928;
|
||||
name = "prefmanager";
|
||||
ghc = haskell.compiler.${defaultGhcVersion};
|
||||
inherit name;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# GHC 9.2.8
|
||||
# Keep in sync with `defaultGhcVersion` in `./constants.nix`.
|
||||
resolver: lts-20.26
|
||||
|
||||
extra-deps:
|
||||
|
|
Loading…
Reference in a new issue