diff --git a/action.yml b/action.yml index 3afba9e..9121478 100644 --- a/action.yml +++ b/action.yml @@ -45,16 +45,6 @@ inputs: description: | Don't use. For bootstrapping purposes only. - load_nixConfig: - default: true - description: | - Reads out a flakes 'nixConfig' attribute, if there is one, and loads - it into the environment config for old-style commands (`nix-build`, - `nix-store` etc) to pick it up. - - If this cause undesired behaviour, you can switch it off by setting - this to false. - runs: using: "composite" @@ -70,16 +60,6 @@ runs: NIX_ON_TMPFS: ${{ inputs.nix_on_tmpfs }} GITHUB_ACCESS_TOKEN: ${{ inputs.github_access_token }} - - name: Preload nixConfig from Flake - run: ${{ github.action_path }}/read-nix-config-from-flake.sh - shell: bash - env: - LOAD_NIXCONFIG: ${{ inputs.load_nixConfig }} - NIX_VERSION: ${{ inputs.nix_version }} - GH_TOKEN: ${{ inputs.github_access_token }} # used by gh cli - OWNER_AND_REPO: ${{ github.repository }} - SHA: ${{ github.sha }} - branding: icon: zap color: gray-dark diff --git a/read-nix-config-from-flake.sh b/read-nix-config-from-flake.sh deleted file mode 100755 index fe946eb..0000000 --- a/read-nix-config-from-flake.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -set -eu -set -o pipefail - -# Exit early if config loading has not been enabled -[[ "$LOAD_NIXCONFIG" == "true" -|| "$LOAD_NIXCONFIG" == "True" -|| "$LOAD_NIXCONFIG" == "TRUE" -]] || exit 0 - -source "${BASH_SOURCE[0]%/*}/vercomp.sh" -if verlte "$NIX_VERSION" "2.13"; then - echo "Do not load flake config on nix version <= 2.13" - exit 0 -fi - -NIX_CONF_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/nix/nix.conf" - -declare nix_conf -tmp="$(mktemp)" - -flake_file=${flake_file:="$tmp"} -flake_url=${flake_url:="github:$OWNER_AND_REPO/$SHA"} - -# only fetch if not (locally) defined (e.g. for testing) -if [ "$flake_file" = "$tmp" ]; then - gh_err="$(mktemp)" - gh_out="$(mktemp)" - gh api 2>"$gh_err" >"$gh_out" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "/repos/$OWNER_AND_REPO/contents/flake.nix?ref=$SHA" || true - gh_ec=$? - if grep -q "HTTP 404" "$gh_err"; then - echo >&2 "No flake.nix found, not loading config" - exit 0 - else - if [ "$gh_ec" -ne 0 ]; then - echo >&2 "Error when fetching flake.nix: ($gh_ec) $(cat "$gh_err")" - cat >&2 "$gh_out" - exit 1 - elif ! jq -r '.content|gsub("[\n\t]"; "")|@base64d' "$gh_out" >"$flake_file"; then - echo >&2 "Error when parsing flake.nix" - cat >&2 "$gh_err" - cat >&2 "$gh_out" - exit 1 - fi - fi -fi - -nix_conf="$(mktemp -d)/flake-nixConfig.conf" -NIX_CONFIG=$(nix --experimental-features "nix-command" eval --raw --impure --expr '(import '"$flake_file"').nixConfig or {}' --apply "$(<"${BASH_SOURCE[0]%/*}/nix_config.nix")" | tee "$nix_conf") - -NIX_USER_CONF_FILES="$nix_conf:$NIX_CONF_FILE:${NIX_USER_CONF_FILES:-}" - -echo "NIX_USER_CONF_FILES=$NIX_USER_CONF_FILES" >> $GITHUB_ENV