Skip to content

Conversation

@jeff-hykin
Copy link
Contributor

@jeff-hykin jeff-hykin commented Oct 30, 2025

  1. This code doesn't really ever need to be updated (it pulls from the package.json / package-lock.json)
  2. It enables two helpful things:
    1. nix develop drops user's into a shell where everything is installed with exact versions, kind of like docker but without the overhead of a VM
    2. nix build . is a sandboxed reproducable build. E.g. it prevents "well it works on my machine" kind of bugs

This should make for an extremely fast and reliable ZenFS setup from zero:

  • Install nix: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  • Clone the repo: nix run 'nixpkgs#git' clone 'git@github.com:zen-fs/core.git'
  • Enter the dev shell: cd core;nix develop
  • Run tests: npm run build; npm run test

The only maintaince is, run nix flake update when you want to update the version of node.js that it defaults to.

@jeff-hykin jeff-hykin requested a review from james-pre as a code owner October 30, 2025 18:23
@james-pre
Copy link
Member

Hey Jeff, thanks for the PR.

I saw that yarn, corepack, esbuild, and graphviz are included, but ZenFS does use any of them. I also saw the custom zsh and xome stuff. Overall, it looks like a solid way for some users to set up a development environment.

The contributing guidelines documents how to contribute to the project, including building and testing. Any normal Node.js install should just work, especially since ZenFS uses the default way of installing (npm install), testing (npm test), and the de-facto build command (npm run build/npx tsc). I expect any user who has enough technical know-how to use Nix will be able to get a development environment set up just fast (or faster) using normal npm commands.

I don't have enough knowledge about Nix/Nixpkgs right now to decide whether to accept a PR. For security, I use an adversarial mindset when approaching changes, especially any relating to tooling and the supply chain and. This is why nontrivial changes are usually considered in a discussion (or feature request issue) first— it allows for healthy discussion before work takes place. For example, mount namespaces have been discussed at length yet still have open questions regarding implementation.

I'd really appreciate if you could justify why this should be added, and especially why each dependency is being added that isn't already part of ZenFS' tooling. Sorry for the wall of text. Thanks again for contributing!

@james-pre james-pre marked this pull request as draft October 31, 2025 04:16
@jeff-hykin
Copy link
Contributor Author

saw that yarn, corepack, esbuild, and graphviz are included, but ZenFS does use any of them

Fixed. For some reason I was thinking you used yarn (yarn needed corepack). Esbuild and graphviz were leftover from the branch I was doing for isolated context trees.

it allows for healthy discussion before work takes place

No worries. I always get a project running in nix or docker before using it.

justify

Its absolutely fair to be skeptical of stuff, especially given the recent catastrophies over on npm.

(1) Why would be be okay security wise?

Its kind of like packaging a project for fedora, I might not understand or use fedora but, its nice to support the people who do (so long as its not a maintaince burden).

Lots of times the nix community has several competing half-baked flakes for a 3rd party project / codebase. Its less of a risk for them when the project has one that isnt 3 year old flake on github from a no-name Dev that never contributed to the original project and could be updated maliciously without so much as a PR. A central point of communication/maintaince helps the nix community.

The only people who would ever use it are the teams who need reproducible no-bitrot builds.

(2) All engineers have standards for their work, and one standard I have for my work is "never solve the same problem twice".

it should work

That is something I hear everyday. Yet when I have my classroom of students do the thing, the only reliable outcome is that I'm going to be spending hours and hours debugging the systems of the 10% of students where it didnt work. It happens every semester with node projects left and right. Docker has a better rate, its more like 1% failure and that 1% is problems with docker rather than problems with the project. Nix gets it down to about 0.5% and xome (fake home folder) gets it down to about 0.1%.

Theres this story I once told a friend:

One time I ran a hello world from a friend and it almost worked first try. It was pretty cool.

