Hey everyone!
Introducing NixFS, a FUSE that allows you to access any Nix derivation simply by accessing a corresponding path. NixFS aims to simplify the process of exploring the Nix store and accessing derivations without having to explicitly build them first.
How NixFS Works
NixFS uses a simple directory structure:
/nixfs
└── flake
├── b64
└── str
When you access a path like /nixfs/flake/str/nixpkgs#hello
, NixFS will automatically trigger a build of nixpkgs#hello
. The path will then behave as a symlink to the store path of the build result.
For flakes with /
in their URL, access via /nixfs/flake/str
will make parsing the flake URI too complicated. You can instead access these flakes using the b64
directory, like so: /nixfs/flake/b64/<base64 encoded flake URL>
.
Why?
NixFS was created to address challenges faced when working with distributed compute frameworks like Apache Spark, which often expect you to provide static paths to Python binaries. These frameworks also sometimes propagate absolute paths for binaries from the application driver to executors that may be running on different hosts.
By providing a filesystem-based interface to access Nix derivations, NixFS allows users to seamlessly integrate Nix packages and their dependencies into distributed computing workflows. This eliminates the need for complex workarounds or manual path adjustments when dealing with these frameworks.
Usage
To mount the NixFS filesystem, run:
$ nix run github:illustris/nixfs -- [--debug] [<fuse mount options>] /mount/path
$ /mount/path/flake/str/nixpkgs#hello/bin/hello
Hello, world!
NixOS Module Integration
NixFS can also be integrated as a module in your NixOS configuration. To do this, add the following to your flake.nix
:
{
inputs.nixfs.url = "github:illustris/nixfs";
outputs = {nixpkgs, nixfs, ...}: {
nixosConfigurations.my_machine = {
imports = [ nixfs.nixosModules.nixfs ];
services.nixfs.enable = true;
};
};
}
This will enable the NixFS service on your NixOS machine, automatically mounting the filesystem on startup.
Contribute to NixFS
Feel free to submit issues or pull requests on the GitHub repository.