[PR #637] [MERGED] Ref/flake #1168

Closed
opened 2026-03-15 11:22:16 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/asciinema/asciinema/pull/637
Author: @Dich0tomy
Created: 6/9/2024
Status: Merged
Merged: 7/22/2024
Merged by: @ku1ik

Base: developHead: ref/flake


📝 Commits (10+)

  • 6233397 ref(nix): switch to flake-parts
  • 06dcba7 ref(nix): make the flake more idiomatic
  • f90a922 ref(nix): access package directly
  • 81306e9 ref(nix): make local path reproducible
  • 4d5e221 ref(nix): split package to default.nix
  • 5f85054 ref(nix): move shell to shell.nix
  • 48c8903 ref(nix): remove unnecessary explicit inputs
  • c094605 style(nix): move formatter to the top
  • c299444 fix(nix): make the package code correct
  • b2bdcf4 chore(nix): bump flake.lock

📊 Changes

4 files changed (+120 additions, -76 deletions)

View changed files

default.nix (+35 -0)
📝 flake.lock (+31 -34)
📝 flake.nix (+30 -42)
shell.nix (+24 -0)

📄 Description

This PR refactors the recently added flake:

  1. Added shell.nix and default.nix for users that don't use flakes and use Nix2

  2. Removed flake-utils and used flake-parts instead, it's way less volatile and has a couple of nice features that could come in handy later (e.g. debugging, really nice modularization)

  3. Changed up a few things to comply with best practices and conventions - like attribute names (nativeBuildInputs vs packages for mkShell), name conventions (pname, name, version for mkDerivation), etc.

  4. Made the source of the derivation reproducible when built locally (src = ./. relies on the current folder name, which if changed can trigger cache misses)

  5. The default.nix and shell.nix are callPackaged, which automatically fills their arguments with nixpkgs packages and allows for easy overriding

  6. Split the package's dependencies into correct categories, in this case only 3 matter:

    • nativeBuildInputs - dependencies which are only needed in the build process and nowhere else (like build tools).
    • buildInputs - dependencies which will be needed by runtime later - static libraries linked into the library, dynamic libraries and such.
    • nativeCheckInputs - native dependencies for tests, this one has a separate category because one may wish to disable checks for the package which would also make the derivation not pull in the unnecessary dependencies.

    For more info on that matter see - https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies

As for the modularization - if you'd like the flake could also be split into actual modules, which would make the flake look something like this and then subsequent modules something like this.

As for maintenance of the package - changes are required if you add Rust libraries that depend on system installed libraries as well or add any kind of resources that would need to be installed into the system later (like man docs, shell completions, icons) - I'm happy to assist with that.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/asciinema/asciinema/pull/637 **Author:** [@Dich0tomy](https://github.com/Dich0tomy) **Created:** 6/9/2024 **Status:** ✅ Merged **Merged:** 7/22/2024 **Merged by:** [@ku1ik](https://github.com/ku1ik) **Base:** `develop` ← **Head:** `ref/flake` --- ### 📝 Commits (10+) - [`6233397`](https://github.com/asciinema/asciinema/commit/6233397dfe041c7ea1bdbb09ca0759d418298d17) ref(nix): switch to flake-parts - [`06dcba7`](https://github.com/asciinema/asciinema/commit/06dcba70d7d78ff31f510b1f274788f9070343b6) ref(nix): make the flake more idiomatic - [`f90a922`](https://github.com/asciinema/asciinema/commit/f90a9225e0f03eb52a3763c333578d612d1cd261) ref(nix): access package directly - [`81306e9`](https://github.com/asciinema/asciinema/commit/81306e93c68939e511f76c2092e1e13467511f4e) ref(nix): make local path reproducible - [`4d5e221`](https://github.com/asciinema/asciinema/commit/4d5e2212e35e799d779210f43375b834ad20a356) ref(nix): split package to default.nix - [`5f85054`](https://github.com/asciinema/asciinema/commit/5f85054405aa0fdcf6f4f9aa2b31b76362a96b5b) ref(nix): move shell to shell.nix - [`48c8903`](https://github.com/asciinema/asciinema/commit/48c89039a6e0ef19a78b7a25a4235c0961fe3f9f) ref(nix): remove unnecessary explicit inputs - [`c094605`](https://github.com/asciinema/asciinema/commit/c09460585a27723a97088cd59fcc958520d5a2c6) style(nix): move formatter to the top - [`c299444`](https://github.com/asciinema/asciinema/commit/c299444bb9b618743598b760c865924c36954160) fix(nix): make the package code correct - [`b2bdcf4`](https://github.com/asciinema/asciinema/commit/b2bdcf4008996bbcf096f28102db67d69218fee0) chore(nix): bump flake.lock ### 📊 Changes **4 files changed** (+120 additions, -76 deletions) <details> <summary>View changed files</summary> ➕ `default.nix` (+35 -0) 📝 `flake.lock` (+31 -34) 📝 `flake.nix` (+30 -42) ➕ `shell.nix` (+24 -0) </details> ### 📄 Description This PR refactors the recently added flake: 1. Added shell.nix and default.nix for users that don't use flakes and use Nix2 2. Removed flake-utils and used flake-parts instead, it's way less volatile and has a couple of nice features that could come in handy later (e.g. debugging, really nice modularization) 3. Changed up a few things to comply with best practices and conventions - like attribute names (`nativeBuildInputs` vs `packages` for `mkShell`), name conventions (`pname`, `name`, `version` for mkDerivation), etc. 4. Made the source of the derivation reproducible when built locally (`src = ./.` relies on the current folder name, which if changed can trigger cache misses) 5. The `default.nix` and `shell.nix` are `callPackage`d, which automatically fills their arguments with `nixpkgs` packages and allows for easy overriding 6. Split the package's dependencies into correct categories, in this case only 3 matter: - `nativeBuildInputs` - dependencies which are only needed in the build process and nowhere else (like build tools). - `buildInputs` - dependencies which will be needed by runtime later - static libraries linked into the library, dynamic libraries and such. - `nativeCheckInputs` - native dependencies for tests, this one has a separate category because one may wish to disable checks for the package which would also make the derivation not pull in the unnecessary dependencies. For more info on that matter see - https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies As for the modularization - if you'd like the flake could also be split into actual modules, which would make the flake [look something like this](https://github.com/Dich0tomy/Dire/blob/trunk/flake.nix) and then [subsequent modules something like this](https://github.com/Dich0tomy/Dire/tree/trunk/nix). As for maintenance of the package - changes are required if you add Rust libraries that depend on system installed libraries as well or add any kind of resources that would need to be installed into the system later (like man docs, shell completions, icons) - I'm happy to assist with that. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-15 11:22:16 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#1168
No description provided.