Skip to content

Commit

Permalink
allow alternative URIs for flox installable (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: Zach Mitchell, PhD <zmitchell@fastmail.com>
  • Loading branch information
aakropotkin and zmitchell authored Jul 11, 2023
1 parent ea48929 commit 1d7e72c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "install-flox-action test pre-release"
on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"

jobs:
install-flox-pre-release:
strategy:
matrix:
os: ["ubuntu-latest"] # macos not yet populated
runs-on: "${{ matrix.os }}"
steps:
- uses: "actions/checkout@v3"
- name: "Install flox pre-release"
uses: "./"
with:
cache-key: "install-flox-action-test"
flox-installable-uri: "github:flox/floxpkgs#flox-prerelease.fromCatalog"
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,42 @@ jobs:
flox nix copy --to "$FLOX_SUBSTITUTER" -v nixpkgs#hello
```
## Use an alternative `flox` executable

You can override the default (latest stable release) executable for `flox`
by providing explicit URIs for either an alternative `floxpkgs`
[flake](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#url-like-syntax)
or `flox`
[installable URI](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html#installables).

For example to use `flox` from a particular `floxpkgs` revision you could set

```yml
# ...<SNIP>...
jobs:
# ...<SNIP>...
- name: Install flox
uses: flox/install-flox-action@v1
with:
floxpkgs-uri: "github:flox/floxpkgs/7df34f186e0a93cc45f8d08c85705c2e18f2ef10"
```

Alternatively you can provide an installable URI for an alternative `flox`
package (useful for working on development builds) with the following:

```yml
# ...<SNIP>...
jobs:
# ...<SNIP>...
- name: Install flox
uses: flox/install-flox-action@v1
with:
# For a local checkout:
flox-installable-uri: ".#flox"
# For the pre-release:
#flox-installable-uri: "github:flox/floxpkgs#flox-prerelease.fromCatalog"
```

## 📫 Have a question? Want to chat? Ran into a problem?

We are happy to welcome you to our [Discourse forum][discourse] and answer your
Expand Down
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ inputs:
description: "AWS access key to upload"
aws-secret-access-key:
description: "AWS secret key to upload"
floxpkgs-uri:
description: |
URI to use when resolving `flox` executable.
Ignored if `flox-installable-uri` is given.
default: "github:flox/floxpkgs"
flox-installable-uri:
required: false
description: |
Absolute installable URI to `flox` executable.
Takes precedence over `floxpkgs-uri` setting.
runs:
using: "composite"
Expand Down Expand Up @@ -74,6 +85,9 @@ runs:
- name: "Install flox"
shell: "bash"
env:
FLOXPKGS_URI: "${{ inputs.floxpkgs-uri }}"
FLOX_INSTALLABLE_URI: "${{ inputs.flox-installable-uri }}"
run: "${{ github.action_path }}/install-flox.sh"

- name: "Setup substituter"
Expand Down
13 changes: 9 additions & 4 deletions install-flox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
set -euo pipefail

if ! type -p nix &>/dev/null ; then
echo "Aborting: Nix is not installed, please configure nix using https://github.com/marketplace/actions/install-nix"
printf '%s' "Aborting: Nix is not installed, please configure nix using " \
"https://github.com/marketplace/actions/install-nix"
exit
fi

# GitHub command to put the following log messages into a group which is collapsed by default
# GitHub command to put the following log messages into a group which is
# collapsed by default
echo "::group::Installing Flox"

: "${FLOXPKGS_URI:=github:flox/floxpkgs}"
: "${FLOX_INSTALLABLE_URI:=$FLOXPKGS_URI#flox.fromCatalog}"

nix profile install --impure \
--experimental-features "nix-command flakes" \
--accept-flake-config \
'github:flox/floxpkgs#flox.fromCatalog'
"$FLOX_INSTALLABLE_URI"

# Check it runs
$HOME/.nix-profile/bin/flox --version
"$HOME/.nix-profile/bin/flox" --version

# This might already be set e.g. if Nix was installed using install-nix-action.
# If Nix was already installed through other means (e.g. on a hosted runner)
Expand Down

0 comments on commit 1d7e72c

Please sign in to comment.