Help understanding inability to create a package on the fly using pkgs.runCommand and reading its content in the same pass

Hello, I haven’t created a minimal version of my problem for fear of hosing my system but I believe this is sufficient (because I feel that the problem is something simple and fundamental I’m missing, please do let me know if I should give a full configuration.nix).

If I put the following inside a let on top of my configuration.nix and proceed to use productVersion in the inside in block …

	productVersionCommand = "${pkgs.coreutils}/bin/cat /sys/class/dmi/id/product_version";
	# productVersionFile = 
	# builtins.trace 
	# 	"productVersionFileReturnedHere" 
	# 	( 
	# 			pkgs.runCommand 
	# 				"product-version" 
	# 				{} 
	# 				"${productVersionCommand} > $out"
	# 	);
	# productVersion = builtins.trace "productVersion" ( builtins.readFile productVersionFile );
	# productVersion = builtins.trace productVersionFile "ThinkCentre M93p\n";
	productVersion = builtins.trace productVersionCommand "ThinkCentre M93p\n";
	# productVersion = builtins.readFile /sys/class/dmi/id/product_version;
	# productVersion = "ThinkCentre M93p\n";

…, I get an error- error: infinite recursion encountered, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:163:28 (use '--show-trace' to show detailed location information). From the outputs and commenting-uncommenting some of the included lines- it seems that the issue is with productVersionCommand evaluation. Would someone be able to help me understand why I’m getting this error? (And if possible- a way to get the output of /sys/class/dmi/id/product_version in my configuration?)

I have another question if it’s alright to ask here- if my understanding is correct then the hash of a realized store path depends only on the .drv and nothing else. Is that correct? If so, will this same derivation give, on two different computers, a store path which is same but has different contents?

I think you will need to give the full configuration for anyone to help you, or at least where productVersion is used. Is it possible that productVersion is somehow needed to evaluate pkgs.coreutils