cachix / install-nix-action

Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.
Apache License 2.0
498 stars 78 forks source link

Specify store in extra_nix_config is not work #177

Closed minizilla closed 1 year ago

minizilla commented 1 year ago

I try to specify custom nix store location with store = ~/nix using extra_nix_config, it confirmed that the config in /etc/nix/nix.conf appended.

$ cat /etc/nix/nix.conf
max-jobs = auto
trusted-users = root runner
access-tokens = github.com=***
store = ~/nix
experimental-features = nix-command flakes
build-users-group = nixbld

However nix command seems to ignore the custom nix store location. For example, I try to cache nix store in ~/nix.

The caching is works by specifying --store ~/nix when running nix develop.

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Nix
        uses: cachix/install-nix-action@v20
      - name: Cache Nix
        uses: actions/cache@v3
        with:
          path: ~/nix
          key: ${{ runner.os }}-nix-${{ hashFiles('flake.nix', 'flake.lock') }}
      - name: Nix develop
        run: nix --store ~/nix develop . --command echo "ok"

But the caching doesn't work if specifying custom store using store = ~/nix in extra_nix_config.

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Nix
        uses: cachix/install-nix-action@v20
        with:
          extra_nix_config: store = ~/nix
      - name: Cache Nix
        uses: actions/cache@v3
        with:
          path: ~/nix
          key: ${{ runner.os }}-nix-${{ hashFiles('flake.nix', 'flake.lock') }}
      - name: Test
        run: nix develop . --command echo "ok"
sandydoo commented 1 year ago

@minizilla, try using the full path to the store. /home/<user>/nix or maybe /root/nix depending on your setup. Does that work?

minizilla commented 1 year ago

Yes it works using /home/runner/nix.