Skip to content

add nix flake - #216

Open
me-it-is wants to merge 3 commits into
frcsoftware:mainfrom
me-it-is:add-nix-flake
Open

add nix flake#216
me-it-is wants to merge 3 commits into
frcsoftware:mainfrom
me-it-is:add-nix-flake

Conversation

@me-it-is

@me-it-is me-it-is commented Aug 31, 2026

Copy link
Copy Markdown

Description

Add a nix flake that provides a dev-shell for development. This makes it so that someone doing development on nixos or who is using nix as their packages manager doesn't have to keep their own copy of this flake or some other Dev shell.

Meta

currently the flake uses the wrong version of pnpm(10.34.5 rather than 10.16.0) because, nixpkgs only contains the most up to date pnpm for each major version. These are the options that i have thought of

  1. ignore the version mismatch, pnpm re-downloads the correct version anyway but then you have two copies of pnpm taking up space on you machine
  2. update the repos pin to 10.34.5, the nix flake wont do any kind of auto update so we wont have to keep changing the pin
  3. same as 1 but also turn off the auto download, this doesn't download a second copy of pnpm but adds the potential of incompatibility (this shouldn't happen if we trust pnpm to follow SEMVAR)
  4. override the source of the pnpm package to be an older version of pnpm, this could break if the build process changed at all between the latest 10.x and 10.16.0 and would require the user to build pnpm from source (it would be done automatically but still)
  5. pull in the last version of nixpkgs that had pnpm 10.16.0, same thing with building from source but would also require rebuilding whatever dependencies have changed (which given that 10.16.0 was released almost a year ago is basically everything)

One other question that i have whether i should add formatting for the flake in ci or any of the documentation, my logic for not was that these files dont get edited often and to format them requires a nix installation witch would be a pain in ci and also impossible for anyone on windows as nix doesn't support it.

Merge checklist:

Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
@github-actions

Copy link
Copy Markdown

🌐 Preview URL: https://pr-216.frcsoftware.pages.dev

@httphypixelnet

Copy link
Copy Markdown
Contributor

Lgtm, but I don't know enough about nix flakes to be a definitive approval. @spacey-sooty, could you review?

Comment thread flake.nix Outdated
@spacey-sooty

Copy link
Copy Markdown
Member

Small nit, broadly LGTM though I'm no flake expert I always used nix-shell @nullcubee wanna give this a look?

@me-it-is

Copy link
Copy Markdown
Author

So with #217 pnpm is getting bumped to 11.24.0 which is the latest on npm, however currently nixpkgs is on 11.22.0 and the next bump is going to 11.25.0 which is latest but not on npm yet (idk how long it takes to get published). My plan is to just deal with the small version mismatch for now until both are available and then submit another pr to bump pnpm one version

@spacey-sooty

Copy link
Copy Markdown
Member

If this is going to be a common issue do we think it's worth just doing an override and making it part of the version update process?

@me-it-is

Copy link
Copy Markdown
Author

overriding the pnpm source?

@spacey-sooty

Copy link
Copy Markdown
Member

we should just be able to override the version it downloads right?

Comment thread flake.nix
description = "A flake to provide a dev environment for FRC/FTC Software development";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable";

nit: If you're not using any nixos features, you can just use nixpkgs-unstable for more up-to-date packages when you do update the flake.

@nullcubee

Copy link
Copy Markdown

So, similarly to my other comment here, most of the contribution documentation just says to use the latest versions of the dependencies for your OS (or notes a specific version or later), if this is true then I'm not sure how much point there is in pinning pnpm to the specific version marked in the project...? Although pnpm doesn't really take any time to build so idk how much of an issue it really is.

Also, the fact that the nix flake exists and can be used to install the dependencies should be noted in the README/Contributing guide. This could be done in a separate PR however.

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.

4 participants