# Sharing nix-portable store between multiple users

**URL:** https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571
**Category:** Help
**Created:** [December 7, 2023, 7:57am UTC](https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571 "2023-12-07T07:57:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jacg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jacg/32/2653_2.png) [@jacg](https://discourse.nixos.org/u/jacg)
#### Post date: [December 7, 2023, 7:57am UTC](https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571/1 "2023-12-07T07:57:12Z")

</div>

Is it possible to share [nix-portable](https://github.com/DavHau/nix-portable)’s store between multiple users on the same HPC system?

The documentation mentions

```auto
NP_LOCATION where to put the `.nix-portable` dir. (defaults to `$HOME`)

```

among the ‘environment variables [which] are optional and can be used to override the default behaviour of nix-portable’.

Could setting this to point to some shared space, and giving group write-access to it, be a solution?

---

<div class="post-metadata">

### Author: ![wamserma](https://discourse.nixos.org/user_avatar/discourse.nixos.org/wamserma/32/5353_2.png) [@wamserma](https://discourse.nixos.org/u/wamserma)
#### Post date: [December 7, 2023, 9:38am UTC](https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571/2 "2023-12-07T09:38:23Z")

</div>

Not sure how locking to some common data structures is implemented in nix(-portable). This may lead to race conditions when e.g. accessing the sqlite database. If most of the actions are read-only, it might suffice to add a (temporary) overlayfs in between to catch the occasional writes.  
There is also work-in-progress to support multiple store locations in Nix, which should help you share a common base store in a clean way.

---

<div class="post-metadata">

### Author: ![Mic92](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mic92/32/5265_2.png) [@Mic92](https://discourse.nixos.org/u/Mic92)
#### Post date: [December 7, 2023, 9:56am UTC](https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571/3 "2023-12-07T09:56:44Z")

</div>

sqlite has process locks, so race conditions won’t be an issue. but you would need to make it writable by multiple persons somehow. I don’t know if posix acl could solve that.

---

<div class="post-metadata">

### Author: ![jacg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jacg/32/2653_2.png) [@jacg](https://discourse.nixos.org/u/jacg)
#### Post date: [December 7, 2023, 12:30pm UTC](https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571/4 "2023-12-07T12:30:43Z")

</div>

> [@wamserma](#):
>
> There is also work-in-progress to support multiple store locations in Nix

Would you have a pointer so some high-level-ish information about this?

---

<div class="post-metadata">

### Author: ![wamserma](https://discourse.nixos.org/user_avatar/discourse.nixos.org/wamserma/32/5353_2.png) [@wamserma](https://discourse.nixos.org/u/wamserma)
#### Post date: [December 7, 2023, 4:39pm UTC](https://discourse.nixos.org/t/sharing-nix-portable-store-between-multiple-users/36571/5 "2023-12-07T16:39:09Z")

</div>

@jacg

> [@NixOS with shared nix store among compute nodes](https://discourse.nixos.org/t/nixos-with-shared-nix-store-among-compute-nodes/33235):
>
> We managed to install NixOS on the compute nodes of a small HPC cluster and now we face the problem of how to run parallel jobs via SLURM in multiple nodes reading the same dependencies from the nix store. As far as I know there are only two options: The nix store is local per node and the clousures are distributed to the nodes before the execution begins. This seems to be the choice that @markuskowa [was following](https://discourse.nixos.org/t/any-reason-not-to-share-a-read-only-nix-store-mount-between-servers/3657/6). Share the nix store among nodes, so they can directly access the paths. …

> [@Super Colliding Nix Stores](https://discourse.nixos.org/t/super-colliding-nix-stores/28462):
>
> [Replit](https://replit.com/) has teamed up with [Obsidian Systems](https://obsidian.systems/) (@Ericson2314) and [Tweag](https://www.tweag.io/) (@thufschmitt, @ben) to add a Local Overlay Store to Nix that allows merging of multiple (possibly remote) stores. You can read more about the motivation and details for this project on our blog: In the coming weeks, we will be developing these new features, releasing a Nix RFC, and working to upstream it into Nix. Reply here if you have ideas for how this kind of Store could help you out. We’re interested to learn about m…

> <https://github.com/NixOS/rfcs/pull/152>
>
> Add a new \`local-overlay\` store implementation to Nix. This will be a local stor…e that is layered upon another local filesystem store (local store or daemon). This allows locally extending a shared store that is periodically updated with additional store objects.
> 
> \- \[Rendered\](https://github.com/NixLayeredStore/rfcs/blob/local-overlay-store/rfcs/0000-local-overlay-store.md)
> \- \[Blog post\](https://blog.replit.com/super-colliding-nix-stores)
> \- \[Implementation\](https://github.com/NixOS/nix/pull/8397)
> 
> \_This work is sponsored by \[Replit\](https://replit.com/) :sparkles:\_
