HackerTrans
TopNewTrendsCommentsPastAskShowJobs

mrcjkb

no profile record

Submissions

Lux – Sandboxing Lua for Safer Package Management

vhyrro.neorg.org
3 points·by mrcjkb·vor 4 Monaten·0 comments

Why Haskell is the perfect fit for renewable energy tech

mrcjkb.dev
8 points·by mrcjkb·vor 9 Monaten·0 comments

Luanox – a modern, snappy module host for Lua

mrcjkb.dev
2 points·by mrcjkb·vor 10 Monaten·0 comments

Show HN: Lux – A luxurious package manager for Lua

mrcjkb.dev
268 points·by mrcjkb·letztes Jahr·136 comments

comments

mrcjkb
·vor 9 Monaten·discuss
https://news.ycombinator.com/item?id=45626961#45630063
mrcjkb
·vor 9 Monaten·discuss
> Lua was conceived as a configuration language

That alone is a pretty weak argument.

> Trying to abstract this away behind a CLI seems like it misses the ethos of Lua.

With `lx add <package>`, you can install the package and add it to und config file in one step. And do things like fail if the package or version doesn't exist or isn't compatible with your system.

You can provide editor plugins or use LSP to give users hints if there's an update available, and use code actions to update them, etc.

> It’s also a tad strange that a package manager designed for Lua isn’t written in Lua.

Again, the fact that Lux relates to Lua is a pretty weak argument for choosing Lua as a language to write or configure it in.

Lots of Lua libraries and packages aren't written in Lua, but are built with Lua bindings. Lua (which as you yourself just mentioned was conceived as a configuration language) is a pretty poor choice for something with the scope of Lux. In fact, luarocks was recently rewritten in Teal. Lux has a Lua API (lux-lua) which means it can be embedded or used as a Lua library.

> Presumably Lua developers already have Lua installed, know Lua, and would more likely contribute to a project written in Lua.

We're not worried about finding contributors. If anything, what we need are high quality contributions. Lua developers who only know Lua are not what we're looking for.
mrcjkb
·vor 9 Monaten·discuss
Right, my bad. Still, being able to do more to aid the creation and maintenance of packages than just install packages doesn't make something "not a package manager".
mrcjkb
·vor 9 Monaten·discuss
It's just a silly pun. Search for "moon illuminance" and perhaps you'll get it :)
mrcjkb
·vor 9 Monaten·discuss
Lux helps you install and create/maintain packages. Linting is a useful step in the creation of packages.

Pip lets you create virtual environments. Does that mean it's an environment manager, not a package manager?

(╭ರ_•́)
mrcjkb
·vor 9 Monaten·discuss
That's a neat idea, but it would mean we'd have to maintain our own library. When editing with the CLI, you have to make sure you preserve comments, which the toml-edit crate does quite well.
mrcjkb
·vor 9 Monaten·discuss
Good thing we're not giving options for no reason other than to give options ;)
mrcjkb
·vor 9 Monaten·discuss
> presumably because that's what Cargo does.

Nope. We chose TOML as the default for various reasons:

- Simplicity. There are use cases for a turing complete configuration language. Lux is not one of them.

- Ergonomics. The ability to edit it using the CLI (technically, that could be possible with Lua too, but it would be a lot more complex and not a very pleasant UX).

> which, I don't know if that's the right call?

The reason we currently support importing a Lua extra.rockspec is ease of migration for complex projects, e.g. with platform-specific overrides (not yet supported by the TOML spec).
mrcjkb
·vor 10 Monaten·discuss
- It's not at the top level namespace, it's usually in the `vim.g` or `vim.b` namespace. There's no more namespacing than with a Lua module + function.

- global configuration variables don't have to be tables. They can be a union of `table | fun():table`, which enables laziness. [rustaceanvim does this, for example](https://github.com/mrcjkb/rustaceanvim/blob/12504405821c0587...).

- lazy.nvim's heuristics to auto-detect and invoke `setup` functions and pass "config objects" are a hack that could just as easily have been implemented around global config variables. This is a symptom of the problem, not a solution.

- If you don't need any code to require the plugin, there's also no need to keep the configuration and the code to require it in the same place.

- If a plugin is implemented correctly (by not making lazy loading the responsibility of the user), there's no need to worry about when the user sets the global variable.

- Most plugins' `setup` functions are idempotent. If you want to provide the ability to reconfigure your plugin at runtime, you can provide a `reload(opts)` function that sets the global config variable and then reinitialises the plugin. Or, you could add a metatable to the config variable that triggers a reload if the plugin has already been initialised. There's hardly ever a valid reason to force the coupling of configuration and initialisation on your plugin's users.
mrcjkb
·vor 10 Monaten·discuss
His use case is mini.nvim, a huge bundle of plugins where you most likely don't want each plugin initialising automatically.

He and I are on very opposite ends of the "setup spectrum", but we have found common ground, which is that you shouldn't cargo cult it: https://github.com/neovim/neovim/pull/35600/files
mrcjkb
·vor 10 Monaten·discuss
You don"t have to use a separate variable prefix for each config option. A plugin's config variable can just be a table/dictionary.
mrcjkb
·vor 10 Monaten·discuss
Neovim provides the same mechanisms as Vim for Lua plugins. The problem (and part of my motivation for writing the nvim-best-practices document) is that not enough plugins use them.

Edit: The Neovim setup antipattern is the Lua equivalent of writing Vimscript functions in autoload and asking users to call them in their configs instead of doing so automatically.
mrcjkb
·letztes Jahr·discuss
> Load the table

If it comes from an impure function, you don't know if you'll get the same result each time you evaluate it.

> Modify. Serialize to file.

And potentially lose information.
mrcjkb
·letztes Jahr·discuss
You mean my Hakyll site? It's mot meant to be :)
mrcjkb
·letztes Jahr·discuss
That doesn't seem very ergonomic - especially for the use cases we have in mind.
mrcjkb
·letztes Jahr·discuss
Lua has evolved and is used for a lot more today than it was initially created for.
mrcjkb
·letztes Jahr·discuss
You might be surprised how well that works :)
mrcjkb
·letztes Jahr·discuss
One of the motivations for Lux is to improve the nixpkgs Lua and Neovim ecosystems.
mrcjkb
·letztes Jahr·discuss
Only the `lx --help` and man pages.
mrcjkb
·letztes Jahr·discuss
We want to be able to write updated dependency specs to the manifest.