Skip to content
Snippets Groups Projects
  1. Jul 04, 2014
  2. Jul 03, 2014
  3. Jun 27, 2014
  4. Jun 24, 2014
  5. Jun 17, 2014
    • Shea Levy's avatar
      Add importNative primop · 5cd022d6
      Shea Levy authored
      This can be used to import a dynamic shared object and return an
      arbitrary value, including new primops. This can be used both to test
      new primops without having to recompile nix every time, and to build
      specialized primops that probably don't belong upstream (e.g. a function
      that calls out to gpg to decrypt a nixops secret as-needed).
      
      The imported function should initialize the Value & as needed. A single
      import can define multiple values by creating an attrset or list, of
      course.
      
      An example initialization function might look like:
      
      extern "C" void initialize(nix::EvalState & state, nix::Value & v)
      {
          v.type = nix::tPrimOp;
          v.primOp = NEW nix::PrimOp(myFun, 1, state.symbols.create("myFun"));
      }
      
      Then `builtins.importNative ./example.so "initialize"` will evaluate to
      the primop defined in the myFun function.
      5cd022d6
  6. Jun 12, 2014
  7. Jun 10, 2014
  8. Jun 02, 2014
  9. May 29, 2014
  10. May 26, 2014
    • Eelco Dolstra's avatar
      Use std::unordered_set · 54a34119
      Eelco Dolstra authored
      54a34119
    • Aristid Breitkreuz's avatar
      a457d5ad
    • Sönke Hahn's avatar
      dev-shell is a bash script, not sh · b1d39d47
      Sönke Hahn authored
      'type -p' does not work in e.g. dash
      b1d39d47
    • Adam Szkoda's avatar
      Rephrase @ operator description · 8ea9fd7a
      Adam Szkoda authored
      8ea9fd7a
    • Eelco Dolstra's avatar
      Remove ExprBuiltin · d8c061e0
      Eelco Dolstra authored
      It's slower than ExprVar since it doesn't compute a static
      displacement. Since we're not using the throw primop in the
      implementation of <...> anymore, it's also not really needed.
      d8c061e0
    • Eelco Dolstra's avatar
      Make the Nix search path declarative · 62a6eeb1
      Eelco Dolstra authored
      Nix search path lookups like <nixpkgs> are now desugared to ‘findFile
      nixPath <nixpkgs>’, where ‘findFile’ is a new primop. Thus you can
      override the search path simply by saying
      
        let
          nixPath = [ { prefix = "nixpkgs"; path = "/my-nixpkgs"; } ];
        in ... <nixpkgs> ...
      
      In conjunction with ‘scopedImport’ (commit
      c273c15c), the Nix search path can be
      propagated across imports, e.g.
      
        let
      
          overrides = {
            nixPath = [ ... ] ++ builtins.nixPath;
            import = fn: scopedImport overrides fn;
            scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
            builtins = builtins // overrides;
          };
      
        in scopedImport overrides ./nixos
      62a6eeb1
    • Eelco Dolstra's avatar
      Ensure that -I flags get included in nixPath · 39d72640
      Eelco Dolstra authored
      Also fixes #261.
      39d72640
    • Eelco Dolstra's avatar
      Add constant ‘nixPath’ · a8edf185
      Eelco Dolstra authored
      It contains the Nix expression search path as a list of { prefix, path
      } sets, e.g.
      
        [ { path = "/nix/var/nix/profiles/per-user/root/channels/nixos"; prefix = ""; }
          { path = "/etc/nixos/configuration.nix"; prefix = "nixos-config"; }
          { path = "/home/eelco/Dev/nix/inst/share/nix/corepkgs"; prefix = "nix"; }
        ]
      a8edf185
    • Eelco Dolstra's avatar
      Add primop ‘scopedImport’ · c273c15c
      Eelco Dolstra authored
      ‘scopedImport’ works like ‘import’, except that it takes a set of
      attributes to be added to the lexical scope of the expression,
      essentially extending or overriding the builtin variables.  For
      instance, the expression
      
        scopedImport { x = 1; } ./foo.nix
      
      where foo.nix contains ‘x’, will evaluate to 1.
      
      This has a few applications:
      
      * It allows getting rid of function argument specifications in package
        expressions. For instance, a package expression like:
      
          { stdenv, fetchurl, libfoo }:
      
          stdenv.mkDerivation { ... buildInputs = [ libfoo ]; }
      
        can now we written as just
      
          stdenv.mkDerivation { ... buildInputs = [ libfoo ]; }
      
        and imported in all-packages.nix as:
      
          bar = scopedImport pkgs ./bar.nix;
      
        So whereas we once had dependencies listed in three places
        (buildInputs, the function, and the call site), they now only need
        to appear in one place.
      
      * It allows overriding builtin functions. For instance, to trace all
        calls to ‘map’:
      
        let
          overrides = {
            map = f: xs: builtins.trace "map called!" (map f xs);
      
            # Ensure that our override gets propagated by calls to
            # import/scopedImport.
            import = fn: scopedImport overrides fn;
      
            scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
      
            # Also update ‘builtins’.
            builtins = builtins // overrides;
          };
        in scopedImport overrides ./bla.nix
      
      * Similarly, it allows extending the set of builtin functions. For
        instance, during Nixpkgs/NixOS evaluation, the Nixpkgs library
        functions could be added to the default scope.
      
      There is a downside: calls to scopedImport are not memoized, unlike
      import. So importing a file multiple times leads to multiple parsings
      / evaluations. It would be possible to construct the AST only once,
      but that would require careful handling of variables/environments.
      c273c15c
    • Eelco Dolstra's avatar
      Shut up some signedness warnings · f0fdbd08
      Eelco Dolstra authored
      f0fdbd08
  11. May 23, 2014
  12. May 22, 2014
  13. May 21, 2014
  14. May 15, 2014
  15. May 14, 2014
Loading