by hkjgkjy · 9y ago · 0 comments
Saddens me, because NixOS does all I want - except having s-expressions...
Replacing that with Scheme sounds like a long-term win to me; although in the short term I imagine it makes packaging the contents of a bash-dominated world more frustrating.
Then there's patching of sources (e.g. to replace shebangs to point to the actual location of the interpreter). Obviously, you want to have side effects there, so that's not purely functional. That's unrelated to Scheme as a language or the DSL we use to describe packages (Nix does something similar because without patching functional package management wouldn't quite work).
I'd say it's largely what you want, minus probably some GNU-isms in their packaging choices.
It sounds trivial, but unfortunately it was a deal-breaker for me. I really liked the centralised configuration and package management offered by NixOS.
The expression `games.nix` [2] I use for my games builds a chroot environment with both 32bit and 64bit /lib and a command `start-game` to launch games from the environment. I store them in ~/game/$gamename, with a `$gamename/start.sh`, which is a slightly tweaked or cleaned up version of what it's usually found in gogs and humble bundle games.
To use it you do `nix-env -if games.nix` to install it the first time and the just `start-game $gamename` to play. To fiddle around uncomment the trailing `#.env`, run `nix-shell games.nix` and you will land in the chroot environment with everything you need.
Most of Nix features like this one are not really documented but fortunately there's github search and folks in #nixos are always available.
No language is purely purely functional, otherwise it wouldn't be able to have inputs/outputs.
The DSL is mostly declarative. Here's an example:
(define metal
(package
(name "metal")
(version "2011-03-25")
(source
(origin
(method url-fetch)
(uri (string-append "http://csg.sph.umich.edu/abecasis/Metal/"
"download/generic-metal-" version ".tar.gz"))
(sha256
(base32
"1bk00hc0xagmq0mabmbb8bykl75qd4kfyirba869h4x6hmn4a0f3"))))
(build-system gnu-build-system)
(arguments
`(#:tests? #f
#:make-flags
(list (string-append "INSTALLDIR="
(assoc-ref %outputs "out") "/bin")
"all")
#:phases
(modify-phases %standard-phases
(delete 'configure))))
(inputs
`(("zlib" ,zlib)))
(home-page "http://csg.sph.umich.edu/abecasis/Metal")
(synopsis "Facilitate meta-analysis of large datasets")
(description "METAL is a tool for meta-analysis genomewide
association scans. ...")
(license license:bsd-3)))
The stuff that's in the "arguments" field is a quoted expression, which is evaluated on the builder's side, at build time. We make use of code staging in several places, which seems like a perfect fit for Scheme.Note that the `,zlib` thing means that the value bound to the variable name "zlib" is injected as is. All package expressions are "live" values in Scheme and can be inspected in a REPL.