Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache lix installer #8

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ By default, the `github.token` is configured. See https://docs.github.com/en/act
for a description of the default token's permissions.


### `extra_nix_config`

Additional configuration text to append to nix.conf. See https://docs.lix.systems/manual/lix/2.90/command-ref/conf-file.html
for a description of the config file format.


<!-- ACTION.YML INPUTS END -->

---
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ inputs:

By default, the `github.token` is configured. See https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
for a description of the default token's permissions.
extra_nix_config:
description: |
Additional configuration text to append to nix.conf. See https://docs.lix.systems/manual/lix/2.90/command-ref/conf-file.html
for a description of the config file format.
runs:
using: "composite"
steps:
- name: Cache installer
uses: actions/cache@v4
with:
path: /tmp/lix-installer
key: lix-installer-${{ runner.os }}-${{ runner.arch }}
- name: Install Lix
run: bash ${{ github.action_path }}/do-the-lix-thing
shell: bash
env:
INPUT_GITHUB_ACCESS_TOKEN: "${{inputs.github_access_token}}"
GITHUB_TOKEN: "${{github.token}}"
INPUT_EXTRA_CONFIG: "${{inputs.extra_nix_config}}"
12 changes: 11 additions & 1 deletion do-the-lix-thing
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set -o pipefail # the return value of a pipeline is the status of
# Constants
REPO_URL="https://github.com/samueldr/lix-gha-installer-action"
ACTION_NAME="Lix GHA Installer Action"
INSTALLER_DOWNLOAD_DIR="/tmp/lix-installer"
################################################################################


Expand Down Expand Up @@ -126,7 +127,15 @@ trap _handle_exit EXIT
(
set -x

curl -sSf -L https://install.lix.systems/lix | bash -s -- install --no-confirm
_installer_bin="$INSTALLER_DOWNLOAD_DIR/lix-installer"
_etag="$INSTALLER_DOWNLOAD_DIR/etag"
mkdir -p "$(dirname "$_installer_bin")"
if ! [ -f "$_etag" ] || ! curl --head -sSf -L --etag-compare "$_etag" "https://install.lix.systems/lix/lix-installer-$(_get_system)"
then
curl -o "$_installer_bin" -sSf -L --etag-save "$_etag" "https://install.lix.systems/lix/lix-installer-$(_get_system)"
chmod +x "$_installer_bin"
fi
"$_installer_bin" install --no-confirm

(
< /etc/nix/nix.conf sed -e 's/nixpkgs=flake:nixpkgs/nixpkgs=channel:nixos-unstable/'
Expand All @@ -138,6 +147,7 @@ curl -sSf -L https://install.lix.systems/lix | bash -s -- install --no-confirm
printf "extra-access-tokens = github.com=%s\n" "${INPUT_GITHUB_ACCESS_TOKEN}"
fi
printf "trusted-users = root %s\n" "${USER:-}"
echo "${INPUT_EXTRA_CONFIG:-}"
) > tmp.conf
sudo mv -v tmp.conf /etc/nix/nix.conf
)
Expand Down