Hello, when I once tried NixOS, a system with declarative configuration at its core, i was naively expecting that I'll be able to declare zshrc. So, for example, that I'll be able to write some kind of rule "append command {X} to the end of the zshrc if it's not somewhere in the file". Turned out that those expectations were way out of the scale, as what was actually possible was to fill 3 configuration fields with the text of the zshenv, zprofile and zshrc. ZQL is to implement the feature. Example code: PRE { setopt #; print "**"; ls $ } ALTER { echo * "added" } POST { VALUE=* } 1. PRE and POST are the contextual surroundings of the inner code that does the editing. 2. The `setopt #` says: match setopt command that takes string. 3. So # denotes string. It doesn't matter if it's given as "#" or '#' or # – it will match all three kinds of strings (unquoted, " and ' plus also $''). 4. Now, if instead of single # there will be two ##, then this is quotation-locked matching – it matches strings with only the kind of quoting that's used for symbol. So, for example, '##' will match only 'string'. 5. # matches strings but not variables 6. To match also variables, there's the * symbol, with the same quotation-locking features. 7. To match variables, there's $ symbol (with the $$ counterpart as well). So, basically, the command matches a context of three preceding commands setopt, print and ls and one trailing command – an assignment VALUE={anything}. After this, it then applies the middle editing block ALTER wchi; 1. Leaves 1st echo argument untouched (because it has * assigned) 2. Sets second argument to "added" This is how I imagine ZQL and the true declaring of zshrc contents. For more information you can take a look at the project's wiki: https://github.com/zdharma/declare-zsh/wiki/ZQL-draft Are there any easily detectable flaws in the idea? What else could be added to the language? The project has fairly sophisticated parsing already implemented. Currently, it allows to disable / enable zplugin's commands (that's how the project started; I'm thinking about exposing a plugin interface for other commands that might benefit from such highly-targeted approach) by providing a plugin name / pattern matching it. -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org
On 2019-07-22 9:27 a.m., Sebastian Gniazdowski wrote:
> Hello,
> when I once tried NixOS, a system with declarative configuration at
Astonishing your creativity Sebastian. I hope you find some new blood
to help you with all your ideas.
On Mon, 22 Jul 2019 at 21:02, Ray Andrews <rayandrews@eastlink.ca> wrote: > > On 2019-07-22 9:27 a.m., Sebastian Gniazdowski wrote: > > Hello, > > when I once tried NixOS, a system with declarative configuration at > > Astonishing your creativity Sebastian. Thank you! > I hope you find some new blood to help you with all your ideas. yes, people are welcomed to join e.g. the declare-zsh project. It should be interesting to someone and I think that e.g. implementing the parsing of the language will be much fun. I think that the typical best place to talk about it is the channel #zplugin on freenode. I think that the next thing that people from the ML join forces together will be the yet hypothetical official plugin manager. Coding such _system_ (not that its sophisticated but just by nature) is extremely fun and it invites creativity. It would be probably an extreme view to see the creators of Zshell code it, the ideas, etc.
On Mon, Jul 22, 2019 at 9:28 AM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> when I once tried NixOS, a system with declarative configuration at
> its core, i was naively expecting that I'll be able to declare zshrc.
> So, for example, that I'll be able to write some kind of rule "append
> command {X} to the end of the zshrc if it's not somewhere in the
> file".
You should have a look at the "newuser" module and zsh-newuser-install
function, also at Functions/MIME/zsh-mime-setup and
Completion/compinstall ... these all implement something or other of
the sort. The general approach is to mark off sections of the file(s)
with keyworded comments and then restrict the operation of the
"declaration" routines to the corresponding commented sections.
There's probably a lot of recent stuff that could be added to at least
newuser and compinstall.
On Tue, Jul 23, 2019 at 01:50:56PM -0700, Bart Schaefer wrote:
> On Mon, Jul 22, 2019 at 9:28 AM Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> >
> > when I once tried NixOS, a system with declarative configuration at
> > its core, i was naively expecting that I'll be able to declare zshrc.
> > So, for example, that I'll be able to write some kind of rule "append
> > command {X} to the end of the zshrc if it's not somewhere in the
> > file".
>
> You should have a look at the "newuser" module and zsh-newuser-install
> function, also at Functions/MIME/zsh-mime-setup and
> Completion/compinstall ... these all implement something or other of
> the sort. The general approach is to mark off sections of the file(s)
> with keyworded comments and then restrict the operation of the
> "declaration" routines to the corresponding commented sections.
>
> There's probably a lot of recent stuff that could be added to at least
> newuser and compinstall.
IMO, it would make sense to just install files in a directory and only have
.zshrc source them all (either using a well-known ordering mechanism or
implement some fancier dependency system). Then you don't need a brittle
mechanism to edit (multiple times, and then to maintain the lifecycles of those
edits) a file that's nominally under user control, other than to insert a single
line.
Danek