-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static type system #14
Comments
Can you expand on this a bit? I think some efforts toward a better type system can be valuable, I'm just not sure whether the static/dynamic distinction even makes sense for nix. |
Ever since SQLite in Nixpkgs was updated to 3.8.0.2, Nix has randomly segfaulted on Darwin: http://hydra.nixos.org/build/6175515 http://hydra.nixos.org/build/6611038 It turns out that this is because the binary cache substituter somehow ends up loading two versions of SQLite: the one in Nixpkgs and the other from /usr/lib/libsqlite3.dylib. It's not exactly clear why the latter is loaded, but it appears to be because WWW::Curl indirectly loads /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation, which in turn seems to load /usr/lib/libsqlite3.dylib. This leads to a segfault when Perl exits: #0 0x00000001010375f4 in sqlite3_finalize () #1 0x000000010125806e in sqlite_st_destroy () #2 0x000000010124bc30 in XS_DBD__SQLite__st_DESTROY () #3 0x00000001001c8155 in XS_DBI_dispatch () ... #14 0x0000000100023224 in perl_destruct () #15 0x0000000100000d6a in main () ... The workaround is to explicitly load DBD::SQLite before WWW::Curl.
It's interesting to think what kind of typing scheme would be needed for Nix. There's apparently a pretty heavy need for anonymous isorecursive records, something like
|
"Nix won't be complete until it has static typing." What a beautiful way to put it :). @tel row polymorphism works well with mu types for this. mu types + row polymorphism sometimes severely limit the ways the attribute set can be functionally extended / unioned / etc, but if that becomes an issue, I think/hope there are sound ways to "break" the mu types and gain more expressiveness. |
In case someone follows this issue but not the mailing-list, I opened a funding campaign for this issue at https://www.gofundme.com/typing-nix. You are all welcome to donate :) |
@regnat, weren't the any other way to sponsor Nix development without sponsoring GoFundMe with 7.9% + $.30 (at least $269 currently)? |
Huh? How come this is closed @edolstra? |
Because it's not realistically going to happen (and I'm cleaning up some backlog issues). |
🚫 dropped |
In case anyone finds this thread, and wondering what happened to @regnat 's project: (Although almost every blog/twitter etc. post mentions Dhall, just as @domenkozar suggests above, and it also seems to be the most active.) Gabriel Gonzalez on the limitations of Dhall: HNix on the other hand "has some form of type checker": |
README: fix towards foolproofing the instruction
I don't want to add to noise here but I'm intrigued by Nix (os) and noticed this issue passing by- why not add a type system and deprecate unsound syntax if any found? |
Nix is one of the best chances for gradual typing, because only one code base matters (nixpkgs), and it can be refactored in tandem of developing the type checker. @SRGOM It's just a lot of work and no one has prioritized it, which makes sense as most of the extent RFCs are more bang for buck. I believe it will happen eventually, if nixpkgs isn't replaced by something else. The biggest technical impediment is probably that people are deathly scared of increasing eval times, so a lot of core functionality remains written in crazy bash deferred to build time. We need to find a way to move the goal posts so eval times aren't a problem at. Then we can easily get things into a state where many core infra changes don't always cause a mass rebuild, and static typing can penetrate deep enough to be worth it. |
Then again, so many of the big innovations (including Nix) where not realistically going to happen at some point in the past, but requirered many people (including you) to push the boundries of what's possible (thank you for that). Leaving this here as a reference. 😄
|
Note that there's a new effort: https://github.com/tweag/nickel |
This deadlocks ProgressBar, e.g. # nix run --impure --no-substitute --store '/tmp/nix2?store=/foo' --expr 'derivation { builder = /nix/store/zi90rxslsm4mlr46l2xws1rm94g7pk8p-busybox-1.31.1-x86_64-unknown-linux-musl/bin/busybox; }' leads to Thread 1 (Thread 0x7ffff6126e80 (LWP 12250)): #0 0x00007ffff7215d62 in __lll_lock_wait () from /nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/lib/libpthread.so.0 #1 0x00007ffff720e721 in pthread_mutex_lock () from /nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/lib/libpthread.so.0 #2 0x00007ffff7ad17fa in __gthread_mutex_lock (__mutex=0x6c5448) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:749 #3 std::mutex::lock (this=0x6c5448) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/std_mutex.h:100 #4 std::unique_lock<std::mutex>::lock (this=0x7fffffff09a8, this=0x7fffffff09a8) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/unique_lock.h:141 #5 std::unique_lock<std::mutex>::unique_lock (__m=..., this=0x7fffffff09a8) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/unique_lock.h:71 #6 nix::Sync<nix::ProgressBar::State, std::mutex>::Lock::Lock (s=0x6c5448, this=0x7fffffff09a0) at src/libutil/sync.hh:45 #7 nix::Sync<nix::ProgressBar::State, std::mutex>::lock (this=0x6c5448) at src/libutil/sync.hh:85 #8 nix::ProgressBar::logEI (this=0x6c5440, ei=...) at src/libmain/progress-bar.cc:131 #9 0x00007ffff7608cfd in nix::Logger::logEI (ei=..., lvl=nix::lvlError, this=0x6c5440) at src/libutil/logging.hh:88 #10 nix::getCodeLines (errPos=...) at src/libutil/error.cc:66 #11 0x00007ffff76073f2 in nix::showErrorInfo (out=..., einfo=..., showTrace=<optimized out>) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/optional:897 #12 0x00007ffff7ad19e7 in nix::ProgressBar::logEI (this=0x6c5440, ei=...) at src/libmain/progress-bar.cc:134 #13 0x00007ffff7ab9d10 in nix::Logger::logEI (ei=..., lvl=nix::lvlError, this=0x6c5440) at src/libutil/logging.hh:88 #14 nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) (programName="/home/eelco/Dev/nix/outputs/out/bin/nix", fun=...) at src/libmain/shared.cc:328 #15 0x000000000046226b in main (argc=<optimized out>, argv=<optimized out>) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/ext/new_allocator.h:80
It is worth mentioning: purenix-org/purenix |
What about https://github.com/haskell-nix/hnix? now says it is:
so after some years we are here I guess 😂 |
using the total-attrs-printed and total-list-items-printed counters to calculate how many attrs were elided only works properly if no nesting is involved. once things do nest the global counter can exceed the size of the currently printed object, leading to unsigned wrapping and great overestimation of elided counts. counting locally in addition to global counts fixes this. these are functional tests because creating these objects requires the evaluator to not be a huge amount of code, and we also want defaults to be tested for cli usage. fixes NixOS#14 Change-Id: Icb9a0cb21b2f4bacbc5e9dcdd8c0b9055b4088a7
Nix won't be complete until it has static typing.
The text was updated successfully, but these errors were encountered: