15 ms·
A service file looks like this: (register-services (make <service> #:provides '(apache-2.0 apache httpd) #:requires '() #:s
by georgyo 9y ago
A service file looks like this:
(register-services
(make <service>
#:provides '(apache-2.0 apache httpd)
#:requires '()
#:start (...)
#:stop (...)
#:actions (make-actions
(reload-modules (...))
(restart (...)))))
It not horrible, but I'm Not a huge fan of that, but maybe it will get much better as it matures.
- rurban 9y agoMuch better than XML. A proper and simple language, not just a stupid bloated datastructure, with the ability to naturally define logic in the deps.
- agumonkey 9y agoreminds me of emacs config file, john wiegley made a tiny dsl called use-package that made everything cuter by a few simplification here and there. A few iteration it became extremely nice to write and read.
- rbanffy 9y agoRemember the Emacs config file is not a configuration file: it is actually a program that's run as Emacs starts. You can do all sorts of interesting stuff (like installing missing packages, setting font size according to the screen, etc) on it.
- agumonkey 9y agoWell config vs program is a deep debate. Now J.Wiegley extension brings some resemblance of semantics because it has a few concepts and steps instead of free form imperative (setq ...)
- mitchty 9y agoI love use-package, has made my emacs init.el config file sooooo much more maintainable from its prior... lets just say mess.
- agumonkey 9y agoSome people, smart and famous, still use vanilla emacs config/loading mechanisms (ensuring lazy loading). I now use req-package so I don't even have to download anything. I do miss the old style of one file per "kind" though. Doesn't mean use-package is bad but somehow I like having a FS-level idea of my emacs config.
- mitchty 9y agoI'm one of those weirdos that sticks my config into org mode files too. https://github.com/mitchty/dotfiles/blob/master/emacs.org https://github.com/mitchty/dotfiles/blob/master/emacs.org (actually i use org mode to compile all of my dot files based on predicates, i'm double plus weird here >.<) I really rather like this way of working with things as it just sticks stuff into ~/.emacs.d/elpa. I can rsync that around if i need/want. And it even bootstraps itself if i'm opening things on a new system. I just like keeping each package in its own use-package declaration so I can have config+setup all in one spot.
- agumonkey 9y agoI planned to do that too. Having a readable.. even story tellable code instead of a too succint result of brain sweat. I might try to make one from scratch using yours as an inspiration. Just to see how my mindset evolved along the years.
- mitchty 9y agoGo for it, its mostly inspired from nix in how I set it up. I can just run make and create dot files for whatever I need then rsync it over to where I need it. Aka I can customize my dot files based on if i'm going to a bsd/mac/linux box with(out)/nix/perl/haskell/git/whatever and have an easy way to copy things over the top of things or not. I declared dot file bankruptcy a few years ago and this is my "perpetual penultimate dot file solution" (yes I'm making a joke at my own expense with penultimate here). But this new setup is easily the most sane I've found so far. Most dot file management uses softlinks which sucks for rsyncing, or some hokey templating language. All mine amounts to is just a stupid .el file that holds predicate definitions that just controls via stupid elisp when an org babel block gets tangled out into a file. Its pretty simple and straightforward. Wonder if I should do some sort of show and tell for it or not. Good luck! Hope it helps or inspires something better.
- snakeanus 9y agoI find it quite comfortable actually. Same goes for all of Guix.
- tmalsburg2 9y agoI'm curious. Why are you not a huge fan of it?
- _wmd 9y agoMy first thought is how I'd parse, modify and write it back without losing user's comments, formatting, changes and suchlike. Is this some well understood format with libraries for common programming languages? If not, it is just likely to proliferate more crappy config management with chunks of regexes and suchlike Elsewhere people are saying it's just Scheme. I'm sure I could find a parser for that in Python, and maybe if I'm really lucky that parser will record whitespace and comment nodes, and have a reverse transformation, but do I really want to be writing error prone 20-line AST visitors just to tweak an integer setting? (No, I most certainly do not, and I consider design decisions like this a massive code smell that'd ward me off any further investigation of a system) edit: downvotes? Is this really such a difficult concept? edit 2: so apparently the big whoopsie was insulting the religion that is LISP. Yes, using a turing complete language for config syntax causes pain. Nobody does this stuff in the real world for a reason. Deal with it, meanwhile go back to obsessing over novelty code-is-data academic exercises on your obsolete Symbolics machines, you'll cause less damage that way.
- brians 9y agoIt's Guile s-expressions, so at least there's a good C reader and writer?
- hashkb 9y agoYou would just use Guile. That's the magic of the Lisp family. Edit: downvotes are because you're sort of insulting Lisp (which is older than you and all your "best practices") with an ignorant complaint.
- phkahler 9y ago>> downvotes are because you're sort of insulting Lisp (which is older than you and all your "best practices") with an ignorant complaint. I recognized it as lisp right away, but I share the complaint about the format. If you want to write a lisp program then do so. If you want to format something for human readability it's probably a good idea to do it differently. This is just a opinion of course, but I suspect it's not an uncommon one.
- rnhmjoj 9y agoIt may be stupid but that syntax makes me feel a little uneasy. The unmatched single quotes reminds me of TemplateHaskell.
- brianon99 9y agoSingle quote denotes a symbol in scheme. But this snippest is not strictly scheme. Perhaps it is SXML but I am not familiar with it.
- cyphar 9y agoWhile I don't write Scheme, I believe it is Scheme -- one of the goals of the GNU project is to have every GNU tool be configurable with Scheme (which is why GNU has a Scheme implementation as opposed to a Common LISP implementation).
- brians 9y agoWell, they have GCL and CLisp too!
- the_why_of_y 9y agoNot only does GNU have a Common Lisp implementation, in fact there are two: GCL: https://www.gnu.org/software/gcl/ https://www.gnu.org/software/gcl/ CLISP: http://clisp.org/ http://clisp.org/
- cyphar 9y agoI've installed CLISP before, why didn't I know it was a GNU project? Fair enough, I stand corrected. :D
- rekado 9y agoThis is just Scheme. It's nothing to do with SXML. #:foo is a keyword argument and '(apache httpd) is a quoted list containing the symbols apache and httpd. Angled brackets have no special meaning, they are just part of the identifier.
- gkya 9y agoThat's a mere function call in a complete, standards based language.
- ymse 9y agoHere is a complete (and simpler) example, taken from my ~/.config/shepherd/init.scm: (define xscreensaver (make <service> #:provides '(xscreensaver) #:start (make-forkexec-constructor (list "/run/setuid-programs/xscreensaver" "-nosplash")) #:stop (make-kill-destructor))) (register-services xscreensaver)
- coldtea 9y agoAny reason for the fugly #: syntax? That's mandated by Guile?
- Avshalom 9y agoThey're keyword arguments, I suspect the #: prefix was chose precisely because it is ugly so it'll almost never conflict with a name a programmer might actually want to give as an argument, Racket uses it too. http://docs.racket-lang.org/guide/keywords.html http://docs.racket-lang.org/guide/keywords.html
- rekado 9y agoThe # is extensible reader syntax. You can install your own readers for characters following the #. #\ is for the character reader, #: for keywords, etc. Guix uses #~ for G-expressions, for example.
- reirob 9y agoThanks for providing the link to the documentation in Racket. For people like me who don't know how to program in Scheme, this quote from the documentation might make it click (it is at the end of the page): Despite their similarities, keywords are used in a different way than identifiers or symbols. Keywords are intended for use (unquoted) as special markers in argument lists and in certain syntactic forms. For run-time flags and enumerations, use symbols instead of keywords. The example below illustrates the distinct roles of keywords and symbols. Examples: > (define dir (find-system-path 'temp-dir)) ; not '#:temp-dir > (with-output-to-file (build-path dir "stuff.txt") (lambda () (printf "example\n")) ; optional #:mode argument can be 'text or 'binary #:mode 'text ; optional #:exists argument can be 'replace, 'truncate, ... #:exists 'replace)
- sigzero 9y agoIt's pretty close to "horrible" though.
- rsync 9y ago"A service file looks like this:" Am I correct that the equivalent to this service file, in the world of systemd, is a binary file ?
- subway 9y agoYou are incorrect. Systems uses plaintext 'ini'-ish files.
- to3m 9y agoNo; the format is text: http://0pointer.de/public/systemd-man/systemd.unit.html http://0pointer.de/public/systemd-man/systemd.unit.html
- majewsky 9y agoMaybe an example is easier to read than a manpage. Here's nginx.service from Arch Linux: https://git.archlinux.org/svntogit/packages.git/tree/trunk/service?h=packages/nginx https://git.archlinux.org/svntogit/packages.git/tree/trunk/s...
- BenjiWiebe 9y agoAnd I personally love it. When writing my own servers/daemons I can very quickly and easily write a new service file for it.