| 1 |
|
| 2 |
let |
| 3 |
# An overlay that adds termonad to all haskell package sets. |
| 4 |
haskellPackagesOverlay = self: super: { |
| 5 |
haskell = super.haskell // { |
| 6 |
packageOverrides = hself: hsuper: |
| 7 |
super.haskell.packageOverrides hself hsuper // { |
| 8 |
termonad = |
| 9 |
let |
| 10 |
filesToIgnore = [ |
| 11 |
"default.nix" |
| 12 |
"flake.nix" |
| 13 |
"flake.lock" |
| 14 |
".git" |
| 15 |
".nix-helpers" |
| 16 |
"result" |
| 17 |
"shell.nix" |
| 18 |
".stack-work" |
| 19 |
"stack.yaml" |
| 20 |
"stack-nightly.yaml" |
| 21 |
".travis.yml" |
| 22 |
]; |
| 23 |
|
| 24 |
src = |
| 25 |
builtins.path { |
| 26 |
# Naming this path makes sure that people will get the same |
| 27 |
# hash even if they checkout the termonad repo into a |
| 28 |
# directory called something else. |
| 29 |
name = "termonad-src"; |
| 30 |
path = ./..; |
| 31 |
filter = path: type: |
| 32 |
with self.lib; |
| 33 |
! elem (baseNameOf path) filesToIgnore && |
| 34 |
! any (flip hasPrefix (baseNameOf path)) [ "dist" ".ghc" ]; |
| 35 |
}; |
| 36 |
|
| 37 |
|
| 38 |
extraCabal2nixOptions = |
| 39 |
self.lib.optionalString self.termonadBuildExamples "-fbuildexamples"; |
| 40 |
|
| 41 |
termonadDrv = |
| 42 |
hself.callCabal2nixWithOptions |
| 43 |
"termonad" |
| 44 |
src |
| 45 |
extraCabal2nixOptions |
| 46 |
{ |
| 47 |
# There are Haskell packages called gtk3 and pcre2, which |
| 48 |
# makes these system dependencies not able to be resolved |
| 49 |
# correctly. |
| 50 |
inherit (self) gtk3 pcre2; |
| 51 |
vte_291 = self.vte; |
| 52 |
}; |
| 53 |
in |
| 54 |
termonadDrv; |
| 55 |
}; |
| 56 |
}; |
| 57 |
|
| 58 |
vte = |
| 59 |
if self.termonadEnableSixelSupport then |
| 60 |
super.vte.overrideAttrs (oldAttrs: { |
| 61 |
# As of 2022-10-20, VTE from Nixpkgs doesn't have sixel enabled by default. |
| 62 |
# We enable it here. |
| 63 |
mesonFlags = oldAttrs.mesonFlags ++ [ "-Dsixel=true" ]; |
| 64 |
# As of 2022-10-20, the released version of VTE doesn't even include SIXEL |
| 65 |
# support, because upstream says it still has bugs. See |
| 66 |
# https://github.com/cdepillabout/termonad/pull/221#discussion_r997222069 |
| 67 |
# and https://gitlab.gnome.org/GNOME/vte/-/issues/253 for more information. |
| 68 |
src = self.fetchurl { |
| 69 |
# This is VTE master as of 2022-10-17. |
| 70 |
url = "https://github.com/GNOME/vte/archive/8ef3f6b2f8043d28cbc82520eb094f09333b26ae.tar.gz"; |
| 71 |
sha256 = "sha256-2V3dTTu9EH7sO2NeWWZ7pOurQopV/Ji+muoS6+IMNrA="; |
| 72 |
}; |
| 73 |
}) |
| 74 |
else |
| 75 |
super.vte; |
| 76 |
|
| 77 |
# This defines which compiler version is used to build Termonad. |
| 78 |
# |
| 79 |
# Either this, or termonadKnownWorkingHaskellPkgSet can be changed in an overlay |
| 80 |
# if you want to use a different GHC to build Termonad. |
| 81 |
termonadCompilerVersion = "ghc92"; |
| 82 |
|
| 83 |
# A Haskell package set where we know the GHC version works to compile |
| 84 |
# Termonad. This is basically just a shortcut so that other Nix files |
| 85 |
# don't need to figure out the correct compiler version to use when it is |
| 86 |
# not given by the user. |
| 87 |
termonadKnownWorkingHaskellPkgSet = self.haskell.packages.${self.termonadCompilerVersion}; |
| 88 |
|
| 89 |
# See ./nixpkgs.nix for an explanation of what this does. |
| 90 |
termonadBuildExamples = false; |
| 91 |
|
| 92 |
# See ./nixpkgs.nix for an explanation of what this does. |
| 93 |
termonadIndexTermonad = false; |
| 94 |
|
| 95 |
# See ./nixpkgs.nix for an explanation of what this does. |
| 96 |
termonadEnableSixelSupport = false; |
| 97 |
|
| 98 |
# This is a shell environment for hacking on Termonad with cabal. See the |
| 99 |
# top-level shell.nix for an explanation. |
| 100 |
termonadShell = |
| 101 |
let |
| 102 |
# Nix-shell environment for hacking on termonad. |
| 103 |
termonadEnv = self.termonadKnownWorkingHaskellPkgSet.termonad.env; |
| 104 |
|
| 105 |
# Build tools that are nice to have. It is okay to get Haskell build tools |
| 106 |
# from any Haskell package set, since they do not depend on the GHC version |
| 107 |
# we are using. We get these from the normal haskellPackages pkg set because |
| 108 |
# then they don't have to be compiled from scratch. |
| 109 |
convenientNativeBuildTools = [ |
| 110 |
self.cabal-install |
| 111 |
self.glade |
| 112 |
self.haskellPackages.ghcid |
| 113 |
self.hlint |
| 114 |
self.termonadKnownWorkingHaskellPkgSet.haskell-language-server |
| 115 |
]; |
| 116 |
in |
| 117 |
|
| 118 |
if self.termonadIndexTermonad |
| 119 |
then |
| 120 |
termonadEnv.overrideAttrs (oldAttrs: { |
| 121 |
nativeBuildInputs = |
| 122 |
let |
| 123 |
ghcEnvWithTermonad = |
| 124 |
self.termonadKnownWorkingHaskellPkgSet.ghcWithHoogle (hpkgs: [ hpkgs.termonad ]); |
| 125 |
in |
| 126 |
oldAttrs.nativeBuildInputs ++ convenientNativeBuildTools ++ [ ghcEnvWithTermonad ]; |
| 127 |
# Termonad can't be loaded in `cabal repl` unless GHC knows how to find zlib: |
| 128 |
# https://discourse.nixos.org/t/shared-libraries-error-with-cabal-repl-in-nix-shell/8921/10 |
| 129 |
LD_LIBRARY_PATH = self.lib.makeLibraryPath [ self.zlib ]; |
| 130 |
}) |
| 131 |
else |
| 132 |
self.termonadKnownWorkingHaskellPkgSet.shellFor { |
| 133 |
withHoogle = true; |
| 134 |
packages = hpkgs: [ hpkgs.termonad ]; |
| 135 |
nativeBuildInputs = termonadEnv.nativeBuildInputs ++ convenientNativeBuildTools; |
| 136 |
# Termonad can't be loaded in `cabal repl` unless GHC knows how to find zlib: |
| 137 |
# https://discourse.nixos.org/t/shared-libraries-error-with-cabal-repl-in-nix-shell/8921/10 |
| 138 |
LD_LIBRARY_PATH = self.lib.makeLibraryPath [ self.zlib ]; |
| 139 |
}; |
| 140 |
|
| 141 |
# Default Haskell packages that you can use in your Termonad configuration. |
| 142 |
# This is only used if the user doesn't specify the extraHaskellPackages |
| 143 |
# option. |
| 144 |
termonadExtraHaskellPackages = hpkgs: with hpkgs; [ |
| 145 |
colour |
| 146 |
lens |
| 147 |
]; |
| 148 |
|
| 149 |
termonad-with-packages = |
| 150 |
let |
| 151 |
# GHC environment that has termonad available, as well as the packages |
| 152 |
# specified above in extraHaskellPackages. |
| 153 |
env = |
| 154 |
self.termonadKnownWorkingHaskellPkgSet.ghcWithPackages |
| 155 |
(hpkgs: [ hpkgs.termonad ] ++ self.termonadExtraHaskellPackages hpkgs); |
| 156 |
in |
| 157 |
self.stdenv.mkDerivation { |
| 158 |
name = "termonad-with-packages-ghc-${env.version}"; |
| 159 |
buildInputs = [ |
| 160 |
self.gdk-pixbuf |
| 161 |
self.gnome.adwaita-icon-theme |
| 162 |
self.hicolor-icon-theme |
| 163 |
]; |
| 164 |
nativeBuildInputs = [ self.wrapGAppsHook ]; |
| 165 |
dontBuild = true; |
| 166 |
unpackPhase = ":"; |
| 167 |
# Using installPhase instead of buildCommand was recommended here: |
| 168 |
# https://github.com/cdepillabout/termonad/pull/109 |
| 169 |
installPhase = '' |
| 170 |
runHook preInstall |
| 171 |
mkdir -p $out/bin |
| 172 |
ln -sf ${env}/bin/termonad $out/bin/termonad |
| 173 |
gappsWrapperArgs+=( |
| 174 |
--set NIX_GHC "${env}/bin/ghc" |
| 175 |
) |
| 176 |
runHook postInstall |
| 177 |
''; |
| 178 |
preferLocalBuild = true; |
| 179 |
allowSubstitutes = false; |
| 180 |
}; |
| 181 |
}; |
| 182 |
in |
| 183 |
|
| 184 |
[ haskellPackagesOverlay ] |