You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
972 B
JavaScript
45 lines
972 B
JavaScript
2 years ago
|
"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) {
|
||
|
assert(Array.isArray(attributes));
|
||
|
|
||
|
return {
|
||
|
type: "NixAttributePath",
|
||
|
attr: attributes
|
||
|
};
|
||
|
},
|
||
|
NixAttributeIdentifier: function (name) {
|
||
|
return {
|
||
|
type: "NixAttributeIdentifier",
|
||
|
name: name
|
||
|
};
|
||
|
}
|
||
|
};
|