diff --git a/.github/workflows/test-prerelease.yml b/.github/workflows/test-prerelease.yml new file mode 100644 index 0000000..2453d2c --- /dev/null +++ b/.github/workflows/test-prerelease.yml @@ -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" diff --git a/README.md b/README.md index 90682aa..d9852cf 100644 --- a/README.md +++ b/README.md @@ -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 +# ...... +jobs: +# ...... + - 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 +# ...... +jobs: +# ...... + - 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 diff --git a/action.yml b/action.yml index da8fe5c..a85cf3e 100644 --- a/action.yml +++ b/action.yml @@ -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" @@ -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" diff --git a/install-flox.sh b/install-flox.sh index 374fdd4..2905cd4 100755 --- a/install-flox.sh +++ b/install-flox.sh @@ -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)