Skip to content

Commit

Permalink
Add installable option
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbode committed Oct 7, 2024
1 parent f927537 commit 4ce5112
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 4 additions & 6 deletions bin/exec-env
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ set -euo pipefail
setup_nix() {
local OLD_PATH=${PATH}

FLAKE_NIX=${MISE_TOOL_OPTS__FLAKE_NIX:-${MISE_PROJECT_ROOT}/flake.nix}
FLAKE_LOCK=${MISE_TOOL_OPTS__FLAKE_LOCK:-${MISE_PROJECT_ROOT}/flake.lock}
local FLAKE_NIX=${MISE_PROJECT_ROOT}/${MISE_TOOL_OPTS__FLAKE_NIX:-flake.nix}
local FLAKE_LOCK=${MISE_PROJECT_ROOT}/${MISE_TOOL_OPTS__FLAKE_LOCK:-flake.lock}
local INSTALLABLE=${MISE_TOOL_OPTS__INSTALLABLE:-.}

read -r _ HASH < <(cat "${FLAKE_NIX}" "${FLAKE_LOCK}" | openssl sha256)

Expand All @@ -19,10 +20,7 @@ setup_nix() {

if [[ ! -e ${HASH_FILE} ]]; then
trap 'rm '"${HASH_FILE}" ERR INT TERM
nix print-dev-env \
--file "${FLAKE_NIX}" \
--reference-lock-file "${FLAKE_LOCK}" \
> "${HASH_FILE}"
nix print-dev-env --reference-lock-file "${FLAKE_LOCK}" "${INSTALLABLE}" > "${HASH_FILE}"
trap - ERR INT TERM
fi

Expand Down
9 changes: 7 additions & 2 deletions mise.plugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
cache-key = [
"""
{% if opts.flake_nix %}
{{ opts.flake_nix }}
{{ opts.flake_nix | canonicalize }}
{% endif %}
""",
"""
{{ [project_root] | concat(with=(opts.flake_nix | default(value='flake.nix'))) | join_path | hash_file }}
""",
"""
{% if opts.flake_lock %}
{{ opts.flake_lock }}
{{ opts.flake_lock | canonicalize }}
{% endif %}
""",
"""
{{ [project_root] | concat(with=(opts.flake_lock | default(value='flake.lock'))) | join_path | hash_file }}
""",
"""
{% if opts.installable %}
{{ opts.installable }}
{% endif %}
""",
]

0 comments on commit 4ce5112

Please sign in to comment.