{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/spack-packages-yaml/latest.json",
  "title": "Spack package configuration file schema",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/packages.json",
    "sourceSha256": "6eb4064dea7a83bd30d0fa181c51288717026e8b8615703678036b6038ec1ffb",
    "fileMatch": [
      "**/*spack/**/packages.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "packages": {
      "type": "object",
      "description": "Package-specific build settings and external package configurations",
      "default": {},
      "properties": {
        "all": {
          "type": "object",
          "description": "Default settings that apply to all packages (can be overridden by package-specific settings)",
          "default": {},
          "deprecatedProperties": [
            {
              "names": [
                "compiler"
              ],
              "message": "The packages:all:compiler preference has been deprecated in Spack v1.0, and is currently ignored. It will be removed from config in Spack v1.2.",
              "error": false
            }
          ],
          "properties": {
            "require": {
              "description": "Package requirements that must be satisfied during concretization",
              "oneOf": [
                {
                  "type": "array",
                  "items": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "one_of": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "List of specs where exactly one must be satisfied"
                          },
                          "any_of": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "List of specs where at least one must be satisfied"
                          },
                          "spec": {
                            "type": "string",
                            "description": "Single spec requirement that must be satisfied"
                          },
                          "message": {
                            "type": "string",
                            "description": "Custom error message when requirement is not satisfiable"
                          },
                          "when": {
                            "type": "string",
                            "description": "Conditional spec that triggers this requirement"
                          }
                        },
                        "additionalProperties": false
                      },
                      {
                        "type": "string"
                      }
                    ]
                  }
                },
                {
                  "type": "string"
                }
              ]
            },
            "prefer": {
              "description": "Strong package preferences that influence concretization without imposing hard constraints",
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "spec": {
                        "type": "string",
                        "description": "Spec constraint to apply"
                      },
                      "message": {
                        "type": "string",
                        "description": "Custom message explaining the constraint"
                      },
                      "when": {
                        "type": "string",
                        "description": "Conditional spec that triggers this constraint"
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            },
            "conflict": {
              "description": "Package conflicts that prevent certain spec combinations",
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "spec": {
                        "type": "string",
                        "description": "Spec constraint to apply"
                      },
                      "message": {
                        "type": "string",
                        "description": "Custom message explaining the constraint"
                      },
                      "when": {
                        "type": "string",
                        "description": "Conditional spec that triggers this constraint"
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            },
            "target": {
              "type": "array",
              "description": "Ordered list of soft preferences for target architectures for all packages (ignored if the concretizer can reuse existing installations)",
              "default": [],
              "items": {
                "type": "string"
              }
            },
            "compiler": {
              "type": "array",
              "description": "Soft preferences for compiler specs for all packages (deprecated)",
              "default": [],
              "items": {
                "type": "string"
              }
            },
            "buildable": {
              "type": "boolean",
              "description": "Whether packages should be built from source (false prevents building)",
              "default": true
            },
            "permissions": {
              "type": "object",
              "description": "File permissions settings for package installations",
              "properties": {
                "read": {
                  "type": "string",
                  "enum": [
                    "user",
                    "group",
                    "world"
                  ],
                  "description": "Who can read the files installed by a package"
                },
                "write": {
                  "type": "string",
                  "enum": [
                    "user",
                    "group",
                    "world"
                  ],
                  "description": "Who can write to the files installed by a package"
                },
                "group": {
                  "type": "string",
                  "description": "The group that owns the files installed by a package"
                }
              },
              "additionalProperties": false
            },
            "package_attributes": {
              "type": "object",
              "description": "Class-level attributes to assign to package instances (accessible in package.py methods)",
              "additionalProperties": false,
              "patternProperties": {
                "^[a-zA-Z_]\\w*$": {}
              }
            },
            "providers": {
              "type": "object",
              "description": "Soft preferences for providers of virtual packages (ignored if the concretizer can reuse existing installations)",
              "default": {},
              "additionalProperties": {
                "type": "array",
                "description": "Ordered list of preferred providers for this virtual package",
                "default": [],
                "items": {
                  "type": "string"
                }
              }
            },
            "variants": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ],
              "description": "Soft variant preferences as a single spec string or list of variant specifications (ignored if the concretizer can reuse existing installations)"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": {
        "type": "object",
        "description": "Package-specific settings that override defaults from 'all'",
        "default": {},
        "properties": {
          "require": {
            "description": "Package requirements that must be satisfied during concretization",
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "one_of": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "List of specs where exactly one must be satisfied"
                        },
                        "any_of": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "List of specs where at least one must be satisfied"
                        },
                        "spec": {
                          "type": "string",
                          "description": "Single spec requirement that must be satisfied"
                        },
                        "message": {
                          "type": "string",
                          "description": "Custom error message when requirement is not satisfiable"
                        },
                        "when": {
                          "type": "string",
                          "description": "Conditional spec that triggers this requirement"
                        }
                      },
                      "additionalProperties": false
                    },
                    {
                      "type": "string"
                    }
                  ]
                }
              },
              {
                "type": "string"
              }
            ]
          },
          "prefer": {
            "description": "Strong package preferences that influence concretization without imposing hard constraints",
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "spec": {
                      "type": "string",
                      "description": "Spec constraint to apply"
                    },
                    "message": {
                      "type": "string",
                      "description": "Custom message explaining the constraint"
                    },
                    "when": {
                      "type": "string",
                      "description": "Conditional spec that triggers this constraint"
                    }
                  },
                  "additionalProperties": false
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          "conflict": {
            "description": "Package conflicts that prevent certain spec combinations",
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "spec": {
                      "type": "string",
                      "description": "Spec constraint to apply"
                    },
                    "message": {
                      "type": "string",
                      "description": "Custom message explaining the constraint"
                    },
                    "when": {
                      "type": "string",
                      "description": "Conditional spec that triggers this constraint"
                    }
                  },
                  "additionalProperties": false
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          "version": {
            "type": "array",
            "description": "Ordered list of soft preferences for versions for this package (ignored if the concretizer can reuse existing installations)",
            "default": [],
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                }
              ]
            }
          },
          "buildable": {
            "type": "boolean",
            "description": "Whether this package should be built from source (false prevents building)",
            "default": true
          },
          "permissions": {
            "type": "object",
            "description": "File permissions settings for package installations",
            "properties": {
              "read": {
                "type": "string",
                "enum": [
                  "user",
                  "group",
                  "world"
                ],
                "description": "Who can read the files installed by a package"
              },
              "write": {
                "type": "string",
                "enum": [
                  "user",
                  "group",
                  "world"
                ],
                "description": "Who can write to the files installed by a package"
              },
              "group": {
                "type": "string",
                "description": "The group that owns the files installed by a package"
              }
            },
            "additionalProperties": false
          },
          "package_attributes": {
            "type": "object",
            "description": "Class-level attributes to assign to package instances (accessible in package.py methods)",
            "additionalProperties": false,
            "patternProperties": {
              "^[a-zA-Z_]\\w*$": {}
            }
          },
          "variants": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ],
            "description": "Soft variant preferences as a single spec string or list of variant specifications (ignored if the concretizer can reuse existing installations)"
          },
          "externals": {
            "type": "array",
            "description": "List of external, system-installed instances of this package",
            "items": {
              "type": "object",
              "properties": {
                "spec": {
                  "type": "string",
                  "description": "Spec string describing this external package instance. Typically name@version and relevant variants"
                },
                "prefix": {
                  "type": "string",
                  "description": "Installation prefix path for this external package (typically /usr, *excluding* bin/, lib/, etc.)"
                },
                "modules": {
                  "type": "array",
                  "description": "Environment modules to load for this external package",
                  "items": {
                    "type": "string"
                  }
                },
                "id": {
                  "type": "string"
                },
                "extra_attributes": {
                  "type": "object",
                  "description": "Additional information needed by the package to use this external",
                  "properties": {
                    "compilers": {
                      "type": "object",
                      "description": "Compiler executable paths for external compiler packages",
                      "properties": {
                        "c": {
                          "type": "string",
                          "description": "Path to the C compiler executable (e.g. /usr/bin/gcc)"
                        },
                        "cxx": {
                          "type": "string",
                          "description": "Path to the C++ compiler executable (e.g. /usr/bin/g++)"
                        },
                        "fortran": {
                          "type": "string",
                          "description": "Path to the Fortran compiler executable (e.g. /usr/bin/gfortran)"
                        }
                      },
                      "additionalProperties": false,
                      "patternProperties": {
                        "^\\w": {
                          "type": "string"
                        }
                      }
                    },
                    "environment": {
                      "type": "object",
                      "description": "Environment variable modifications to apply at runtime",
                      "default": {},
                      "properties": {
                        "set": {
                          "description": "Environment variables to set to specific values",
                          "type": "object",
                          "additionalProperties": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "number"
                              }
                            ]
                          }
                        },
                        "unset": {
                          "description": "Environment variables to remove/unset",
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "prepend_path": {
                          "description": "Environment variables to prepend values to (typically PATH-like variables)",
                          "type": "object",
                          "additionalProperties": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "number"
                              }
                            ]
                          }
                        },
                        "append_path": {
                          "description": "Environment variables to append values to (typically PATH-like variables)",
                          "type": "object",
                          "additionalProperties": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "number"
                              }
                            ]
                          }
                        },
                        "remove_path": {
                          "description": "Values to remove from PATH-like environment variables",
                          "type": "object",
                          "additionalProperties": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "number"
                              }
                            ]
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "extra_rpaths": {
                      "type": "array",
                      "default": [],
                      "items": {
                        "type": "string"
                      },
                      "description": "List of extra rpaths to inject by Spack's compiler wrappers"
                    },
                    "implicit_rpaths": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "boolean"
                        }
                      ],
                      "description": "List of non-default link directories to register at runtime as rpaths"
                    },
                    "flags": {
                      "type": "object",
                      "properties": {
                        "cflags": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Flags for C compiler, e.g. -std=c11"
                        },
                        "cxxflags": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Flags for C++ compiler, e.g. -std=c++14"
                        },
                        "fflags": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Flags for Fortran 77 compiler, e.g. -ffixed-line-length-none"
                        },
                        "cppflags": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Flags for C preprocessor, e.g. -DFOO=1"
                        },
                        "ldflags": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Flags passed to the compiler driver during linking, e.g. -Wl,--gc-sections"
                        },
                        "ldlibs": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Flags for linker libraries, e.g. -lpthread"
                        }
                      },
                      "description": "Flags to pass to the compiler during compilation and linking",
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": {
                    "type": "string"
                  }
                },
                "dependencies": {
                  "type": "array",
                  "description": "List of dependencies for this external package, specifying dependency relationships explicitly",
                  "items": {
                    "type": "object",
                    "description": "Dependency specification for an external package",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Explicit reference ID to another external package (provides unambiguous reference)"
                      },
                      "spec": {
                        "type": "string",
                        "description": "Spec string that matches an available external package"
                      },
                      "deptypes": {
                        "oneOf": [
                          {
                            "type": "string",
                            "description": "Single dependency type (e.g., 'build', 'link', 'run', 'test')"
                          },
                          {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "description": "Dependency type (e.g., 'build', 'link', 'run', 'test')"
                            },
                            "description": "List of dependency types (e.g., ['build', 'link'])"
                          }
                        ],
                        "description": "Dependency types; if not specified, inferred from package recipe"
                      },
                      "virtuals": {
                        "type": "string",
                        "description": "Virtual package name this dependency provides (e.g., 'mpi')"
                      }
                    }
                  }
                }
              },
              "required": [
                "spec"
              ],
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
