mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-08-17 16:50:25 +03:00
add pre-commit checks
This commit is contained in:
parent
f756bd09d5
commit
344dc80d93
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,6 +35,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env*.local
|
.env*.local
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
96
README.md
96
README.md
@ -1,54 +1,79 @@
|
|||||||
|
# [Noogle](https://noogle.dev)
|
||||||
|
|
||||||
![Website](https://img.shields.io/website?down_message=noogle.dev&up_message=noogle.dev&url=https%3A%2F%2Fnoogle.dev)
|
![Website](https://img.shields.io/website?down_message=noogle.dev&up_message=noogle.dev&url=https%3A%2F%2Fnoogle.dev)
|
||||||
![GitHub top language](https://img.shields.io/github/languages/top/hsjobeki/noogle)
|
![GitHub top language](https://img.shields.io/github/languages/top/hsjobeki/noogle)
|
||||||
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/hsjobeki/noogle/main.yml)
|
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/hsjobeki/noogle/main.yml)
|
||||||
|
![built-with-dream2nix](https://img.shields.io/badge/built%20with-dream2nix-blue)
|
||||||
|
|
||||||
# [Noogle](https://noogle.dev)
|
Noogle is a Nix API search engine. It allows you to search functions based on
|
||||||
|
their types and other attributes in `nix` projects. In `nixpkgs` especially
|
||||||
|
the `builtins` and `lib` attributes.
|
||||||
|
|
||||||
Noogle is a Nix API search engine. It allows you to search functions based on their types and other attributes in `nix` projects. In `nixpkgs` especially the `builtins` and `lib` attributes.
|
## Current Features
|
||||||
|
|
||||||
- Beginners-friendly search for nix and nix-related functions
|
- [x] Beginners-friendly search for nix and nix-related functions
|
||||||
- Expert search with directly typing type signatures
|
- [x] Search by **type** signatures
|
||||||
- Search functions based on:
|
- [x] Sorted by relevance based on:
|
||||||
- type
|
- id
|
||||||
- signature
|
|
||||||
- name
|
- name
|
||||||
- tree-search from one type to another
|
- category
|
||||||
|
- description
|
||||||
## How it works
|
- example
|
||||||
|
- [ ] tree-search from one type to another
|
||||||
|
- [ ] functions from external libraries and nix frameworks
|
||||||
|
|
||||||
### Indexers:
|
## Available data
|
||||||
|
|
||||||
Data collections need to be up-to-date
|
Currently there are the following subsets of nix functions available.
|
||||||
Those collections are then combined and dumped somewhere (db / json)
|
|
||||||
|
|
||||||
For the indexing i currently use:
|
- nix/**builtins**
|
||||||
|
- nixpkgs/**lib**
|
||||||
|
- nixpkgs/build-support/**trivial-builders**
|
||||||
|
|
||||||
- Nixdoc (a fork) to collect nixpkgs.lib informations
|
### Search
|
||||||
- nix __dump-builtins + builtins-types.json for the nix builtins
|
|
||||||
|
|
||||||
As some parts of nix already have nixos modules their input/output can be discovered. I still lack some tool to integrate that into noogle.
|
- types are parsed and interpreted
|
||||||
|
- text search, looks in all metadata fields for an **exact match** word
|
||||||
|
or character sequence.
|
||||||
|
Noogle does not offer elastic search yet. And it remains open if it ever will.
|
||||||
|
|
||||||
### Search:
|
> If you have a function/set that you would like to find here,
|
||||||
|
> don't hesitate to file an issue.
|
||||||
|
|
||||||
- haskell-like types are parsed and splitted between input and ouput
|
**View the prototype [here](https://noogle.dev)**
|
||||||
- text search, looks in all metadata fields for an exact matching word or character sequence. I dont have elastic search yet.
|
|
||||||
|
|
||||||
# View the prototype [here](https://noogle.dev)
|
|
||||||
|
|
||||||
## We need your help / what is missing
|
## We need your help / what is missing
|
||||||
|
|
||||||
- Parsing `Types:` into a real type signature tree
|
### Extend available function
|
||||||
- Upstream missing type informations (like in /lib/attrsets.nix)
|
|
||||||
- Write type signatures for the `builtins` in json
|
Currently there is only a limited set of data.
|
||||||
- Add path, where each function can be imported from. e.g. `lib.makeOverridable` or `lib.customisation.makeOverridable` (it is available in both sets)
|
|
||||||
- Website
|
Because nixpkgs is very inconsistently documented it is
|
||||||
- improve share / social interactions
|
really hard to extend the scope.
|
||||||
- Add filter by tags e.g. lib.lists
|
|
||||||
- Prepare for scaling up: Either use api or use indexedDB with WebAssembly for complete offline usage?
|
So if you want to help noogle, we must improve nixpkgs itself.
|
||||||
- Mobile optimization for reading on the go
|
|
||||||
- Clean up / enhance my nixdoc fork.
|
- [ ] Parsing `Types:` into a real type signature tree
|
||||||
- Make the `sloppy` parser more error resistant
|
- [ ] Fix: line beginnings that include Asterisk (*) : Is interpreted as List-Markdown
|
||||||
- Some valueable information can be used from the rnix AST ?
|
- [x] Upstream missing type informations (like in /lib/attrsets.nix)
|
||||||
|
- [x] Write type signatures for the `builtins` in json
|
||||||
|
- [ ] Add path, where each function can be imported from.
|
||||||
|
|
||||||
|
e.g. `lib.makeOverridable` or `lib.customisation.makeOverridable`
|
||||||
|
it is available in both sets
|
||||||
|
|
||||||
|
### Website
|
||||||
|
|
||||||
|
- [x] improve share (deeplinks)
|
||||||
|
- [ ] social interactions
|
||||||
|
- [ ] Add filter by tags e.g. lib.lists
|
||||||
|
- [ ] Prepare for scaling up (we expect more users)
|
||||||
|
- [x] Mobile optimization for reading on the go
|
||||||
|
|
||||||
|
## Nixdoc / Indexer (fork)
|
||||||
|
|
||||||
|
- [ ] Parse types directly while also parsing comments
|
||||||
|
- [ ] Extend the scope, so that is can parse more comments
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -62,4 +87,5 @@ Contributions are very welcome just file a PR or issue
|
|||||||
|
|
||||||
`nix develop`
|
`nix develop`
|
||||||
|
|
||||||
This command creates the node_modules folder with all needed dependencies based on dream2nix.
|
This command creates the node_modules folder
|
||||||
|
with all needed dependencies based on dream2nix.
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
Box,
|
|
||||||
IconButton,
|
IconButton,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
Paper,
|
Paper,
|
||||||
@ -9,15 +8,10 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { DocItem, NixType } from "../../models/nix";
|
import { DocItem } from "../../models/nix";
|
||||||
import { Preview } from "../preview/preview";
|
import { Preview } from "../preview/preview";
|
||||||
import StarIcon from "@mui/icons-material/Star";
|
|
||||||
import ShareIcon from "@mui/icons-material/Share";
|
import ShareIcon from "@mui/icons-material/Share";
|
||||||
import { useLocalStorage } from "usehooks-ts";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import StarRateIcon from "@mui/icons-material/StarRate";
|
|
||||||
import StarBorderIcon from "@mui/icons-material/StarBorder";
|
|
||||||
import { Key } from "@mui/icons-material";
|
|
||||||
|
|
||||||
interface FunctionItemProps {
|
interface FunctionItemProps {
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
@ -25,10 +19,9 @@ interface FunctionItemProps {
|
|||||||
docItem: DocItem;
|
docItem: DocItem;
|
||||||
handleClose: () => void;
|
handleClose: () => void;
|
||||||
}
|
}
|
||||||
const getKey = (item: DocItem) => `${item.category}/${item.name}`;
|
|
||||||
|
|
||||||
export default function FunctionItem(props: FunctionItemProps) {
|
export default function FunctionItem(props: FunctionItemProps) {
|
||||||
const { name, docItem, selected, handleClose } = props;
|
const { docItem, selected, handleClose } = props;
|
||||||
const { fn_type, category, description, id } = docItem;
|
const { fn_type, category, description, id } = docItem;
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const descriptionPreview = useMemo(() => {
|
const descriptionPreview = useMemo(() => {
|
||||||
|
@ -3,12 +3,11 @@ import Paper from "@mui/material/Paper";
|
|||||||
import InputBase from "@mui/material/InputBase";
|
import InputBase from "@mui/material/InputBase";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import ClearIcon from "@mui/icons-material/Clear";
|
import ClearIcon from "@mui/icons-material/Clear";
|
||||||
import { Box, debounce, Grid, Tooltip, Typography } from "@mui/material";
|
import { Box, debounce, Grid, Typography } from "@mui/material";
|
||||||
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
||||||
import { NixType, nixTypes } from "../../models/nix";
|
import { NixType, nixTypes } from "../../models/nix";
|
||||||
import SearchIcon from "@mui/icons-material/Search";
|
import SearchIcon from "@mui/icons-material/Search";
|
||||||
import { usePageContext } from "../pageContext";
|
import { usePageContext } from "../pageContext";
|
||||||
import { initialPageState } from "../../models/internals";
|
|
||||||
import { SelectOption } from "../selectOption";
|
import { SelectOption } from "../selectOption";
|
||||||
|
|
||||||
export type Filter = { from: NixType; to: NixType };
|
export type Filter = { from: NixType; to: NixType };
|
||||||
|
95
flake.lock
95
flake.lock
@ -125,6 +125,22 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673956053,
|
||||||
|
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-parts": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
@ -173,6 +189,21 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1667395993,
|
||||||
|
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flakeCompat": {
|
"flakeCompat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -205,6 +236,27 @@
|
|||||||
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
|
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"pre-commit-hooks",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1660459072,
|
||||||
|
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"gomod2nix": {
|
"gomod2nix": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -309,6 +361,22 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-stable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673800717,
|
||||||
|
"narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-22.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1673027386,
|
"lastModified": 1673027386,
|
||||||
@ -395,11 +463,36 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"pre-commit-hooks_2": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1674550893,
|
||||||
|
"narHash": "sha256-HXI8AB96PP7UZ7iPANACXM8qc9eMz0ljxBEDM8JJKhY=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"rev": "7bdf85f6bbef581eb687838d19f2b35a4c9d77f0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"dream2nix": "dream2nix",
|
"dream2nix": "dream2nix",
|
||||||
"nixdoc-fork": "nixdoc-fork",
|
"nixdoc-fork": "nixdoc-fork",
|
||||||
"nixpkgs": "nixpkgs_4"
|
"nixpkgs": "nixpkgs_4",
|
||||||
|
"pre-commit-hooks": "pre-commit-hooks_2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
|
39
flake.nix
39
flake.nix
@ -1,12 +1,18 @@
|
|||||||
{
|
{
|
||||||
inputs.dream2nix.url = "github:nix-community/dream2nix";
|
inputs = {
|
||||||
inputs.nixdoc-fork.url = "github:hsjobeki/nixdoc";
|
dream2nix.url = "github:nix-community/dream2nix";
|
||||||
outputs = {self, nixpkgs,...}@inp:
|
nixdoc-fork.url = "github:hsjobeki/nixdoc";
|
||||||
let
|
pre-commit-hooks = {
|
||||||
system = "x86_64-linux";
|
url = "github:cachix/pre-commit-hooks.nix";
|
||||||
pkgs = inp.nixpkgs.legacyPackages.${system};
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inherit (builtins.fromJSON (builtins.readFile ./package.json)) name;
|
};
|
||||||
in
|
};
|
||||||
|
outputs = { self, nixpkgs, pre-commit-hooks, ... }@inp:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = inp.nixpkgs.legacyPackages.${system};
|
||||||
|
inherit (builtins.fromJSON (builtins.readFile ./package.json)) name;
|
||||||
|
in
|
||||||
(inp.dream2nix.lib.makeFlakeOutputs {
|
(inp.dream2nix.lib.makeFlakeOutputs {
|
||||||
systemsFromFile = ./nix_systems;
|
systemsFromFile = ./nix_systems;
|
||||||
config.projectRoot = ./.;
|
config.projectRoot = ./.;
|
||||||
@ -19,7 +25,7 @@
|
|||||||
packageOverrides = {
|
packageOverrides = {
|
||||||
${name}.staticPage = {
|
${name}.staticPage = {
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
cp ${inp.nixdoc-fork.packages.${system}.data} ./models/lib.json
|
cp ${inp.nixdoc-fork.packages.${system}.data} ./models/lib.json
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
@ -35,7 +41,20 @@
|
|||||||
})
|
})
|
||||||
// {
|
// {
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [nodejs-18_x ];
|
buildInputs = with pkgs; [ nodejs-18_x ];
|
||||||
|
shellHook = ''
|
||||||
|
${self.checks.${system}.pre-commit-check.shellHook}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
checks.${system} = {
|
||||||
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||||
|
src = ./.;
|
||||||
|
hooks = {
|
||||||
|
nixpkgs-fmt.enable = true;
|
||||||
|
statix.enable = true;
|
||||||
|
markdownlint.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"target": "es6",
|
"target": "es6",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
@ -16,5 +17,5 @@
|
|||||||
"incremental": true
|
"incremental": true
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules", "result"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user