This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
generated from blue-build/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: try to use pkl as templating engine
- Loading branch information
1 parent
645e3ff
commit fa684ad
Showing
3 changed files
with
96 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
class Project { | ||
image_name: String | ||
description: String | ||
base_images: String | ||
} | ||
|
||
class Image { | ||
name: String | ||
description: String | ||
`base-image`: String | ||
`image-version`: String | ||
modules: Listing<ImportModule?> | ||
} | ||
|
||
class ImportModule { | ||
`from-file`: String | ||
} | ||
|
||
const meta = (Project) { | ||
image_name = "atomic-studio" | ||
description = "Operating system based on Fedora Atomic meant for content creators and artists" | ||
base_images = "ghcr.io/ublue-os" | ||
} | ||
|
||
const allModules { | ||
shared = List("packages", "files", "scripts", "bling", "services") | ||
fx = List("apps", "flatpaks", "audinux") | ||
nvidia = List() | ||
amd = List("packages", "scripts") | ||
gnome = List("apps") | ||
plasma = List("apps", "scripts", "files") | ||
misc = List(new Mapping { | ||
["type"] = "yafti" | ||
}, new Mapping { | ||
["type"] = "signing" | ||
}) | ||
} | ||
|
||
|
||
const function toImportModule(baseFolder: String, extension: String, prefix: String, modules: List<String>): Listing<ImportModule> = new Listing<ImportModule> { | ||
for (_module in modules) { | ||
new ImportModule { | ||
`from-file` = "\(baseFolder)/\(prefix)/\(_module)\(extension)" | ||
} | ||
} | ||
} | ||
|
||
const function genImageTags(base: String, nvidia: Boolean, fx: Boolean): String = (if (base == "silverblue") "-gnome" else "") + (if (fx) "-fx" else "") + (if (nvidia) "-nvidia" else "") | ||
|
||
const function genImage(base: String, nvidia: Boolean, fx: Boolean): Image = (Image) { | ||
name = "\(meta.image_name)\(genImageTags(base, nvidia, fx))" | ||
description = meta.description | ||
`base-image` = "\(meta.base_images)/\(base)\(if (nvidia) "-nvidia" else "-main")" | ||
`image-version` = "latest" | ||
modules = new Listing { | ||
...(toImportModule("common", ".yml", "shared", allModules.shared)) | ||
...?(if(nvidia) null else toImportModule("common", ".yml", "shared/amd", allModules.amd)) | ||
...?(if(base == "silverblue") toImportModule("common", ".yml", "gnome", allModules.gnome) else toImportModule("common", ".yml", "plasma", allModules.plasma)) | ||
...?(if(fx) toImportModule("common", ".yml", "fx", allModules.fx) else null) | ||
} | ||
} | ||
|
||
/*[ | ||
gen_module_definition("shared", modules.shared), | ||
if (nvidia) then [] else gen_module_definition("shared/amd", modules.amd), | ||
if (baseimage == "silverblue") then gen_module_definition("gnome", modules.gnome) else gen_module_definition("plasma", modules.plasma), | ||
if (fx) then gen_module_definition("fx", modules.fx) else [], | ||
modules.misc, | ||
]),*/ | ||
|
||
const function atomicStudioImages(prefix: String, extension: String): Mapping<String, Image> = new Mapping<String, Image> { | ||
for (_base in List("kinoite", "silverblue")) { | ||
for (_nvidia in List(false, true)) { | ||
for (_fx in List(false, true)) { | ||
["\(prefix)\(genImageTags(_base, _nvidia, _fx))\(extension)"] = genImage(_base, _nvidia, _fx) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
output { | ||
files { | ||
for (_filename, _recipe in atomicStudioImages("recipe", ".yml")) { | ||
[_filename] { | ||
value = _recipe | ||
renderer = new YamlRenderer {} | ||
} | ||
} | ||
} | ||
} |