-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[OS-Release] Set image_id to NixOS-based system build toplevel on NixOS systems #3223
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Mathieu Grzybek <[email protected]>
Signed-off-by: Mathieu Grzybek <[email protected]>
Signed-off-by: Mathieu Grzybek <[email protected]>
…S use case Signed-off-by: Mathieu Grzybek <[email protected]>
Hi @SuperQ and @discordianfish, This PR is ready for human validation. The changes are quite small, I hope the code is fine for you. In the end I removed some content from Regards, |
NixOS Infra uses a small python script, that exposes various things as a textfile. Ideally we could extract, package and expose that with node-exporter downstream in nixpkgs. https://github.com/NixOS/infra/tree/main/modules/prometheus/nixos-exporter |
I managed to adapt my code in order to get the data directly from the nix store sqlite database:
However the Is it acceptable to add this dependancy? What's the procedure? |
This seems like an issue for NixOS, it needs to include an |
I'm not a NixOS expert but you seem to tell me that I can set IMAGE_ID and IMAGE_VERSION using my nix configuration. Such as: system.image = {
version = system.build.toplevel; # Using lib.strings.splitString to extract the hash
id = "";
} Is it right? |
Yes, that looks correct. I suppose we really only set it for actual images. |
Context
image_id
is empty on NixOS systems.Why is it useful?
While managing upgrades, checking the drift is very important. Comparing the live
image_id
with the desired state from somenix-build
evaluation is very practical.This is why this patch checks if we are running on a NixOS system (
NAME
env variable) and gets the hash from the symlink at/run/current-system
.The test grabs the hash from the local NixOS system or creates a fake