mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-29 19:30:11 +00:00
nixos-version: escape specialisations and use kernel.modDirVersion if available
This commit is contained in:
@@ -28,15 +28,15 @@ case "$1" in
|
||||
echo "@kernelVersion@"
|
||||
;;
|
||||
--specialisations)
|
||||
if [[ -z "@specialisations@" ]]; then
|
||||
specialisations=@specialisations@
|
||||
if [[ -z "$specialisations" ]]; then
|
||||
echo "$0: no specialisations found" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "@specialisations@"
|
||||
fi
|
||||
printf '%s\n' "$specialisations"
|
||||
;;
|
||||
--json)
|
||||
cat <<EOF
|
||||
cat <<'EOF'
|
||||
@json@
|
||||
EOF
|
||||
;;
|
||||
|
||||
@@ -58,13 +58,19 @@ let
|
||||
inherit (config.system.nixos) version codeName revision;
|
||||
inherit (config.system) configurationRevision;
|
||||
kernelVersion =
|
||||
if config.boot.kernel.enable then config.boot.kernelPackages.kernel.version else null;
|
||||
specialisations = lib.attrNames config.specialisation;
|
||||
if config.boot.kernel.enable then
|
||||
# modDirVersion returns 6.18.54-xanmod1 instead of 6.18.54
|
||||
config.boot.kernelPackages.kernel.modDirVersion or config.boot.kernelPackages.kernel.version
|
||||
else
|
||||
null;
|
||||
specialisations = lib.escapeShellArg (
|
||||
lib.concatStringsSep " " (lib.attrNames config.specialisation)
|
||||
);
|
||||
|
||||
json = builtins.toJSON (
|
||||
{
|
||||
nixosVersion = config.system.nixos.version;
|
||||
inherit kernelVersion specialisations;
|
||||
specialisations = lib.attrNames config.specialisation;
|
||||
}
|
||||
// lib.optionalAttrs (kernelVersion != null) {
|
||||
inherit kernelVersion;
|
||||
|
||||
Reference in New Issue
Block a user