All Projects → talyz → fromElisp

talyz / fromElisp

Licence: MIT license
An Emacs Lisp reader in Nix.

Programming Languages

Nix
1067 projects

Projects that are alternatives of or similar to fromElisp

Vulnix
Vulnerability (CVE) scanner for Nix/NixOS.
Stars: ✭ 161 (+519.23%)
Mutual labels:  nix, nixos
Nox
Tools to make nix nicer to use
Stars: ✭ 232 (+792.31%)
Mutual labels:  nix, nixos
Deploy Rs
A simple multi-profile Nix-flake deploy tool.
Stars: ✭ 164 (+530.77%)
Mutual labels:  nix, nixos
Dotfiles
My dotfiles
Stars: ✭ 150 (+476.92%)
Mutual labels:  nix, nixos
Arion
Run docker-compose with help from Nix/NixOS
Stars: ✭ 202 (+676.92%)
Mutual labels:  nix, nixos
Nix Bitcoin
A collection of Nix packages and NixOS modules for easily installing full-featured Bitcoin nodes with an emphasis on security.
Stars: ✭ 154 (+492.31%)
Mutual labels:  nix, nixos
Nix 1p
A (more or less) one page introduction to Nix, the language.
Stars: ✭ 219 (+742.31%)
Mutual labels:  nix, nixos
Nixos Manager
Manage your NixOS packages and configuration via a simple, intuitive UI
Stars: ✭ 128 (+392.31%)
Mutual labels:  nix, nixos
Mach Nix
Create highly reproducible python environments
Stars: ✭ 231 (+788.46%)
Mutual labels:  nix, nixos
Nixpkgs Wayland
Automated, pre-built packages for Wayland (sway/wlroots) tools for NixOS.
Stars: ✭ 178 (+584.62%)
Mutual labels:  nix, nixos
Appvm
Nix-based app VMs
Stars: ✭ 146 (+461.54%)
Mutual labels:  nix, nixos
All Hies
Cached Haskell IDE Engine Nix builds for all GHC versions
Stars: ✭ 201 (+673.08%)
Mutual labels:  nix, nixos
Shabka
Shabka. Declaritive description of my network, workstations and servers.
Stars: ✭ 138 (+430.77%)
Mutual labels:  nix, nixos
Home Manager
Manage a user environment using Nix [maintainer=@rycee]
Stars: ✭ 2,447 (+9311.54%)
Mutual labels:  nix, nixos
Nixos Weekly
NixOS Weekly Newsletter
Stars: ✭ 137 (+426.92%)
Mutual labels:  nix, nixos
Nixbox
NixOS Vagrant boxes [[email protected]]
Stars: ✭ 189 (+626.92%)
Mutual labels:  nix, nixos
Micro Ci
A tiny CI server built around GitHub and Nix
Stars: ✭ 126 (+384.62%)
Mutual labels:  nix, nixos
Dotfiles
Configuration files for XMonad, Emacs, NixOS, Taffybar and more.
Stars: ✭ 127 (+388.46%)
Mutual labels:  nix, nixos
Nixos Mailserver
A complete and Simple Nixos Mailserver
Stars: ✭ 172 (+561.54%)
Mutual labels:  nix, nixos
rc
Structured system configuration (I moved from NixOS to GuixSD)
Stars: ✭ 97 (+273.08%)
Mutual labels:  nix, nixos

fromElisp

An Emacs Lisp reader in Nix. Yes, it’s necessary.

nix-repl> :p fromElisp "(use-package lsp-mode :ensure :commands lsp)"
[ [ "use-package" "lsp-mode" ":ensure" ":commands" "lsp" ] ]

Functionality

