Skip to content

Conversation

@gefjon
Copy link
Contributor

@gefjon gefjon commented Oct 31, 2025

Description of Changes

When building under Nix, Git metadata is not available within the sandbox, as we use lib.cleanSource on our source directory. This is important because it avoids spurious rebuilds and/or determinism hazards.

The build was broken due to our new spacetime init template system accessing Git metadata in the CLI's build.rs
to filter out non-git-tracked files from the templates. The Flake sandbox does this automatically (even without lib.cleanSource!), so when building under Nix it's unnecessary to do twice. (I remain unconvinced that it's necessary to do in non-Nix builds either, as CI builds should have a clean checkout and local dev builds don't need clean templates, but the behavior was already in master and I didn't feel comfortable removing it.)

As an enhancement, I've also found a Nix-ey way to embed our Git commit hash in builds. Previously, builds under Nix had the empty string instead of a commit hash, because we included the git CLI tool but scrubbed the necessary metadata. Now, we inject an environment variable from the Nix flake, and don't make the git CLI tool available at all. This has the convenient upside of allowing Nix builds to reference dirtyRev in builds with a dirty worktree, which should reduce confusion.

API and ABI breaking changes

N/a

Expected complexity level and risk

3? I didn't have a strong understanding of what the CLI build script was doing, and to what extent it was doing things intentionally versus for convenience. As such, it's possible that I've inadvertently damaged something load-bearing.

Testing

  • Built with nix build, ran spacetime init, chose the basic-rust template, and got a reasonable-looking template instantiation.
  • Hopefully we have automated tests for this?

When building under Nix, Git metadata is not available within the sandbox,
as we use `lib.cleanSource` on our source directory.
This is important because it avoids spurious rebuilds and/or determinism hazards.

The build was broken due to our new `spacetime init` template system
accessing Git metadata in the CLI's build.rs
to filter out non-git-tracked files from the templates.
The Flake sandbox does this automatically (even without `lib.cleanSource`!),
so when building under Nix it's unnecessary to do twice.
(I remain unconvinced that it's necessary to do in non-Nix builds either,
as CI builds should have a clean checkout and local dev builds don't need clean templates,
but the behavior was already in master and I didn't feel comfortable removing it.)

As an enhancement, I've also found a Nix-ey way to embed our Git commit hash in builds.
Previously, builds under Nix had the empty string instead of a commit hash,
because we included the `git` CLI tool but scrubbed the necessary metadata.
Now, we inject an environment variable from the Nix flake,
and don't make the `git` CLI tool available at all.
This has the convenient upside of allowing Nix builds to reference `dirtyRev`
in builds with a dirty worktree, which should reduce confusion.
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

This seems fine to me. The CI will also have tested that it can build on non-nix. I am going to approve this, but yeah I think we should rip all this out at some point.

@gefjon gefjon added this pull request to the merge queue Oct 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 31, 2025
@bfops bfops added this pull request to the merge queue Nov 1, 2025
Merged via the queue into master with commit 7345296 Nov 1, 2025
23 of 24 checks passed
bfops pushed a commit that referenced this pull request Nov 6, 2025
…ts (#3551)

# Description of Changes

When building under Nix, Git metadata is not available within the
sandbox, as we use `lib.cleanSource` on our source directory. This is
important because it avoids spurious rebuilds and/or determinism
hazards.

The build was broken due to our new `spacetime init` template system
accessing Git metadata in the CLI's build.rs
to filter out non-git-tracked files from the templates. The Flake
sandbox does this automatically (even without `lib.cleanSource`!), so
when building under Nix it's unnecessary to do twice. (I remain
unconvinced that it's necessary to do in non-Nix builds either, as CI
builds should have a clean checkout and local dev builds don't need
clean templates, but the behavior was already in master and I didn't
feel comfortable removing it.)

As an enhancement, I've also found a Nix-ey way to embed our Git commit
hash in builds. Previously, builds under Nix had the empty string
instead of a commit hash, because we included the `git` CLI tool but
scrubbed the necessary metadata. Now, we inject an environment variable
from the Nix flake, and don't make the `git` CLI tool available at all.
This has the convenient upside of allowing Nix builds to reference
`dirtyRev` in builds with a dirty worktree, which should reduce
confusion.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

3? I didn't have a strong understanding of what the CLI build script was
doing, and to what extent it was doing things intentionally versus for
convenience. As such, it's possible that I've inadvertently damaged
something load-bearing.

# Testing

- [x] Built with `nix build`, ran `spacetime init`, chose the
`basic-rust` template, and got a reasonable-looking template
instantiation.
- [ ] Hopefully we have automated tests for this?
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.

4 participants