summaryrefslogtreecommitdiff
path: root/overlays/nix-direnv/default.nix
blob: 7c488e4eec7768f641febebfb3ebc4beb8634f4a (plain)
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
47
48
49
50
51
52
53
{ final, prev, ... }: {
  nix-direnv = prev.resholve.mkDerivation rec {
    pname = "nix-direnv";
    version = "3.0.6";

    patches = [
      ./static-nix.patch
    ];

    src = prev.fetchFromGitHub {
      owner = "nix-community";
      repo = "nix-direnv";
      rev = version;
      hash = "sha256-oNqhPqgQT92yxbKmcgX4F3e2yTUPyXYG7b2xQm3TvQw=";
    };

    installPhase = ''
      runHook preInstall
      install -m400 -D direnvrc $out/share/nix-direnv/direnvrc
      runHook postInstall
    '';

    solutions = {
      default = {
        scripts = [ "share/nix-direnv/direnvrc" ];
        interpreter = "none";
        inputs = with final; [ coreutils nix-monitored ];
        fake = {
          builtin = [
            "PATH_add"
            "direnv_layout_dir"
            "has"
            "log_error"
            "log_status"
            "watch_file"
          ];
          function = [
            # not really a function - this is in an else branch for macOS/homebrew that
            # cannot be reached when built with nix
            "shasum"
          ];
        };
        keep = {
          "$cmd" = true;
          "$direnv" = true;
        };
        execer = [
          "cannot:${prev.lib.getExe' final.nix-monitored "nix"}"
        ];
      };
    };
  };
}