|
| 1 | +"$schema": http://json-schema.org/draft-04/schema# |
| 2 | +"$id": https://nix.dev/manual/nix/latest/protocols/json/schema/file-system-object-v1.json |
| 3 | +title: File System Object |
| 4 | +description: | |
| 5 | + This schema describes the JSON representation of Nix's [File System Object](@docroot@/store/file-system-object.md). |
| 6 | +
|
| 7 | + The schema is recursive because file system objects contain other file system objects. |
| 8 | +type: object |
| 9 | +required: ["type"] |
| 10 | +properties: |
| 11 | + type: |
| 12 | + type: string |
| 13 | + enum: ["regular", "symlink", "directory"] |
| 14 | + |
| 15 | +# Enforce conditional structure based on `type` |
| 16 | +anyOf: |
| 17 | + - $ref: "#/$defs/regular" |
| 18 | + required: ["type", "contents"] |
| 19 | + |
| 20 | + - $ref: "#/$defs/directory" |
| 21 | + required: ["type", "entries"] |
| 22 | + |
| 23 | + - $ref: "#/$defs/symlink" |
| 24 | + required: ["type", "target"] |
| 25 | + |
| 26 | +"$defs": |
| 27 | + regular: |
| 28 | + title: Regular File |
| 29 | + description: | |
| 30 | + See [Regular File](@docroot@/store/file-system-object.md#regular) in the manual for details. |
| 31 | + required: ["contents"] |
| 32 | + properties: |
| 33 | + type: |
| 34 | + const: "regular" |
| 35 | + contents: |
| 36 | + type: string |
| 37 | + description: File contents |
| 38 | + executable: |
| 39 | + type: boolean |
| 40 | + description: Whether the file is executable. |
| 41 | + default: false |
| 42 | + additionalProperties: false |
| 43 | + |
| 44 | + directory: |
| 45 | + title: Directory |
| 46 | + description: | |
| 47 | + See [Directory](@docroot@/store/file-system-object.md#directory) in the manual for details. |
| 48 | + required: ["entries"] |
| 49 | + properties: |
| 50 | + type: |
| 51 | + const: "directory" |
| 52 | + entries: |
| 53 | + type: object |
| 54 | + description: | |
| 55 | + Map of names to nested file system objects (for type=directory) |
| 56 | + additionalProperties: |
| 57 | + $ref: "#" |
| 58 | + additionalProperties: false |
| 59 | + |
| 60 | + symlink: |
| 61 | + title: Symbolic Link |
| 62 | + description: | |
| 63 | + See [Symbolic Link](@docroot@/store/file-system-object.md#symlink) in the manual for details. |
| 64 | + required: ["target"] |
| 65 | + properties: |
| 66 | + type: |
| 67 | + const: "symlink" |
| 68 | + target: |
| 69 | + type: string |
| 70 | + description: Target path of the symlink. |
| 71 | + additionalProperties: false |
0 commit comments