mirror of
https://github.com/nix-community/nix-direnv.git
synced 2024-09-11 11:35:54 +03:00
Merge pull request #441 from kingarrrt/self-contained
make self-contained
This commit is contained in:
commit
499255d018
47
default.nix
47
default.nix
@ -1,18 +1,53 @@
|
|||||||
{ stdenv, nix, lib }:
|
{ resholve, lib, coreutils, direnv, nix }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
# resholve does not yet support `finalAttrs` call pattern hence `rec`
|
||||||
name = "nix-direnv";
|
# https://github.com/abathur/resholve/issues/107
|
||||||
|
resholve.mkDerivation rec {
|
||||||
|
pname = "nix-direnv";
|
||||||
|
version = "3.0.0";
|
||||||
|
|
||||||
src = ./.;
|
src = builtins.path {
|
||||||
|
path = ./.;
|
||||||
|
name = pname;
|
||||||
|
};
|
||||||
|
|
||||||
|
# drop min version checks which are redundant when built with nix
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
sed -i "2iNIX_BIN_PREFIX=${nix}/bin" direnvrc
|
sed -i "/_require_version bash/,+2d" direnvrc
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
install -m400 -D direnvrc $out/share/nix-direnv/direnvrc
|
install -m400 -D direnvrc $out/share/${pname}/direnvrc
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
solutions = {
|
||||||
|
default = {
|
||||||
|
scripts = [ "share/${pname}/direnvrc" ];
|
||||||
|
interpreter = "none";
|
||||||
|
inputs = [ coreutils direnv nix ];
|
||||||
|
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;
|
||||||
|
execer = [
|
||||||
|
"cannot:${direnv}/bin/direnv"
|
||||||
|
"cannot:${nix}/bin/nix"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A fast, persistent use_nix implementation for direnv";
|
description = "A fast, persistent use_nix implementation for direnv";
|
||||||
homepage = "https://github.com/nix-community/nix-direnv";
|
homepage = "https://github.com/nix-community/nix-direnv";
|
||||||
|
4
direnvrc
4
direnvrc
@ -59,10 +59,6 @@ _nix_direnv_preflight() {
|
|||||||
_nix_direnv_fatal '$direnv environment variable was not defined. Was this script run inside direnv?'
|
_nix_direnv_fatal '$direnv environment variable was not defined. Was this script run inside direnv?'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${NIX_BIN_PREFIX:-} ]]; then
|
|
||||||
PATH_add "$NIX_BIN_PREFIX"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check command min versions, bash check uses $BASH_VERSION with _require_version
|
# check command min versions, bash check uses $BASH_VERSION with _require_version
|
||||||
# instead of _require_cmd_version because _require_cmd_version uses =~ operator which
|
# instead of _require_cmd_version because _require_cmd_version uses =~ operator which
|
||||||
# would be a syntax error on bash < 3
|
# would be a syntax error on bash < 3
|
||||||
|
@ -16,6 +16,7 @@ if [[ "$(git symbolic-ref --short HEAD)" != "master" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sed -Ei "s!(version = ).*!\1\"$version\";!" default.nix
|
||||||
sed -Ei "s!(NIX_DIRENV_VERSION=).*!\1$version!" direnvrc
|
sed -Ei "s!(NIX_DIRENV_VERSION=).*!\1$version!" direnvrc
|
||||||
|
|
||||||
sed -i README.md templates/flake/.envrc \
|
sed -i README.md templates/flake/.envrc \
|
||||||
|
Loading…
Reference in New Issue
Block a user