Commit graph

241 commits

Author SHA1 Message Date
John Wiegley 7c9211d6e0
Merge pull request #352 from pikajude/path-tarball
Support tarballs in NIX_PATH and -I
2018-09-03 10:04:19 -07:00
John Wiegley ed99b7ad18
Merge branch 'master' into mapattrs 2018-09-02 19:15:04 -07:00
Jude Taylor 368f7e038c support tarballs in NIX_PATH and -I 2018-09-02 11:25:24 -07:00
John Wiegley 7d549d67c6
Merge remote-tracking branch 'origin/master' into pending 2018-08-23 21:08:12 -07:00
Jörg Thalheim c890965bb4 add builtins.{bitAnd,bitOr,bitXor) 2018-08-20 17:04:55 -05:00
John Wiegley 0613d1d604
Finish implementation of cycle detection during normalization 2018-08-10 17:50:07 -04:00
Matthew Bauer 10fe907c50 Add builtins.mapAttrs
Fixes #341
2018-08-09 18:23:13 -04:00
John Wiegley 456e0811bc
Merge remote-tracking branch 'origin/master' into pending 2018-08-06 16:15:14 -04:00
Domen Kožar 6033a49e6d
Implement addErrorContext as id 2018-08-06 21:09:30 +01:00
John Wiegley f262046f34
Change coerceToString to also take a coerceMore argument 2018-08-05 15:51:42 -04:00
John Wiegley 50740972de
'import' should never carry over the lexical scope of its parent file
Fixes #334
2018-08-04 15:08:36 -04:00
gb fd2bbb66e9 fixes to match latest master: tests ran 2018-07-28 15:32:15 -04:00
gb 9c3e5e995c update fork from master contd 2018-07-28 14:17:37 -04:00
gb ea3b675f28 update fork from master 2018-07-28 13:23:23 -04:00
Félix Baylac-Jacqué d3cbcf791c
Builtins.div cannot divide by 0
Fixes #277.
2018-06-12 21:54:28 +02:00
Dmitry Rets 3a096cc93b Implement top-level __findFile.
Fixes https://github.com/haskell-nix/hnix/issues/248.
2018-05-20 23:39:24 +02:00
John Wiegley 60231bd38a
Merge branch 'master' into master 2018-05-14 21:15:07 -07:00
hsloan f7ff858ef9 add builtins.toFile 2018-05-14 22:54:34 -04:00
John Wiegley 6aa64760d1 Make use of lens-family to provide some utility lenses/traversals 2018-05-14 22:45:43 -04:00
Blair Archibald b89cba0525 Fix #280. unsafeGetAttrPos should return null.
According to the expected test output, unsafeGetAttrPos should fail silently and
return null if it can't find a position for the field (e.g when looking up
builtins).
2018-05-14 22:45:43 -04:00
John Wiegley 45da41666b Make use of attrsetGet in another place 2018-05-14 22:45:43 -04:00
John Wiegley 35fb7dc974
Add instance Lift (Fix NExprF) for GHC 8.0 2018-05-10 15:35:53 -07:00
John Wiegley dbd8468862
In Builtins.hs, just include derivation.nix directly 2018-05-10 13:51:14 -07:00
John Wiegley 1d5c0370ae
Simplify definition of getAttr 2018-05-10 00:09:42 -07:00
John Wiegley 8ebac49b95
Make builtins.toString much better behaved 2018-05-09 22:17:32 -07:00
John Wiegley ba0dc19d2d
Work from mightybyte: Minimize deps required, for building with GHCJS 2018-05-08 16:41:15 -07:00
gb 43c145252d NixString is in its own module hiding the constructors 2018-05-08 16:47:50 -04:00
John Wiegley 449d6611df
Remove the Uri type, it's just sugar
Fixes #308
2018-05-08 12:15:50 -07:00
John Wiegley f1faf50bcb
Merge branch 'master' into string_context_255 2018-05-06 10:47:23 -07:00
John Wiegley e7a6456a35 Make use of lens-family to provide some utility lenses/traversals 2018-05-06 10:43:43 -07:00
Blair Archibald aae7f13ab1 Fix #280. unsafeGetAttrPos should return null.
According to the expected test output, unsafeGetAttrPos should fail silently and
return null if it can't find a position for the field (e.g when looking up
builtins).
2018-05-06 13:17:43 +01:00
John Wiegley 9e50e9e069 Make use of attrsetGet in another place 2018-05-06 00:35:29 -07:00
gb 8e7d9d32fa add string context 2018-05-03 08:07:54 -04:00
John Wiegley b1b027286b Fix a warning in Builtins.hs 2018-05-02 21:39:23 -07:00
John Wiegley a627d885e8 Implement builtins.fetchurl
Squashed commit of the following:

