about summary refs log tree commit diff
path: root/nixpkgs/pkgs/shells/zsh/zimfw/default.nix
blob: 5f58d3d5e9f9fc8d0fa2de00329b01083cde038f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ stdenv, lib, fetchFromGitHub }:

stdenv.mkDerivation rec {
  pname = "zimfw";
  version = "1.12.0";
  src = fetchFromGitHub {
    owner = "zimfw";
    repo = "zimfw";
    rev = "v${version}";
    ## zim only needs this one file to be installed.
    sparseCheckout = [ "zimfw.zsh" ];
    sha256 = "sha256-PwfPiga4KcOrkkObIu3RCUmO2ExoDQkbQx7S+Yncy6k=";
  };
  strictDeps = true;
  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out
    cp -r $src/zimfw.zsh $out/

    runHook postInstall
  '';

  ## zim automates the downloading of any plugins you specify in the `.zimrc`
  ## file. To do that with Nix, you'll need $ZIM_HOME to be writable.
  ## `~/.cache/zim` is a good place for that. The problem is that zim also
  ## looks for `zimfw.zsh` there, so we're going to tell it here to look for
  ## the `zimfw.zsh` where we currently are.
  postFixup = ''
    substituteInPlace $out/zimfw.zsh \
      --replace "\''${ZIM_HOME}/zimfw.zsh" "$out/zimfw.zsh" \
      --replace "\''${(q-)ZIM_HOME}/zimfw.zsh" "$out/zimfw.zsh"
  '';

  meta = with lib; {
    description =
      "The Zsh configuration framework with blazing speed and modular extensions";
    homepage = "https://zimfw.sh";
    license = licenses.mit;
    maintainers = [ maintainers.joedevivo ];
    platforms = platforms.all;
  };
}