Switch from KCL to CUE

Although KCL is unquestionably a more powerful language, and maps more
closely to my mental model of how host/environment/application
configuration is defined, the fact that it doesn't work on ARM (issue
982]) makes it a non-starter.  It's also quite slow (owing to how it
compiles a program to evaluate the code) and cumbersome to distribute.
Fortunately, `tmpl` doesn't care how the values it uses were computed,
so we freely change configuration languages, so long as whatever we use
generates JSON/YAML.

CUE is probably a lot more popular than KCL, and is quite a bit simpler.
It's more restrictive (values cannot be overridden once defined), but
still expressive enough for what I am trying to do (so far).
This commit is contained in:
2024-01-14 22:16:39 -06:00
parent 8f31b0302c
commit 11f9957c11
24 changed files with 239 additions and 244 deletions

57
env/prod/nut.cue vendored Normal file
View File

@@ -0,0 +1,57 @@
package prod
import n "du5t1n.me/cfg/schema/app/nut"
nut: n.#Nut & {
listen: {
address: "::"
port: 3493
}
ups: {
apc1500: {
driver: "usbhid-ups"
port: "auto"
desc: "Back-UPS XS 1500G"
vendorid: "051d"
product: ".*1500M.*"
pollonly: "enabled"
pollinterval: 1
}
apc1300: {
driver: "usbhid-ups"
port: "auto"
desc: "Back-UPS XS 1300G"
vendorid: "051d"
product: ".*1300G.*"
pollonly: "enabled"
pollinterval: 1
}
}
users: {
homeassistant: {
password: """
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAxZUZleGt3emxXdDFtcEtN
Wll3K0hrS2c2M1oyMWh2VlBnMER0bkZOb1VVCnU3aTI2eVJoV1dKNWxEd0VnbVNa
NlMxVWRuZWpNbTJRVUhWR2w3bUlwaEUKLS0tIGZLcGNQRy9LNUF1Y0JzZEZGdXBn
bUJjYlBSSEYwRUpwemlMZ0xCZnpTS2cKUFke27YDeTME9OBgEcQdbJ3jsDZS43km
tK61kLMcexq3lXQb30gx4fzMuYa0MXFygawscTnxTrOrXUd36Iga4A==
-----END AGE ENCRYPTED FILE-----
"""
}
upsmon: {
upsmon: "primary"
password: """
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBzdnZMZ1F1d05RRi84ZENT
SmdRNkFLWDRPMTBFTkdOdFRBMC8xK0gvUVV3CjRhWVljR3ZiU1hwWEJBN2hCcTM1
NWFQWWdmVm1XK1pKUHFnRjJjYXdDNjgKLS0tIERvOU44ellHdGZYVXRDMHN4NkpV
QkhtVlVQUS96UStlQWo2QWJISUlGL2cKc8AC3UujJMIafbV31pjAzniqSHBNwYDw
zhh094auKibUcg6Tbyc=
-----END AGE ENCRYPTED FILE-----
"""
}
}
}

40
env/test/nut.cue vendored Normal file
View File

@@ -0,0 +1,40 @@
package test
import n "du5t1n.me/cfg/schema/app/nut"
nut: n.#Nut & {
listen: {
address: "::"
port: 3493
}
ups: {
nutdev1: {
driver: "usbhid-ups"
port: "auto"
vendorid: "051D"
productid: "0002"
product: "Back-UPS NS 1100M2 FW:953.e3 .D USB FW:e3"
serial: "3B1810X28282"
vendor: "American Power Conversion"
bus: "001"
}
}
users: {
dustin: {
actions: ["set", "fsd"]
instcmds: ["all"]
password: """
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBnZFN1b095cVk3UnhDdEc2
T2RTK0hpSVhGcHhNLzFMZGRvRWRlOERaY3hvCjVvNkxZeXVLcldFRnUwMzdNNU4r
eTRYNlFZeGhNWlo5cTdHR2ExNUpBaTgKLS0tIE5DNlp0cVgvMWRXcWd3cFR5akJm
a3FnMEhZRHpGMWZicUpqMklQcGtxaEkK82i19a+P++lx2dDJ+SBgNkqOg+7GiSPH
gI96Syl48P7V2PP3R6c=
-----END AGE ENCRYPTED FILE-----
"""
}
}
}