commit 15b10d898e0457237f07cda9e5e9525bac0e95f6
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:33:30 2018 -0700

    Update Exec.hs

commit d4a886dccf2715f1c1790e01adc242c352e7f427
Merge: 02afb27 4caacc1
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:08:55 2018 -0700

    Merge branch 'master' into http

commit 02afb275f2078c1184a901da3ea0262630fefeea
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:08:42 2018 -0700

    Update Exec.hs

commit 3733ce5888adb7161d2f57a16204ab953e9c4d7d
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:07:08 2018 -0700

    Update Builtins.hs

commit 4402be6d04ac34156d50f8ee29f9af300de75ce5
Merge: 2c60097 13f3ebd
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 15:06:28 2018 -0700

    Merge branch 'master' into http

commit 2c600976bb3a5d9267a0f313487dd0ab1a6ce1f7
Merge: 4a9d1a5 555ce95
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 14:25:59 2018 -0700

    Merge branch 'master' into http

commit 4a9d1a56d463567ad155a58fc39f5b24e2636120
Merge: 4dd46f2 431006f
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 14:20:57 2018 -0700

    Merge branch 'master' into http

commit 4dd46f21e3f594c4f7ae5bee8412a7841e566d4c
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sun Apr 29 12:51:11 2018 -0700

    generated hnix.cabal

commit c87ae993fb7dbb1117f03133862799e1549c4259
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 16:55:11 2018 -0700

    remove dep from hnix.cabal

commit 0bb8856c8759ad3c67a0b4eb1d26b6195da82667
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 16:53:54 2018 -0700

    remove http-client stuff from default.nix

commit d298756a2ba4376f8cb3c54fb723a00697e0821d
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:49:59 2018 -0700

    getURL is implemented for both http and https

commit a3d66c07a097aedb03f30bcc636fcb3d5717e1fe
Merge: c4cb48a a73eae5
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:14:32 2018 -0700

    Merge branch 'builtin2' into http

commit c4cb48a8a756e82fb7d389ff501b2a85001dba38
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:13:25 2018 -0700

    add getURL function

commit ff23fc18ed16075353a58725d7d08f41605a6070
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:06:40 2018 -0700

    use http-client-* instead of HTTP

commit fcbe40f3bea84607a9d7849a9f3d2fc3a6cb9bef
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 14:58:07 2018 -0700

    add HTTP

commit a73eae573a193dbb8361e03b584a6cd55e7c427a
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 14:36:24 2018 -0700

    implement fetchurl (as a copy of fetchTarball)
