Git Product home page Git Product logo

flutsch's Introduction

Flutsch

๐Ÿšง๐Ÿšง๐Ÿšง Under construction ๐Ÿšง๐Ÿšง๐Ÿšง

This tool is not production ready yet.

A recursive nix value introspection tool.

Flutsch is a dynamic and efficient tool designed to traverse any generic Nix expression (attribute sets) easily.

It introspects nested attributes and functions, presenting dynamic value information in a JSON format (position, value type, etc.). This output can be used for further static analysis tasks, including but not limited to inspection of documentation comments.

Try it out:

nix run github:hsjobeki/flutsch <path/to/file.nix>

This will create a file values.json in your current directory.

Flutsch was designed as generic expression treewalker with the boobytraps and footguns of nixpkgs in mind.

since it leverages the native C++ Nix evaluator. It catches all kinds of evaluation errors; and more importantly, it can provide introspection without adding more builtins / changing the nix language itself.

Demo

Demo

Example

rec {
  a = {
    # The id function
    inherit a;
  };
}

Which essentially contains three entries:

  1. The root attrset rec {...}
  2. The binding for a = ...
  3. The recursive binding inherit a

Theoretically there would also be a value a.a.a and so on. But flutsch terminates here since it has already introspected all the values.

The result looks then like this:

[
    {
        "binding": {
            "is_root": false,
            "name": "a",
            "pos": {
                "column": 3,
                "file": "test.nix",
                "line": 2
            }
        },
        "value": {
            "children": [
                {
                    "is_root": false,
                    "name": "a",
                    "pos": {
                        "column": 7,
                        "file": "test.nix",
                        "line": 2
                    }
                }
            ],
            "error": false,
            "error_description": null,
            "path": [
                "<root>",
                "a"
            ],
            "pos": {
                "column": 7,
                "file": "test.nix",
                "line": 2
            },
            "type": "attrset"
        }
    },
    {
        "binding": {
            "is_root": true,
            "name": "<root>",
            "pos": {
                "column": 5,
                "file": "test.nix",
                "line": 1
            }
        },
        "value": {
            "children": [
                {
                    "is_root": false,
                    "name": "a",
                    "pos": {
                        "column": 5,
                        "file": "test.nix",
                        "line": 1
                    }
                }
            ],
            "error": false,
            "error_description": null,
            "path": [
                "<root>"
            ],
            "pos": {
                "column": 5,
                "file": "test.nix",
                "line": 1
            },
            "type": "attrset"
        }
    }
]

Which can be used (e.g. via it json representation) for further static analysis, visualization tasks, or generating documentation.

Key Features

  • Deep Traversal: Effortlessly explores any Nix attribute set without much configuration.
  • Error Handling: With its native error handling in the C++ Nix evaluator, Flutsch cannot fail.
  • Introspection Output: The native c++ bindings allow to retrieve information that is internal to the evaluation.
  • Static Analysis Readiness: Flutsch's output serves as a prime candidate for static analysis, especially for scrutinizing documentation comments and understanding the structure and relations within Nix expressions.

Usage

flutsch ./default.nix

Flutsch can be granularly configured via a json config file:

Simply pass --config <file_path.json> to the invocation.

Contributing

TODO

flutsch's People

Contributors

hsjobeki avatar

Stargazers

Jeff Carpenter avatar John Murray avatar  avatar Aleksander Gondek avatar Travis A. Everett avatar  avatar Lunaphied avatar Stel Abrego avatar Kayla Firestack avatar Qyriad avatar RyzeNGrind avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.