-
Notifications
You must be signed in to change notification settings - Fork 50
Inject the repository commit id in boot menu entries #228
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # SPDX-FileCopyrightText: 2026 Antoine Eiche <antoine.eiche@lewocorp.eu> | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| # nixos-rebuild is wrapped to add the repository HEAD commit id to the added boot menu entry. | ||
| # Note the derivation produced by this nixos-rebuild wrapper then differs from the one produced from the repository itself since it injects the commit id via builtins.getEnv. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a link to the nixos-rebuild wrapper produced by the repository itself and the place where it makes use of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you mean? I added a link to the nixpkgs code using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This comment seems to say there's a different piece of code to look at. Otherwise, can you try to rework the comment? I think I have trouble understanding it after rereading a couple of review passes already. |
||
| # See https://github.com/nixos/nixpkgs/blob/ddce4d809a16b9f0614e76636063282f6fb02908/nixos/modules/misc/label.nix#L69 for details. | ||
| { | ||
| writeShellApplication, | ||
| nixos-rebuild, | ||
| git, | ||
| }: | ||
| writeShellApplication { | ||
| name = "nixos-rebuild"; | ||
| runtimeInputs = [ | ||
| nixos-rebuild | ||
| git | ||
| ]; | ||
| text = '' | ||
| if [ "$(git rev-parse --is-inside-work-tree 2>&1)" != "true" ]; then | ||
| echo "error: the current directory must be a Git repository." | ||
| exit 1 | ||
| fi | ||
| revision=$(git rev-parse HEAD) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if this is run not in a Git repo? Can we have minimal fallback/error-handling here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| export NIXOS_LABEL_VERSION="''${revision:0:7}" | ||
| nixos-rebuild "$@" | ||
| ''; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called
git-aware-nixos-rebuildor something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally called it
nixos-rebuild-git-aware.Actually, i'm a bit confused because in your previous comments, I had understood that you wanted to override
nixos-rebuildwhile exposing the original one via the attributenixos-rebuild-unwrapped.In this fixup commit, I do not modify the attribute
nixos-rebuildbut just add an attributenixos-rebuild-git-aware. This is much simpler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote:
this doesn't say anything about the name of the attribute? shadowing meant that it should shadow the
nixos-rebuildbinary in$PATH, but you can have the attribute namednixos-rebuild-git-awareproducing abin/nixos-rebuildand having anixos-rebuild-git-aware.unwrappedattribute to get you access to the git-unaware attribute?