2018-05-02 21:38:39 -07:00
hsloan c1561ea711 Implement builtins.currentTime 2018-05-02 21:32:00 -07:00
Alex Rozenshteyn a355366f32 Add builtins.hasContext 2018-05-02 20:54:51 -07:00
John Wiegley fe0357c572
Merge branch 'master' into merge257 2018-05-02 14:22:47 -07:00
John Wiegley 431006f524
Merge pull request #263 from gdevanla/master
add TopLevel placeHolder to builtins module
2018-05-02 14:19:10 -07:00
John Wiegley 0b74225bcb
Update Builtins.hs 2018-05-02 14:18:45 -07:00
gb b07927a136 cleanup exec' 2018-05-02 14:10:49 -07:00
gb d07888ed35 implemented builtins.trace 2018-05-02 13:58:30 -07:00
John Wiegley acda2b3337 Use Exception rather than Frame, reduce constraints imposed by forceThunk 2018-05-01 20:34:41 -04:00
John Wiegley c934c690e3 Add attrsetGet helper function to Builtins.hs 2018-04-30 21:48:45 -04:00
John Wiegley bdce698e36 Merge remote-tracking branch 'origin/pr/272' 2018-04-30 19:48:14 -04:00
John Wiegley 70acb77826
Merge branch 'master' into master 2018-04-29 18:02:46 -07:00
Guru Devanla 0268b5cf2b remove extra spaces 2018-04-29 15:15:38 -07:00
Guru Devanla eefc698bde fix type of builtin.placeholder, add tests 2018-04-29 15:10:52 -07:00
Tim Sears a49a424813 add builtins.mul, issue #250 2018-04-29 11:43:06 -07:00
Guru Devanla 2819ccbc8f merged from origin 2018-04-29 10:37:16 -07:00
John Wiegley 005fe53733
Merge branch 'master' into easy-builtins 2018-04-29 10:28:13 -07:00
Alex Rozenshteyn f3cad22e1e Add builtins.true, builtins.false, and builtins.null 2018-04-29 10:07:37 -07:00
John Wiegley 829e0a63ab
Merge branch 'master' into master 2018-04-28 23:32:18 -07:00
John Wiegley b78a44f1c7
Merge branch 'master' into simplify-builtins 2018-04-28 18:33:24 -07:00
John Wiegley 86b0dad65b Define builtins.valueSize 2018-04-28 18:29:25 -07:00
John Wiegley b24598b3a3 Add top-level __valueSize
Fixes #253
2018-04-28 17:12:32 -07:00
Shea Levy 674601ad39
builtins: Simplify generating the full builtins list. 2018-04-28 16:54:16 -07:00
John Wiegley 9f41a1938f
Merge branch 'master' into master 2018-04-28 16:35:10 -07:00
John Wiegley 1093c1ff6e
Merge pull request #261 from timsears/master
allow floating point values to be used with builtins.add. Fixes Issue…
2018-04-28 15:57:37 -07:00
Guru Devanla dc384ee90f Merge branch 'master' of https://github.com/haskell-nix/hnix 2018-04-28 15:36:38 -07:00
Guru Devanla 8ba302265b add builtins.placeHolder to builtins 2018-04-28 15:35:01 -07:00
Alex Rozenshteyn 6734e3b73f Add builtins.storeDir 2018-04-28 15:28:57 -07:00
Tim Sears 43bb8d0558 allow floating point values to be used with builtins.add. Fixes Issue #207. 2018-04-28 15:22:28 -07:00
John Wiegley 1c5044da60 Finish builtins.genericClosure
Fixes #144
2018-04-28 15:18:45 -07:00
John Wiegley 3b304561f7 Make div dispatch on value types 2018-04-28 15:01:12 -07:00
John Wiegley d0b5ccde77 Initial implementation of genericClosure 2018-04-28 14:56:20 -07:00
John Wiegley 49953737cc
Merge pull request #256 from wavewave/builtin
add div
2018-04-28 14:55:21 -07:00
Ian-Woo Kim aa506e8555 add div 2018-04-28 14:01:14 -07:00
John Wiegley f722639b01 Minor correction to the builtins list 2018-04-28 13:49:34 -07:00
John Wiegley ec50146a25 Add a comment 2018-04-28 13:49:22 -07:00
John Wiegley 6946e713c0 For every builtin name, also an alias __name at toplevel
Relates to #243
2018-04-28 07:08:08 -07:00
John Wiegley 7282d7c153 Define builtins.langVersion == 5 (integer), add a matching test with Nix
Fixes #235
2018-04-27 20:55:03 -07:00
John Wiegley 4947f05a14 Make builtins.nixPath a synonym for __nixPath
Fixes #238
2018-04-27 20:52:09 -07:00
John Wiegley 1e2bd9eb2f Silence a warning 2018-04-26 22:30:42 -07:00
John Wiegley 6c2149f767 Remove code TODOs, which have been changed into GitHub issues 2018-04-26 17:13:22 -07:00
John Wiegley 49eea12262 Use fromValue defensively wherever possible in Builtins.hs 2018-04-25 20:46:31 -07:00
John Wiegley e8da0391e1 Fix an issue where evaluation was unintentionally too deep
Fixes #193
2018-04-25 20:23:10 -07:00
John Wiegley cfdb314f9e Simplify foldl'_ a bit 2018-04-25 01:10:15 -07:00
John Wiegley b83ccb40f3 Add provenance to thunks, and allow provenance to stack 2018-04-24 21:41:23 -07:00
John Wiegley 9864a8c7a5 Rework the way that info frames and error are handled
There is still work to be done to render the new "typed frames", and to
convert all the current string based frame into typed frames. This will pave
the way forward to smarter error messages that can be browsed in intelligent
environments like Emacs and the browser.
2018-04-24 02:15:28 -07:00
John Wiegley 596f2d160b
Merge pull request #191 from mightybyte/sort-builtins
Sort the builtins for easy comparison
2018-04-23 10:08:45 -07:00
John Wiegley 3cf02e3902 Track value provenance during evaluation 2018-04-22 14:33:38 -07:00
Doug Beardsley 26013d2e3b Sort the builtins for easy comparison 2018-04-22 13:48:55 -04:00
John Wiegley 9937453ef2 Ensure that the --trace option persists through imports 2018-04-21 10:36:32 -07:00
John Wiegley 8a93068102 Rename Nix.Core back to Nix.Eval, since Nix.Eval was now almost empty 2018-04-21 10:11:34 -07:00
John Wiegley 86b09103d6 Move production of a reduced test case to --reduce, improve --trace 2018-04-20 22:36:40 -07:00
John Wiegley 7188c71d0a Add more evaluation context information, for -v2 or higher 2018-04-18 16:12:31 -07:00
John Wiegley bd693fd3e5 And more coercion work 2018-04-17 21:53:07 -07:00
John Wiegley 91f7feb615 More work on path coercions 2018-04-17 21:49:29 -07:00
John Wiegley 114931bda8 Pass a 0 argument where needed 2018-04-17 20:44:20 -07:00
John Wiegley e92c5755af attrNames and attrValues, by using ToBuiltin, were evaluating too deeply 2018-04-17 19:01:32 -07:00
John Wiegley 02ee1c7e34 The argument order for the function passed to foldl' had gotten flipped 2018-04-17 18:30:05 -07:00
John Wiegley d16a627464 Avoid re-executing actions that yield functions in Builtins.hs 2018-04-17 17:46:27 -07:00
John Wiegley 7cf4d62868 builtins.currentSystem had the arch and os reversed 2018-04-17 14:49:47 -07:00
John Wiegley 8d25aa461d Add --json option to hnix, which can render both expressions and values 2018-04-17 14:24:52 -07:00
John Wiegley 11d074a355 Simplify more functions in Builtins.hs
Specifically, reduce the number of explicit calls to 'force'.
2018-04-16 21:47:45 -07:00
John Wiegley c9158273a4 Change all builtins to go from m (NValue m) -> m (NValue m)
This avoids a needless thunk encapsulation.
2018-04-16 21:39:41 -07:00
hsloan eef5b3fb30 use fromValue in more places in builtins
do this to avoid pattern matching and throwing errors explicitly
2018-04-16 23:18:06 -04:00
John Wiegley b1f6a99dbc Simplify more functions in Builtins using Nix.Convert 2018-04-15 23:01:22 -07:00
John Wiegley a0372918dd More minor cleanups in Builtins.hs 2018-04-15 22:01:01 -07:00
John Wiegley dc23fb71fe Some further simplifications in Builtins.hs 2018-04-15 21:03:43 -07:00
John Wiegley dacd0ca0db Restore the "normal form recursive" ToNix/FromNix type classes
This allows for very easily written Builtins
2018-04-15 20:43:04 -07:00
John Wiegley fb6191c949 Rename the internal version of ToNix/FromNix to ToValue/FromValue 2018-04-15 19:05:44 -07:00
John Wiegley ef82d5e9f2 Make ToNix monadic, to avoid making any assumptions about its use 2018-04-15 16:21:47 -07:00
John Wiegley 5ce5ac8791 Get rid of ConvertValue in favor of Nix.Context
There remains some simplification work to be done, still, as there is much
duplication in Builtins.hs as things stand now. At least for now only one type
class-based, automatic conversion mechanism exists.
2018-04-15 01:43:01 -07:00
John Wiegley a6b004d04b Make some uses of Nix.Convert with forcing more explicit 2018-04-15 00:51:50 -07:00
John Wiegley 16e02088d8 More changes in Builtins.hs to use Nix.Convert 2018-04-14 23:53:59 -07:00
John Wiegley ca0ab497a1 Resolve some warnings in Builtins.hs 2018-04-14 23:53:31 -07:00
John Wiegley ca24430bc9 Change Builtins.hs to use the ToNix/FromNix defined in Convert.hs 2018-04-14 22:58:50 -07:00
Ryan Trinkle 6366620542 Allow imports from strings 2018-04-13 23:30:21 -04:00
John Wiegley c5f001a7d4 For now, allow pathExists to accept a string 2018-04-13 18:35:51 -07:00
John Wiegley 6c9cbf241a Rewrite ToNix/FromNix, although Builtins.hs is not using it yet 2018-04-13 18:09:12 -07:00
John Wiegley 7f6a64da04 More corrections to the search path logic
Fixes #112
2018-04-13 16:37:11 -07:00
John Wiegley caa897af4a Introduce new helper function Exec.foldNixPath 2018-04-13 10:38:57 -07:00
John Wiegley c9c2db5cb8 Correct the behavior of baseNameOf 2018-04-13 01:20:33 -07:00
John Wiegley b6b3c61176 Add the __nixPath builtin 2018-04-13 01:20:24 -07:00
John Wiegley e9299dce7b Implement builtins.fetchTarball at the moment by calling nix-instantiate 2018-04-11 13:56:18 -07:00
John Wiegley ffa8d85dd2 Move handling of with statements into MonadEval 2018-04-11 11:53:30 -07:00
Doug Beardsley 714b78cbdc Fix remaining split test failure 2018-04-11 02:06:47 -04:00
John Wiegley 3233c9cb31 Restore the pretty show instance for NValue m (orphaned in Pretty for now) 2018-04-10 21:11:46 -07:00
John Wiegley 74de14dc7d Restore the linter, to some degree, at least for the language tests 2018-04-10 21:02:01 -07:00
Doug Beardsley 9ab6455bfc Fix bug in builtins.split for multiple matches 2018-04-10 12:33:31 -07:00
Doug Beardsley 13fc5bcd6d Add builtins.split
Finishes issue #113
2018-04-10 12:33:31 -07:00
John Wiegley a7e7e84795 Drop dependency on insert-ordered-containers
Fixes #161
2018-04-10 11:58:08 -07:00
John Wiegley 49d73fa767 Restore code in Builtins.hs 2018-04-10 09:02:17 -07:00
John Wiegley 4f9dec43cd More work on the megaparsec parser 2018-04-10 00:40:11 -07:00
John Wiegley 8f37f37986 Down to 16 basic test failures with megaparsec 2018-04-09 21:35:46 -07:00
John Wiegley 9d7f25d368 All is building with Megaparsec now, but many parsing tests fail 2018-04-09 17:12:16 -07:00
John Wiegley 9beb9364e0 The Megaparsec version of Parser.hs is at least compiling 2018-04-09 16:11:31 -07:00
John Wiegley 4c2eebbe40 Refactor evaluation using a type class 2018-04-09 00:52:10 -07:00
John Wiegley f6eb4c1353 Store a closure in NVClosure, instead of passing the scope 2018-04-07 22:46:05 -07:00
Ryan Trinkle 7c3b7d9482 When the user calls import on a directory, automatically append default.nix 2018-04-07 20:33:36 -04:00
John Wiegley 39e859fab5 Make use of Nix.Normal, move some more code to Nix.Value 2018-04-07 17:24:22 -07:00
John Wiegley 31e6aa8fb9 Implement __curPos as a primitive action during evaluation 2018-04-07 16:35:11 -07:00
Ryan Trinkle 33ae62534b Make map builtin lazier 2018-04-07 19:06:01 -04:00
Ryan Trinkle 628697d63b Merge branch 'master' of github.com:jwiegley/hnix
# Conflicts:
#	src/Nix/Monad.hs
#	src/Nix/Monad/Instance.hs
2018-04-07 18:39:57 -04:00
Ryan Trinkle 8b0de962b0 Add derivation builtin 2018-04-07 18:34:54 -04:00
Doug Beardsley 1b7dac071d Test to catch a bug in builtins.match
Also added infrastructure for comparing against current nix behavior,
not just current nix tests.
2018-04-07 15:07:09 -07:00
John Wiegley aaaa82820f Don't distinguish between literal and env paths in values, just exprs 2018-04-07 14:52:24 -07:00
John Wiegley ea6a98f602 Implement builtins.tryEval 2018-04-07 14:33:15 -07:00
John Wiegley a704bb045f Commit the src/ directory 2018-04-07 12:02:50 -07:00