4 ms·
Nix function call syntax is completely standard for ML-style functional languages and allows for effortless partial application. The main downside is that error
by sshine 1y ago
Nix function call syntax is completely standard for ML-style functional languages and allows for effortless partial application. The main downside is that error messages can get cryptic, especially so when Nix is untyped.
Whitespace add list delimiter is not very common, but I have to admit I really like it.
I was hoping for some “this doesn’t work” kind of things, not “this doesn’t feel familiar”.
Not sure how Nix doesn’t win the readability contest: literally a config file with function calls, and as little superfluous syntax as possible. I’d say the real criticism is: Nix is hard to write, and nixpkgs idioms (nested, undocumentedabstractions scattered throughout the code) are hard to read.
- yencabulator 1y ago> Not sure how Nix doesn’t win the readability contest Not sure how you can be serious. https://github.com/NixOS/nixpkgs/blob/d600f006643e074c2ef1d72e462e218b647a096c/pkgs/development/go-modules/generic/default.nix#L148-L166 https://github.com/NixOS/nixpkgs/blob/d600f006643e074c2ef1d7... buildGoDir() { local d; local cmd; cmd="$1" d="$2" . $TMPDIR/buildFlagsArray echo "$d" | grep -q "\(/_\|examples\|Godeps\|testdata\)" && return 0 [ -n "$excludedPackages" ] && echo "$d" | grep -q "$excludedPackages" && return 0 local OUT if ! OUT="$(go $cmd $buildFlags "''${buildFlagsArray[@]}" -v -p $NIX_BUILD_CORES $d 2>&1)"; then if ! echo "$OUT" | grep -qE '(no( buildable| non-test)?|build constraints exclude all) Go (source )?files'; then echo "$OUT" >&2 return 1 fi fi if [ -n "$OUT" ]; then echo "$OUT" >&2 fi return 0 } (Do note the Nix escaping on top of the shell horrors.) Nix just comes from a culture of utter utter horrible code. It's my daily driver, but I am holding my nose. https://github.com/NixOS/nix/blob/94ec9e47030c2a7280503d338f0dca7ad92811f5/src/nix-build/nix-build.cc#L483-L512 https://github.com/NixOS/nix/blob/94ec9e47030c2a7280503d338f... std::string rc = fmt( R"(_nix_shell_clean_tmpdir() { rm -rf %1%; }; )"s + (keepTmp ? "trap _nix_shell_clean_tmpdir EXIT; " "exitHooks+=(_nix_shell_clean_tmpdir); " "failureHooks+=(_nix_shell_clean_tmpdir); ": "_nix_shell_clean_tmpdir; ") + (pure ? "" : "[ -n \"$PS1\" ] && [ -e ~/.bashrc ] && source ~/.bashrc;") + "%2%" "dontAddDisableDepTrack=1;\n" + structuredAttrsRC + "\n[ -e $stdenv/setup ] && source $stdenv/setup; " "%3%" "PATH=%4%:\"$PATH\"; " "SHELL=%5%; " "set +e; " R"s([ -n "$PS1" -a -z "$NIX_SHELL_PRESERVE_PROMPT" ] && PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] '; )s" "if [ \"$(type -t runHook)\" = function ]; then runHook shellHook; fi; " "unset NIX_ENFORCE_PURITY; " "shopt -u nullglob; " "unset TZ; %6%" "shopt -s execfail;" "%7%", shellEscape(tmpDir), (pure ? "" : "p=$PATH; "), (pure ? "" : "PATH=$PATH:$p; unset p; "), shellEscape(dirOf(*shell)), shellEscape(*shell), (getenv("TZ") ? (string("export TZ=") + shellEscape(getenv("TZ")) + "; ") : ""), envCommand);
- craftkiller 1y agoI think sshine was saying that the nix *language* is readable. Both of your examples are from the implementation, not the language itself.
- yencabulator 1y agoA system's purpose is what it does. Nix the language is used to generate bash scripts that are then run in a sandbox, and based on what I'm seeing it's not a great fit/architecture. (Nix is not a general-purpose language. The concept of store paths etc is hardcoded in it.) I can complain about the horrible, undebuggable, error messages on the slightest typos too, if you want? Nix is way too subtle to "win the readability contest".