-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
default.nix
72 lines (66 loc) · 1.69 KB
/
default.nix
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
resholve,
lib,
coreutils,
nix,
writeText,
}:
# resholve does not yet support `finalAttrs` call pattern hence `rec`
# https://github.com/abathur/resholve/issues/107
resholve.mkDerivation rec {
pname = "nix-direnv";
version = "3.0.6";
src = builtins.path {
path = ./.;
name = pname;
};
installPhase = ''
install -m400 -D direnvrc $out/share/${pname}/direnvrc
'';
solutions = {
default = {
scripts = [ "share/${pname}/direnvrc" ];
interpreter = "none";
inputs = [ coreutils ];
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"
];
external = [
# We want to reference the ambient Nix when possible, and have custom logic
# for the fallback
"nix"
];
};
keep = {
"$cmd" = true;
"$direnv" = true;
# Nix fallback implementation
"$_nix_direnv_nix" = true;
"$ambient_nix" = true;
"$NIX_DIRENV_FALLBACK_NIX" = true;
};
prologue =
(writeText "prologue.sh" ''
NIX_DIRENV_SKIP_VERSION_CHECK=1
NIX_DIRENV_FALLBACK_NIX=''${NIX_DIRENV_FALLBACK_NIX:-${lib.getExe nix}}
'').outPath;
};
};
meta = with lib; {
description = "A fast, persistent use_nix implementation for direnv";
homepage = "https://github.com/nix-community/nix-direnv";
license = licenses.mit;
platforms = platforms.unix;
};
}