From 519e8941f945a1a1d0eae1eae005dac1c59c7335 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 24 Jun 2026 22:10:46 -0400 Subject: [PATCH] check flakes --- bin/lib/cmds.nu | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/bin/lib/cmds.nu b/bin/lib/cmds.nu index 4705e44..54f3c83 100644 --- a/bin/lib/cmds.nu +++ b/bin/lib/cmds.nu @@ -25,6 +25,43 @@ export def "skyg check" [] { nix flake check --no-build } +# Validate that all versioned flake inputs use the same NixOS release +export def "skyg check-flake-versions" [] { + let flake = "flake.nix" + + if not ($flake | path exists) { + print "check-flake-versions: flake.nix not found, skipping" + return + } + + # Only scan url lines to avoid false positives from embedded script strings + let url_lines = (open $flake | lines | enumerate | where { |row| + ($row.item | str contains "url") and ($row.item =~ 'release-\d+\.\d+') + }) + + let versions = ($url_lines + | each { |row| $row.item | parse --regex '.*release-(?P\d+\.\d+).*' | get version } + | flatten + | uniq) + + if ($versions | length) <= 1 { + print "check-flake-versions: OK" + return + } + + print "check-flake-versions: mismatched NixOS release versions in flake.nix:" + print "" + for version in $versions { + print $" release-($version):" + $url_lines | where { |row| $row.item | str contains $"release-($version)" } | each { |row| + print $" line ($row.index + 1): ($row.item | str trim)" + } + } + print "" + print "All versioned inputs (home-manager, stylix, etc.) must use the same NixOS release." + error make { msg: "Mismatched NixOS release versions" } +} + # rollback configuration export def "skyg rollback" [] { sudo nixos-rebuild switch --rollback