From ca6a0fa53591ac959ae1008ad785e444edbef0b1 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Mon, 11 Aug 2025 01:52:06 -0400 Subject: [PATCH 1/2] Add example for `nix develop` --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 4ac81e2..b2f08d1 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,20 @@ install-nix-action's own `extra_nix_config` input: substituters = https://hydra.iohk.io https://cache.nixos.org/ ``` +### How do I use `nix develop`? + +`nix develop` can be used for `steps[*].shell`. + +```yaml + # optional step: build devShell in advance for accuracy of subsequent step timing and result +- name: Build devShell + run: nix build --no-link .#devShell.$(uname -m)-linux + +- name: Run a command with nix develop + shell: 'nix develop -c bash -e {0}' + run: echo "hello, pure world!" +``` + ### How do I pass environment variables to commands run with `nix develop` or `nix shell`? Nix runs commands in a restricted environment by default, called `pure mode`. From a23271bac0db40f14618c3746894ec13a5bc45cc Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Fri, 15 Aug 2025 15:14:07 -0400 Subject: [PATCH 2/2] Reword README.md section on `nix develop` Addresses feedback from @sandydoo https://github.com/cachix/install-nix-action/pull/248#pullrequestreview-3121533041 --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b2f08d1..30be585 100644 --- a/README.md +++ b/README.md @@ -155,14 +155,16 @@ install-nix-action's own `extra_nix_config` input: substituters = https://hydra.iohk.io https://cache.nixos.org/ ``` -### How do I use `nix develop`? +### How do I configure steps to use my flake's development environment? -`nix develop` can be used for `steps[*].shell`. +You can configure [`jobs..steps[*].shell`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsshell) +to use `nix develop`. ```yaml - # optional step: build devShell in advance for accuracy of subsequent step timing and result -- name: Build devShell - run: nix build --no-link .#devShell.$(uname -m)-linux + # (optional) pre-build the shell separately to avoid skewing the run time of the next + # step and have clear point of failure should the shell fail to build +- name: Pre-build devShell + run: nix build --no-link .#devShells.$(nix eval --impure --raw --expr 'builtins.currentSystem').default - name: Run a command with nix develop shell: 'nix develop -c bash -e {0}'