fix: resolve evaluation purity, missing packages, and brittle paths

This commit is contained in:
Bernardo Magri
2026-04-13 19:50:09 +01:00
parent cabc668c77
commit d9c35f5ff6
13 changed files with 176 additions and 192 deletions

View File

@@ -9,12 +9,7 @@ let
# Unified state reading function
# Handles both JSON and plain text files with graceful fallbacks
readState = { file, default }:
let
# In pure evaluation mode (like nix build .#vm), absolute paths as strings
# will cause an error in pathExists/readFile.
isFileSafe = ! (builtins.isString file && lib.hasPrefix "/" file);
in
if isFileSafe && builtins.pathExists file then
if builtins.pathExists file then
let
content = builtins.readFile file;
cleanContent = lib.removeSuffix "\n" content;