Skip to content

Commit

Permalink
feat(nix)!: redirect paths
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Jul 8, 2024
1 parent ba68c16 commit 9bf39ca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/usr/local/containerbase/tools/v2/nix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ function install_tool() {
local file
local arch

# if [[ ${MAJOR} -lt 2 || (${MAJOR} -eq 2 && ${MINOR} -lt 14) ]]; then
# echo "Nix version ${TOOL_VERSION} is not supported! Use v2.14 or higher." >&2
# exit 1
# fi

arch=$(uname -m)
file=$(get_from_url "https://hydra.nixos.org/job/nix/maintenance-${TOOL_VERSION}/buildStatic.${arch}-linux/latest/download-by-type/file/binary-dist")

Expand All @@ -23,6 +28,6 @@ function link_tool() {
local versioned_tool_path
versioned_tool_path=$(find_versioned_tool_path)

shell_wrapper "${TOOL_NAME}" "${versioned_tool_path}/bin"
shell_wrapper "${TOOL_NAME}" "${versioned_tool_path}/bin" "NIX_STORE_DIR=$(get_home_path)/nix/store NIX_DATA_DIR=$(get_home_path)/nix/data NIX_LOG_DIR=$(get_cache_path)/nix/log NIX_STATE_DIR=$(get_home_path)/nix/state NIX_CONF_DIR=$(get_home_path)/nix/conf"
[[ -n $SKIP_VERSION ]] || nix --version
}
2 changes: 1 addition & 1 deletion src/usr/local/containerbase/utils/filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function setup_directories () {
# shellcheck disable=SC2174
mkdir -p -m 775 "${home_path}"
# shellcheck disable=SC2174
mkdir -p -m 775 "${home_path}"/{.config,.local}
mkdir -p -m 775 "${home_path}"/{.cache,.config,.local}

# symlink v2 tools bin and lib
rm -rf "${BIN_DIR}" "${LIB_DIR}"
Expand Down
5 changes: 5 additions & 0 deletions src/usr/local/containerbase/utils/linking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function shell_wrapper () {
local SOURCE=$2
local EXPORTS=$3
local args=$4
local content=$5
TARGET="$(get_bin_path)/${1}"
if [[ -z "$SOURCE" ]]; then
SOURCE=$(command -v "${1}")
Expand All @@ -28,6 +29,10 @@ EOM
echo "export $EXPORTS" >> "$TARGET"
fi

if [ -n "$content" ]; then
echo "$content" >> "$TARGET"
fi

echo "${SOURCE} ${args} \"\$@\"" >> "$TARGET"

set_file_owner "${TARGET}" 775
Expand Down
3 changes: 3 additions & 0 deletions test/nix/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ RUN set -ex; \
--extra-experimental-features flakes \
flake update

RUN set -ex; \
ls -la $USER_HOME; \
true
#--------------------------------------
# final
#--------------------------------------
Expand Down

0 comments on commit 9bf39ca

Please sign in to comment.