Skip to content

Nix flake for isolated GCC-Rust development environment#4545

Open
nsvke wants to merge 1 commit into
Rust-GCC:masterfrom
nsvke:gccrs-nix
Open

Nix flake for isolated GCC-Rust development environment#4545
nsvke wants to merge 1 commit into
Rust-GCC:masterfrom
nsvke:gccrs-nix

Conversation

@nsvke

@nsvke nsvke commented May 6, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a reproducible Nix development environment
for gccrs. It automatically handles all toolchain, glibc, and dependency
configurations.

Provides completely separate environments for 64-bit and 32-bit targets,
automatically preventing linker conflicts.

Injects useful global scripts (gccrs-setup, gccrs-build, gccrs-test, gx,
gccrs-commit-mklog, gccrs-fix-changelog, gccrs-mklog, gccrs-style,
gccrs-verify and gccrs-help) to automate the build process and ensure
GNU commit standards are met effortlessly.

contrib/ChangeLog:

* nix/bash/gccrs-commit-mklog.sh: New file.
* nix/bash/gccrs-fix-changelog.sh: New file.
* nix/bash/gccrs-mklog.sh: New file.
* nix/bash/gccrs-style.sh: New file.
* nix/bash/gccrs-verify.sh: New file.
* nix/flake.lock: New file.
* nix/flake.nix: New file.
* nix/packages/gccrs-contrib-tools.nix: New file.
* nix/packages/gccrs-env-tools.nix: New file.

Comment thread gcc/rust/nix/flake.nix Outdated
description = "Reproducible Nix environment for GCC Rust (gccrs) development";

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we pin this dependency to a specific commit ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was initially relying on the flake.lock file to handle the version pinning, but we can definitely pin the exact commit hash directly in flake.nix if preferred. I can update this in the next commit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Completely forgot about lock file, forget what I said.

Comment thread gcc/rust/nix/flake.nix Outdated
@@ -0,0 +1,249 @@
{

@P-E-P P-E-P May 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the location of this file is incorrect. We should probably put this in $GCC_TOP/contrib/. I can't remember how we usually tag files that should not be sent upstream though.

@dkm probably has a lot of advice and opinions on that matter (and I'd like to hear them)

EDIT: Didn't read that part about the side repository for the flake at first. This would probably help a lot and reduce potential friction when upstreaming.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct, that's really not something we should send upstream, at least not in this form.

It would be nice to have it in contrib/ if it was meant to be shared, but as it's really a gccrs specific thing.

We could have it in gcc/rust/<something> to avoid any mistake. We already have a non-code doc/ subdir.

Or, we could still have it in contrib/, BUT:

TLDR: the easier would be to keep it in rust/ (sent upstream), but the cleaner would be to keep it in contrib/ and be careful.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's fine to keep it in contrib and add it to the hardcoded gerris list. If commits touch both the flake and general gccrs code, then there is an issue with the commit and it should be split up anyways. @P-E-P and @nsvke if you think it would be useful to have it upstream then I'm also okay with putting it in the rust/ folder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree that it should be in the contrib/ folder. It cannot compile the full gcc anyway, as the environment is specifically designed for gccrs. If @P-E-P also approves this location, I can refactor it to work in contrib/.

Comment thread gcc/rust/nix/flake.nix Outdated
];
text = ''
if [ ! -f "contrib/mklog.py" ]; then
echo "Warning: 'contrib/mklog.py' not found! Use in 'gccrs' root folder."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct me if I'm wrong but this shouldn't happen if we retrieve the script from the store, you could use builtin.FilterSource to make it lighter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely right. However, if we proceed with the side-repository approach, the flake won't be able to access this script during the evaluation phase. The source code is only available after the environment is initialized (either via the gccrs-setup command or a manual clone).

Depending on which repository structure we ultimately choose to move forward with, I can definitely rethink and refactor this for the most optimal solution.

@powerboat9 powerboat9 May 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/contrib/gcc-git-customization.sh shows a method for using rev-parse to handle execution outside the root folder.

@dkm

dkm commented May 6, 2026

Copy link
Copy Markdown
Member

I would try to add more info in the commit log. You have the info as the PR description is very well detailed.
Keep in mind that the git repository will probably be live for a long time. It's also really nice to have the basic info in the git log without having to browse github (e.g. think offline work, or if github is down, or if github dies).

@nsvke
nsvke force-pushed the gccrs-nix branch 2 times, most recently from b882b7f to a298338 Compare May 12, 2026 12:29
@nsvke

nsvke commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

I have completed a major refactoring of the Nix environment in my reference repository. To preserve the existing inline comment history, I am not pushing these commits to this draft PR.

@nsvke
nsvke marked this pull request as ready for review June 3, 2026 09:42
@nsvke
nsvke force-pushed the gccrs-nix branch 2 times, most recently from 95fa714 to 9b10a6b Compare July 1, 2026 06:25
@nsvke
nsvke force-pushed the gccrs-nix branch 3 times, most recently from 222bc61 to d27efb9 Compare July 10, 2026 07:35
This commit introduces a reproducible Nix development environment
for gccrs. It automatically handles all toolchain, glibc, and dependency
configurations.

Provides completely separate environments for 64-bit and 32-bit targets,
automatically preventing linker conflicts.

Injects useful global scripts (gccrs-setup, gccrs-build, gccrs-test,
gccrs-exec, gccrs-git, gccrs-commit-mklog, gccrs-fix-changelog,
gccrs-mklog, gccrs-style, gccrs-verify) to automate the build process
and ensure GNU commit standards are met effortlessly.

contrib/ChangeLog:

	* nix/bash/gccrs-commit-mklog.sh: New file.
	* nix/bash/gccrs-fix-changelog.sh: New file.
	* nix/bash/gccrs-mklog.sh: New file.
	* nix/bash/gccrs-style.sh: New file.
	* nix/bash/gccrs-verify.sh: New file.
	* nix/flake.lock: New file.
	* nix/flake.nix: New file.
	* nix/packages/gccrs-contrib-tools.nix: New file.
	* nix/packages/gccrs-env-tools.nix: New file.

Signed-off-by: Enes Cevik <enes@nsvke.com>
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.

5 participants