nixos-version --json: Use builtins.toJSON

This commit is contained in:
Eelco Dolstra 2020-02-10 15:25:24 +01:00
parent f9392f04ae
commit b98ea45608
2 changed files with 8 additions and 1 deletions

View file

@ -10,7 +10,7 @@ case "$1" in
;;
--json)
cat <<EOF
{"nixosVersion": "@version@", "nixpkgsRevision": "@revision@", "configurationRevision": "@configurationRevision@"}
@json@
EOF
;;
*)

View file

@ -49,6 +49,13 @@ let
src = ./nixos-version.sh;
inherit (config.system.nixos) version codeName revision;
inherit (config.system) configurationRevision;
json = builtins.toJSON ({
nixosVersion = config.system.nixos.version;
} // optionalAttrs (config.system.nixos.revision != null) {
nixpkgsRevision = config.system.nixos.revision;
} // optionalAttrs (config.system.configurationRevision != null) {
configurationRevision = config.system.configurationRevision;
});
};
nixos-enter = makeProg {