I only needed to install a new OS, package manager, language, modify the system path, update the versions of 116 system packages, manually download some .so files, recompile a native dependency from source, change the library path for gcc, and python, modify 3 system config files, install a couple of drivers, system link a few binaries, add a handful of commands to the bash profile zshrc and etc/bashrc, uninstall and then reinstall python 2, delete a cache folder and a temp folder, set the environment variable for the default editors, restart a system service, update the DNS look-up table, download some GPG keys, suppress old binaries that were auto-added to the path above the new ones, add a few sources to the package manager, install a separate version of python under a different name, edit the system architecture number in a source file, reset the nvrmc cache, change the file permissions on 10 executables after enabling the root user and editing the path of root, adding the aliases from before to the root's bashrc, and then set the default behavior for git, download an old version of bash to run a script from stack overflow suppress a few SSL certificate errors remove some of the shims created by the recently installed library, update some of the pip module that were no longer available for download, and reboot the computer a few times and boom it worked.

It was Practically effortless.

It might work first try for you, it might work first try for many people, but if I'm going to build a massive software platform on top of ZenFS I want it to build with the deterministic reproducibility of a sha256 hash.

Hopefully I never need to use it. But when I open up one of my old university projects from 2017, like a security demo that uses python 2.6 and nodejs 10, it takes me 10 sec to get it running. That is what "not solving the same problem twice" looks like for me.

All that said, I won't feel bad if you dont merge it. I already had to do the work for myself. Also Nix horribly confusing. I'm a big critic of Nix. The language design is terrible, the errors make no sense. Its reliable and my students benefit from that reliability without understanding nix, but thats pretty much where the benefits stop.

mkdir -p "$js_path"
cp -r "$src/." "$js_path"
# make locks writable
chmod +w "$js_path/yarn.lock" 2>/dev/null || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from yarn

@james-pre
Copy link
Member

Theres this story I once told a friend ...

This sounds oddly familier to an experience I had a few months ago! While I've designed ZenFS to require minimal effort for contributors to set up, there could always be edge cases.

but if I'm going to build a massive software platform on top of ZenFS ...

That sounds cool, I'd love to see what use case(s) you have. As a quick aside I'm currently working on @zenfs/linux, a package that will handle the emulation for processes, sysfs, drivers, devices, etc. mentioned in previous deiscussions.

Also Nix horribly confusing.

This is definitly part of my hesitation. I have zero experience using Nix, so I don't feel like I can do a comprehensive audit that meets the quality and security standards of ZenFS.



I have a few questions:

  1. Why merged into @zenfs/core? An unofficial flake would come with the benefits of Nix while also allowing for Nix-specific things that may not align with the current tooling goals of ZenFS
  2. What consumer does the flake target?
    a. Contributors, i.e. getting and working on ZenFS' source
    b. Users, who would just import ... from '@zenfs/core'
    - npm includes hashes (I think they are sha256 too). We could just use npm install @zenfs/core instead of building from source, and check ZenFS' hashes, right?
  3. Do you plan on including this in the nixpkg package manager/repository?
  4. I saw that you maintain xome. What is xome, and why is it required here? Could we remove it?

If you could answer these I think would help me understand the PR better. Happy Halloween!

@jeff-hykin
Copy link
Contributor Author

Well that is a more positive response than I expected 😄

Before I give a bunch of Docker comparisions, are you familiar with docker? E.g. running a dockerfile, pulling an image, etc

I saw that you maintain xome. What is xome, and why is it required here? Could we remove it?

This is really good to talk about. I didn't even think this would PR be considered long enough to get into these details haha. Not only should we talk about xome, for security we should also talk about github:divnix/nixpkgs.lib and other inputs ("github:numtide/flake-utils", "github:NixOS/nixpkgs/nixpkgs-unstable", "github:nix-community/home-manager"). Those "other inputs" are maintained or closely associated with known nix members. Which is good in terms of intent, but still carries some risk.

Once I hear back about docker stuff I'll give a security walkthrough.

Thankfully the conceptual usage of nix is fairly straightforward even if the language/cli/docs are extremely confusing.

@james-pre
Copy link
Member

Yes, I'm familier with Docker. Please feel free to elaborate, I can reference documentation for anything I don't know about already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants