Skip to content
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

Add support for building Bashcov with the Nix package manager #78

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

tomeon
Copy link
Collaborator

@tomeon tomeon commented Jul 15, 2023

Relates to #72 .

This branch introduces support for building Bashcov with Nix. My hope is that some of this code can be downstreamed to Nixpkgs to satisfy NixOS/nixpkgs#242854. In the meantime, the changes in this PR permit Nix users to incorporate Bashcov into their Nix environments / NixOS configurations by using either Nix flakes or legacy Nix code-fetching methods.

Additionally, this PR introduces a Nix-based development environment that can be entered by executing nix develop from within the repository. This development environment includes Ruby 3.2, plus bundix for helping to maintain the gemset.nix file that acts as a gem specification for consumption by the Nix bundlerEnv Bundler environment builder.

I plan to add support for executing Nix builds and tests within the GitHub actions workflow introduced in #76.

TODO

  • Add Nix flake check to GItHub actions workflow.
  • Developer documentation (how to enter the Nix development shell, how to update gemset.nix, ...).
  • Consumer documentation (how to install Bashcov using Nix flakes).
  • Sanity checks (e.g. CI test and/or pre-commit hook verifying that gemset.nix is up-to-date).

Needs feedback

  • Where to put developer documentation (maybe in CONTRIBUTING.md, or perhaps a separate doc -- say, HACKING.md).

@tomeon tomeon force-pushed the nix-support branch 5 times, most recently from ddf02cf to 2a19c7a Compare July 30, 2023 13:55
@infertux
Copy link
Owner

infertux commented Aug 2, 2023

@tomeon Thank you for your hard work on this. I have very limited experience with Nix but happy to test this PR whenever you need it.

@tomeon tomeon force-pushed the nix-support branch 3 times, most recently from 24a2fe9 to 35a61bd Compare August 6, 2023 14:13
@tomeon tomeon marked this pull request as ready for review August 6, 2023 14:14
@tomeon tomeon force-pushed the nix-support branch 2 times, most recently from 5cac52b to 287c888 Compare August 6, 2023 17:21
@tomeon
Copy link
Collaborator Author

tomeon commented Aug 6, 2023

@infertux --

I have very limited experience with Nix but happy to test this PR whenever you need it.

Thank you! Sounds like you are the ideal audience for the new INSTALL.md and HACKING.md 🙂 .

Highlighting some other changes: I updated the ci.yml workflow to ignore errors in the nix job that runs nix flake check. This is because that job can fail if the ./Gemfile.nix.lock or gemset.nix become out-of-date with respect to the contents of bashcov.gemspec, and I figured it is likely too onerous to require contributors to keep the Nix-specific assets updated lest their very-probably-not-Nix-specific changes fail CI. To ensure that Nix assets stay up-to-date despite this, I've added a second GitHub Actions workflow that checks whether it is necessary to update Gemfile.nix.lock or gemset.nix, and, if so, opens a PR containing those changes. This workflow uses peter-evans/create-pull-request and runs on a twice-weekly schedule. #80 was created as a test of this process.

@infertux
Copy link
Owner

@tomeon Just FYI I haven't forgotten you but I've been traveling and don't have access to my workstation to try out this Nix stuff properly. I'm looking at the diff and wondering why do we need to have a separate Gemfile.nix.lock file just for Nix? Why can't we use Gemfile.lock?

@tomeon
Copy link
Collaborator Author

tomeon commented Aug 26, 2023

@infertux

[W]hy do we need to have a separate Gemfile.nix.lock file just for Nix? Why can't we use Gemfile.lock?

This is possible, but requires tracking Gemfile.lock with Git. Otherwise nix build and any other Nix commands that trigger building Bashcov would bail out with an error like:

error: getting status of '/nix/store/8rhwb3qc0dsfw9p87s5qwjskzs0r77f2-source/Gemfile.lock': No such file or directory

This is a limitation, or at least a stricture, of Nix flakes.

I figured that the path of least resistance would be to introduce a Nix-specific lockfile, rather than remove Gemfile.lock from .gitignore. Would you prefer to track Gemfile.lock and use it with the Bashcov Nix derivation instead?

Freed-Wu and others added 11 commits April 19, 2024 10:58
NixOS doesn't have /bin/bash. Replace it by `/usr/bin/env bash`.
On most OS, shebangs can only specify a single parameter.
including a definition of the `bashcov` derivation and a
`numtide/devshell`-based development shell.
by not requiring Git for listing the files that should be included in
the gem.  Instead assume that the entire build sandbox source directory
should be included, minus the files in test/, spec/, and features/.
via the following:

   1. cd.sh: replace use of HOME with OLDPWD,
   2. delete.sh: Use `$BASH` rather than `/usr/bin/env bash` as the
      interpreter for `tmp.sh`, and
   3. Use `-execdir` rather than `-exec` when executing scripts with
      `find`.
in order to support systems that do not provide /bin/bash.
if it /bin/bash does not exist.
as this is available in the Nix sandbox while /usr/bin/env (Aruba's
default, used with `/usr/bin/env bash`) is not.
so that `nix flake check` builds and tests `bashcov`.
tomeon and others added 10 commits April 19, 2024 11:07
that includes information on running Bashcov with Nix
which updates `Gemfile.nix.lock` and `gemset.nix` if, and only if, doing
so fixes errors running `nix build`.
that opens a PR with changes to `Gemfile.nix.lock` and `gemset.nix` if
any were made by `update-deps-conservative`.
as such failures may be due to an out-of-date `Gemfile.nix.lock` and/or
`gemset.nix`.
for (among other things) native extension compilation prerequisites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants