Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jrmurr/direnv-nix-action
Github composite action to install nix and setup the env with direnv
https://github.com/jrmurr/direnv-nix-action
hacktoberfest nix
Last synced: 4 months ago
JSON representation
Github composite action to install nix and setup the env with direnv
- Host: GitHub
- URL: https://github.com/jrmurr/direnv-nix-action
- Owner: JRMurr
- License: mit
- Created: 2022-10-30T21:04:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-18T13:49:20.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T13:21:28.541Z (4 months ago)
- Topics: hacktoberfest, nix
- Language: Nix
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# direnv-nix-action
This action will install nix with the [cachix nix action](https://github.com/cachix/install-nix-action) and direnv to make nix based workflows easier to setup.
### Example workflow
Assuming you have a nix setup with this flake
```nix
{inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in {
devShells = {
# other dev shells....
CI = pkgs.mkShell { buildInputs = [ pkgs.nodejs-16_x ]; };
};
});
}
```
and an `.envrc` like
```
if [ -z $DEV_SHELL_NAME ]; then
use flake
else
# running in CI
use flake ".#${DEV_SHELL_NAME}"
fi
```Then your workflow can look like
```yaml
name: use nixon: push
env:
DEV_SHELL_NAME: CI
jobs:
build:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3- name: "Setup env"
uses: JRMurr/[email protected]- name: use node
run: node --version
shell: bash
```You can disable Nix installation and configure it before running direnv. For example,
if you use Cachix, you can do:```yaml
name: use nixon: push
env:
DEV_SHELL_NAME: CI
jobs:
build:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3# Docs to use Cachix: https://nix.dev/tutorials/continuous-integration-github-actions
- uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v11
with:
name: mycache
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'- name: "Setup env"
uses: JRMurr/[email protected]
with:
# You already installed nix, so you can disable that step
install-nix: "false"
# You are using Cachix cache, so no need to use Github cache too
cache-store: "false"- name: use node
run: node --version
shell: bash
```