resolve conflicts with main

This commit is contained in:
hsjobeki 2023-01-30 12:01:30 +01:00
commit a55c1b00c6
12 changed files with 284 additions and 59 deletions

38
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**What happened**
The bug you encountered
**Steps to Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
- Screen resolution (optional)
or
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

View File

@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**If your Feature is adding / extending more functions**
Tell us where to find the function / functions e.g. where in nixpkgs
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

1
.gitignore vendored
View File

@ -35,6 +35,7 @@ yarn-error.log*
# local env files
.env*.local
.pre-commit-config.yaml
# vercel
.vercel

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Johannes Kirschbauer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -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)
![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)
![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
- Expert search with directly typing type signatures
- Search functions based on:
- type
- signature
- [x] Beginners-friendly search for nix and nix-related functions
- [x] Search by **type** signatures
- [x] Sorted by relevance based on:
- id
- name
- tree-search from one type to another
## How it works
- category
- description
- 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
Those collections are then combined and dumped somewhere (db / json)
Currently there are the following subsets of nix functions available.
For the indexing i currently use:
- nix/**builtins**
- nixpkgs/**lib**
- nixpkgs/build-support/**trivial-builders**
- Nixdoc (a fork) to collect nixpkgs.lib informations
- nix __dump-builtins + builtins-types.json for the nix builtins
### Search
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
- 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)
**View the prototype [here](https://noogle.dev)**
## We need your help / what is missing
- Parsing `Types:` into a real type signature tree
- Upstream missing type informations (like in /lib/attrsets.nix)
- 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
- improve share / social interactions
- Add filter by tags e.g. lib.lists
- Prepare for scaling up: Either use api or use indexedDB with WebAssembly for complete offline usage?
- Mobile optimization for reading on the go
- Clean up / enhance my nixdoc fork.
- Make the `sloppy` parser more error resistant
- Some valueable information can be used from the rnix AST ?
### Extend available function
Currently there is only a limited set of data.
Because nixpkgs is very inconsistently documented it is
really hard to extend the scope.
So if you want to help noogle, we must improve nixpkgs itself.
- [ ] Parsing `Types:` into a real type signature tree
- [ ] Fix: line beginnings that include Asterisk (*) : Is interpreted as List-Markdown
- [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
@ -62,4 +87,5 @@ Contributions are very welcome just file a PR or issue
`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.

View File

@ -1,5 +1,4 @@
import {
Box,
IconButton,
ListItemText,
Paper,
@ -9,15 +8,10 @@ import {
Typography,
} from "@mui/material";
import { useMemo } from "react";
import { DocItem, NixType } from "../../models/nix";
import { DocItem } from "../../models/nix";
import { Preview } from "../preview/preview";
import StarIcon from "@mui/icons-material/Star";
import ShareIcon from "@mui/icons-material/Share";
import { useLocalStorage } from "usehooks-ts";
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 {
selected: boolean;
@ -25,10 +19,9 @@ interface FunctionItemProps {
docItem: DocItem;
handleClose: () => void;
}
const getKey = (item: DocItem) => `${item.category}/${item.name}`;
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 { enqueueSnackbar } = useSnackbar();
const descriptionPreview = useMemo(() => {

View File

@ -3,12 +3,11 @@ import Paper from "@mui/material/Paper";
import InputBase from "@mui/material/InputBase";
import IconButton from "@mui/material/IconButton";
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 { NixType, nixTypes } from "../../models/nix";
import SearchIcon from "@mui/icons-material/Search";
import { usePageContext } from "../pageContext";
import { initialPageState } from "../../models/internals";
import { SelectOption } from "../selectOption";
export type Filter = { from: NixType; to: NixType };

View File

@ -125,6 +125,22 @@
"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": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
@ -173,6 +189,21 @@
"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": {
"flake": false,
"locked": {
@ -205,6 +236,27 @@
"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": {
"flake": false,
"locked": {
@ -309,6 +361,22 @@
"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": {
"locked": {
"lastModified": 1673027386,
@ -395,11 +463,36 @@
"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": {
"inputs": {
"dream2nix": "dream2nix",
"nixdoc-fork": "nixdoc-fork",
"nixpkgs": "nixpkgs_4"
"nixpkgs": "nixpkgs_4",
"pre-commit-hooks": "pre-commit-hooks_2"
}
},
"rust-analyzer-src": {

View File

@ -1,12 +1,18 @@
{
inputs.dream2nix.url = "github:nix-community/dream2nix";
inputs.nixdoc-fork.url = "github:hsjobeki/nixdoc";
outputs = {self, nixpkgs,...}@inp:
let
system = "x86_64-linux";
pkgs = inp.nixpkgs.legacyPackages.${system};
inherit (builtins.fromJSON (builtins.readFile ./package.json)) name;
in
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixdoc-fork.url = "github:hsjobeki/nixdoc";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
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 {
systemsFromFile = ./nix_systems;
config.projectRoot = ./.;
@ -19,8 +25,8 @@
packageOverrides = {
${name}.staticPage = {
preBuild = ''
cp ${inp.nixdoc-fork.packages.${system}.data.lib} ./models/data/lib.json
cp ${inp.nixdoc-fork.packages.${system}.data.build_support} ./models/data/trivial-builders.json
cp ${inp.nixdoc-fork.packages.${system}.data.lib} ./models/data/lib.json
cp ${inp.nixdoc-fork.packages.${system}.data.build_support} ./models/data/trivial-builders.json
'';
installPhase = ''
@ -37,7 +43,20 @@
})
// {
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;
};
};
};
};

View File

@ -49,6 +49,7 @@ const MyApp: React.FunctionComponent<MyAppProps> = (props) => {
<meta />
<meta name="robots" content="all" />
<link rel="icon" href="/favicon.png" />
<link rel="search" type="application/opensearchdescription+xml" title="Search nix function on noogle" href="/search.xml"></link>
</Head>
<CacheProvider value={emotionCache}>

10
public/search.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Noogle</ShortName>
<Description>Search for nix functions by name.</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/png">https://noogle.dev/favicon.png</Image>
<Url type="text/html" template="https://noogle.dev/?term=%22{searchTerms}%22"/>
<moz:SearchForm>https://noogle.dev</moz:SearchForm>
</OpenSearchDescription>

View File

@ -3,6 +3,7 @@
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
@ -16,5 +17,5 @@
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "result"]
}