Skip to content

Add flake.nix file for Nix/NixOS users #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kstrafe
Copy link
Contributor

@kstrafe kstrafe commented May 11, 2025

This flake defines a development shell for developing argbash. It ensures that all dependencies used to build this project are pinned to a specific version (via a lock file). In this case, make, m4, and autoconf, and sphinx.

This guarantees deterministic build behavior; builds always use the same exact dependencies until the lock file is updated. Any updates to the dependencies on a system level will not be able to break our build if an API or a behavior of such a dependency has changed.

The nixpkgs repository already has a build script for argbash here:

https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name/ar/argbash

But that is just for building the tool so it can be used. A devshell can be defined and used from there, but this patch allows it to be updated when new dependencies come in, allowing us to keep the flake in sync with development of this tool.

This flake defines a development shell for developing argbash. It
ensures that all dependencies used to build this project are pinned to a
specific version (via a lock file). In this case, make, m4, and autoconf,
and sphinx.

This guarantees deterministic build behavior; builds always use the same
exact dependencies until the lock file is updated. Any updates to the
dependencies on a system level will not be able to break our build if an
API or a behavior of such a dependency has changed.

The nixpkgs repository already has a build script for argbash here:

https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name/ar/argbash

But that is just for building the tool so it can be used. A devshell can
be defined and used from there, but this patch allows it to be updated when
new dependencies come in, allowing us to keep the flake in sync with
development of this tool.
@matejak
Copy link
Owner

matejak commented May 11, 2025

The question is whether this is the right place for it. I am now in favor of having distributions as single source of truth of Argbash packaging.
Moreover, I see hashes in your PR content, and this is thin ice - how to make sure that they are correct and up to date?
What can Argbash do to help distributions with packaging, and what is already too much and duplication/getting into the way?

@kstrafe
Copy link
Contributor Author

kstrafe commented May 11, 2025

@matejak this is not for packaging itself, it's just for developers so they can get the correct dependencies to build and test argbash.

The git hashes rev refer to a git hash, since git is content-addressed, this alone guarantees that we're referring to exact dependency versions. The narHash is effectively unnecessary when using git, and more so an artefact due to nix allowing us to refer to arbitrary links such as tarballs. The narHash makes sure said tarball hasn't been modified either accidentally or maliciously.

The hashes are updated once we decide to update our dependencies. It is desired to keep dependencies fixed, such that updates of dependencies (which would be done in a separate nixpkgs commit) don't suddenly break the build. In addition, this allows us to deterministically update our dependencies by running nix flake update, which will update the flake.lock file with the latest git rev of nixpkgs. If the build then breaks with those new dependencies, then we just don't commit that update.

Typically, an update would be run every couple of months, if any of the dependencies had been updated in the nixpkgs branch. I've seen other projects have the same flake file for years. It's just practical to be able to run nix develop for whatever project, get the correct dependencies, and to be able to build it immediately without having to chase down which packages are needed. This change will increase the likelihood of more contributors since they can get to work on developing argbash pretty much immediately.

@matejak
Copy link
Owner

matejak commented May 14, 2025

Would it be possible to connect this to some sort of CI? That would provide some indication that the file is OK, and neutralize my reservations towards introducing distribution-specific content into the project.

@kstrafe
Copy link
Contributor Author

kstrafe commented May 14, 2025

Would be possible, if the CI has the nix package manager installed, then we need to run nix develop and run the standard make check and documentation to make sure all is well.

@matejak
Copy link
Owner

matejak commented May 14, 2025

Don't be shy, look at https://github.com/matejak/argbash/blob/master/.github/workflows/run-tests.yml and feel free to propose anything that is needed - new step, new test...

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