NixOS: config flake store path for /run/current-system

Is there a way to get the flake store path that was used to generate a system, e.g. the one pointed to by /run/current-system and others?

Specifically I mean the store path that you can get from nix flake metadata in the flake repo itself.

I’m trying to write some tooling around giving myself a reminder to update the flake (to keep nixpkgs up to date), and currently I just look at the flake.lock file in the checked out flake repo itself, but that only tracks whether the flake repo has been updated, but not whether it’s been applied or not, so I’d like to be able to inspect the lock file that was stored in the Nix store when the system was built.

My first thought was to use nix show-derivation -r /run/current-system and parse the output, but I don’t seem to be able to find the source path. It’s very likely I’m looking in the wrong part of the output, but I’m hoping someone can point me in the right direction.

Thanks!

Not by default, but you can include a reference to it somewhere in the generation by interpolating self into a string that makes it somewhere you can find: "${self}"

1 Like

Oh good point. I could just put it in a file that gets dropped into /etc or similar. I’m trying to make things more complicated than they have to be.

Thanks!