(Keep in mind im a start-mid level programmer, this is just a fun idea, dont flame me.)
While nix is amazing, some people have some points they dont like which are fair, one usually is nixlang. While I myself really love the syntax, nixlang evaluation is not very fast, and for noob programmers it might be more confusing then using, say, python or lua, and its very unique which isnt always a good thing. (No hate at all.)
Luau is a lua fork which has strict type evaluations and is run sandboxed with strict control over std/_G which can also be freezed, so it could easily be used for a pure packaging system like nix. In my opinion, lua is one of, if not the easiest language which also has great lsp support and great speed out of the box, and the best pick for a bolt-on configuration/scripting language, and afaik luau has c++ support so it should work with nix. One issue I might see is lazy loading, but it shouldnt be hard to achieve using metatables and storing functions and storing the value if evaluated, for example:
```
--!strict
export type Package = {
name: string,
version: string,
dependencies: { Package },
build: (self: Package) -> (),
}
export type PackageSet = {
[string]: Package
}
export type PackageFactory = (pkgs: PackageSet) -> Package
export type PackageMap = { [string]: PackageFactory }
local function create_lazy_pkgs(pkg_map: PackageMap): PackageSet
local pkgs = {}
local cache: { [string]: Package } = {}
setmetatable(pkgs, {
__index = function(self, key: string): Package
if cache[key] then
return cache[key]
end
local factory = pkg_map[key]
if not factory then
error(`Package '{key}' not found in package map.`)
end
print(`[EVALUATING] Instantiating derivation for: {key}`)
local evaluated_pkg = factory(self :: PackageSet)
cache[key] = evaluated_pkg
return evaluated_pkg
end
})
return pkgs :: PackageSet
end
local registry: PackageMap = {
zlib = function(pkgs)
return {
name = "zlib",
version = "1.2.13",
dependencies = {pkgs.curl}, -- Dependencies are also lazily evaluated
build = function(self)
print(Building {self.name}-{self.version}...)
end
}
end,
unused_package = function(pkgs)
error("This package should NEVER be evaluated because nobody requested it!")
end
}
``
Also, lua metatables are really powerfull and if wrapped with functions can be the user friendly nix module replacement (lib.mkOptions, ...), currently nixos imports all modules by default which makes nixos evalation quite slow, luau is much faster and if multi-level __index support is added even modules could be lazy loaded (i.e. steam only being loaded if aprograms.steam.*is referenced even if its a option of a option likegamescopeSession.steamArgs`, and then checking if its a valid option).
(Credit to dacctal who made pkgit, a source only make-like lua package manager that reminded me of nix)
PS: going to bed, will reply late