fromElisp provides four main functions: fromElisp, parseElisp, fromOrgModeBabelElisp and parseOrgModeBabelElisp.

  • fromElisp elisp (string)

    Takes a string argument and tries to convert the Elisp read from it to the closest equivalent data type in Nix.

    For example,

    (use-package highlight-symbol
      :ensure t
      :hook (((python-mode emacs-lisp-mode nix-mode) . highlight-symbol-mode)
             ((python-mode emacs-lisp-mode nix-mode) . highlight-symbol-nav-mode))
      :config
      (highlight-symbol-nav-mode)
      (setq highlight-symbol-idle-delay 0.5)
      (set-face-attribute 'highlight-symbol-face nil :background "dark cyan"))
        

    is read as

    [[ "use-package" "highlight-symbol"
       ":ensure" true
       ":hook" [[[ "python-mode" "emacs-lisp-mode" "nix-mode" ] "highlight-symbol-mode" ]
                [[ "python-mode" "emacs-lisp-mode" "nix-mode" ] "highlight-symbol-nav-mode" ]]
       ":config"
       [ "highlight-symbol-nav-mode" ]
       [ "setq" "highlight-symbol-idle-delay" 0.5 ]
       [ "set-face-attribute" [ "quote" "highlight-symbol-face" ] [ ] ":background" "dark cyan" ]]]
        
  • parseElisp elisp (string)

    Takes a string argument and provides an AST with additional structural info, such as object type, line number and list depth.

    The AST provided for the code

    (setq mouse-wheel-scroll-amount '(3 ((shift) . 1)))
        

    would be

    [{ depth = 0; line = 1; type = "list"; value = [
         { line = 1; type = "symbol"; value = "setq"; }
         { line = 1; type = "symbol"; value = "mouse-wheel-scroll-amount"; }
         { line = 1; type = "quote"; value = {
             depth = 1; line = 1; type = "list"; value = [
               { line = 1; type = "integer"; value = 3; }
               { depth = 2; line = 1; type = "list"; value = [
                   { depth = 3; line = 1; type = "list"; value = [
                       { line = 1; type = "symbol"; value = "shift"; }
                     ];
                   }
                   { line = 1; type = "integer"; value = 1; }
                 ];
               }
             ];
           };
         }
       ];
     }]
        
  • fromOrgModeBabelElisp text (string)

    fromElisp, but for Org mode babel files. Runs fromElisp on the result of tangling all Elisp code blocks with :tangle yes set. Tangling is done internally, not by Org mode.

  • parseOrgModeBabelElisp text (string)

    parseElisp, but for Org mode babel files. Runs parseElisp on the result of tangling all Elisp code blocks with :tangle yes set. Tangling is done internally, not by Org mode.

Other functions

  • tokenizeElisp elisp (string)

    Takes a string argument and produces a list of tokens from the Elisp read from it. Used internally by fromElisp and parseElisp.

  • *tokenizeElisp’* args (attrs)

    An alternate version of tokenizeElisp allowing the specification of the starting line number.

    args is an attribute set with the following attributes:

    • elisp (string, required)

      The string of Elisp to tokenize.

    • startLineNumber (int, optional)

      The line number to use for the first line of elisp. Useful if elisp is a block of code from a larger file and you want line numbers to be correct.

  • *parseElisp’* tokens (list)

    An alternate version of parseElisp which takes as its argument a list of tokens produced by tokenizeElisp.

  • *fromElisp’* ast (list)

    An alternate version of fromElisp which takes as its argument an AST produced by parseElisp.

  • tokenizeOrgModeBabelElisp text (string)

    Run tokenizeElisp’ on all Elisp code blocks (with :tangle yes set) from Org mode babel text text.

  • *tokenizeOrgModeBabelElisp’* defaultArgs (attrs) text (string)

    An alternate version of tokenizeOrgModeBabelElisp which allows the specification of default arguments for Org babel headers. Currently only :tangle is supported.

  • *parseOrgBabelElisp’* defaultArgs (attrs) text (string)

    An alternate version of parseOrgBabelElisp which allows the specification of default arguments for Org babel headers. Currently only :tangle is supported.

  • *fromOrgBabelElisp’* defaultArgs (attrs) text (string)

    An alternate version of fromOrgModeBabelElisp which allows the specification of default arguments for Org babel headers. Currently only :tangle is supported.

Usage

You can use fromElisp in your code in multiple ways.

fetchGit

You can use fetchGit without a rev attribute to try it out quickly and then add the rev when you want reproducibility.

with (import (builtins.fetchGit {
  url = "https://github.com/talyz/fromElisp.git";
  ref = "master";
  # rev = "c13d6035666f36ca940db996f1dbaf83cb4e8453";
}));
# ... code ...

niv

If you use niv to manage your Nix dependencies, simply run

$ niv add talyz/fromElisp

to add fromElisp to your dependencies and import it as follows:

with (import (import ./nix/sources.nix).fromElisp {});
# ... code ...

Git submodule

If you plan on contributing to fromElisp and want to do it from your own source, you can import it as a Git submodule.

Limitations

  • No Unicode support

    Nix doesn’t support Unicode, so we can’t either.

  • No evaluation

    This is a reader and not an evaluator. You can make some pretty reasonable assumptions from the structure of the code, though: it’s, for example, used in the Emacs overlay to implement the functionality of emacsWithPackagesFromUsePackage.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].