"use strict"; const assert = require("assert"); let types = module.exports = { /* NOTE: Synthesized attribute sets are non-recursive: nix-repl> rec { data = 1; sub = { data = 2; }; sub.ref = data; }.sub.ref 1 nix-repl> rec { data = 1; sub = rec { data = 2; }; sub.ref = data; }.sub.ref 2 nix-repl> rec { data = 1; sub.data = 2; sub.ref = data; }.sub.ref 1 */ NixAttributeSet: function (bindings, recursive = false) { return { type: "NixAttributeSet", bind: bindings, recursive: recursive }; }, NixBinding: function (attributePath, value) { return { type: "NixBinding", attrpath: types.NixAttributePath(attributePath), expression: value }; }, NixAttributePath: function (attributes) { // NOTE: This does not accept an array of strings! Instead, specify as an array of NixAttributeIdentifiers // TODO: Add proper validation for this assert(Array.isArray(attributes)); assert(!attributes.some((attribute) => typeof attribute === "string")); return { type: "NixAttributePath", attr: attributes }; }, NixIdentifier: function (name) { return { type: "NixIdentifier", name: name }; }, NixAttributeIdentifier: function (name) { return { type: "NixAttributeIdentifier", name: name }; }, NixAttributeSelection: function (expression, attributePath) { return { type: "NixAttributeSelection", attrpath: types.NixAttributePath(attributePath), expression: expression }; }, NixLetIn: function (bindings, body) { return { type: "NixLetIn", bind: bindings, body: body }; } };