Skip to content

feat: add Nix packaging, devshell, and modules#25

Open
KristijanZic wants to merge 1 commit into
orhun:mainfrom
KristijanZic:main
Open

feat: add Nix packaging, devshell, and modules#25
KristijanZic wants to merge 1 commit into
orhun:mainfrom
KristijanZic:main

Conversation

@KristijanZic
Copy link
Copy Markdown

  • Adds a flake.nix using crane and flake-parts for fast caching
  • Provides a development shell with necessary dependencies
  • Exports a Home Manager module to manage ratty.toml
  • Exports a NixOS module to enforce system-wide config
  • Patches hardcoded shell paths for NixOS compatibility

Copy link
Copy Markdown

@vimlinuz vimlinuz left a comment

Choose a reason for hiding this comment

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

lgtm!!!🚀

- Adds a flake.nix using crane and flake-parts for fast caching
- Provides a development shell with necessary dependencies
- Exports a Home Manager module to manage ratty.toml
- Exports a NixOS module to enforce system-wide config
- Patches hardcoded shell paths for NixOS compatibility
@bubylou
Copy link
Copy Markdown

bubylou commented May 11, 2026

This built and ran on NixOS for me but for some reason the rat cursor was a white cube instead of the spinning rat.

Comment thread flake.nix
];

doCheck = false;
postInstall = pkgs.lib.optionalString pkgs.stdenv.isLinux ''
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are tests turned off, were they failing?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

good question!

Copy link
Copy Markdown

@imnotpoz imnotpoz May 12, 2026

Choose a reason for hiding this comment

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

I looked through the repo and didn't find any tests for ratty, which is why I also did doCheck = false; in the nixpkgs package

when nix builds a rust program it first builds it in release mode for the actual binary, then again in debug mode for tests (crane helps with it but you still need to build the ratty crate twice) - that slows down build time considerably and is the reason behind this

if I'm wrong about there being no tests please let me know, I'll update the package

@es-sai-fi
Copy link
Copy Markdown

es-sai-fi commented May 11, 2026

what's the benefit of using flake-parts here?

@KristijanZic KristijanZic mentioned this pull request May 11, 2026
@servrox
Copy link
Copy Markdown

servrox commented May 12, 2026

This built and ran on NixOS for me but for some reason the rat cursor was a white cube instead of the spinning rat.

only got this for some custom models, since ratty falls back to the white cube when the cursor model path resolves to an absolute path outside its asset root. custom models only load reliably when placed under the expected assets/objects layout and referenced by a bare filename.

@orhun
Copy link
Copy Markdown
Owner

orhun commented May 12, 2026

Thanks for the PR! Any chance that we check the Nix flake in the CI as well?

Comment thread flake.nix
inherit src buildInputs nativeBuildInputs;
};

ratty = craneLib.buildPackage {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please move this package to a separate file, you can later still use it in inputsFrom as self.packages.${system}.ratty

Comment thread flake.nix
};
};

nixosModules.default =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same as the package with the nixos and home-manager modules, move them to separate files

I'd suggest nix/package.nix, nix/nixos-module.nix and nix/home-manager-module.nix (or move the modules into their own directory)

Comment thread flake.nix
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread flake.nix
crane,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this could be removed, the attributes that don't depend on the system you could leave as is and the ones that do you can use the following function for:

forEachSystem = nixpkgs.lib.genAttrs (import systems);

where systems is the input mentioned in another comment

otherwise if you don't decide to use that input, replace (import systems) with the array of systems

@KristijanZic
Copy link
Copy Markdown
Author

Thanks for the PR! Any chance that we check the Nix flake in the CI as well?

Yes, I can make a workflow.
I'll gather all the feedback from here and get to work. :)


Thanks everyone for the reviews. I really appreciate it!

@Sporarum
Copy link
Copy Markdown

Maybe this deserves a different issue/PR, but we should also include nix to the install instructions and packaging status!

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.

8 participants