1
0
mirror of https://github.com/NuschtOS/search.git synced 2024-11-21 11:19:06 +01:00
Go to file
2024-11-18 14:28:28 +01:00
.github Add 24.11 to CI (#171) 2024-11-17 20:57:14 +01:00
nix wrapper: make mkSearch overrideable (#178) 2024-11-18 14:28:28 +01:00
public ixx: init 2024-10-21 23:13:11 +02:00
src code: allow breaks 2024-11-04 23:42:50 +01:00
.editorconfig Copy template files (#8) 2024-06-28 22:24:36 +02:00
.envrc Add direnv 2024-10-09 00:17:12 +02:00
.gitignore ixx: init 2024-10-21 23:13:11 +02:00
.npmrc Initial Commit 2024-06-23 22:07:29 +02:00
angular.json Initial Commit 2024-06-23 22:07:29 +02:00
flake.lock Update nixpkgs digest to 5e4fbfb (#172) 2024-11-17 21:00:57 +01:00
flake.nix wrapper: make mkSearch overrideable (#178) 2024-11-18 14:28:28 +01:00
LICENSE upstream merge template repository (#111) 2024-10-12 04:13:59 +02:00
package.json node: update deps (#177) 2024-11-17 21:12:06 +01:00
pnpm-lock.yaml node: update deps (#177) 2024-11-17 21:12:06 +01:00
README.md Write better usage doc (#165) 2024-11-07 07:46:16 +01:00
tsconfig.app.json Initial Commit 2024-06-23 22:07:29 +02:00
tsconfig.json Initial Commit 2024-06-23 22:07:29 +02:00
tsconfig.spec.json Initial Commit 2024-06-23 22:07:29 +02:00

NüschtOS Search

Simple and fast static-page NixOS option search

Deployments

Usage

There are two functions exposeed to build the directory containing the static search:

  • mkMultiSearch to build a search with multiple scopes (modules). It takes the baseHref, title and scopes option.
  • mkSearch is a thin wrapper around mkMultiSearch to only use one scope (module). It takes the modules, optionsJSON, optionsPrefix, urlPrefix, baseHref and title option.

Explanation of options

  • baseHref - The directory to where the search is going to be deployed relative to the domain. Defaults to /.

  • title - The title on the top left. Defaults to NüschtOS Search.

  • modules - A list of NixOS modules as an attrset or file similar to the nixosSystem function. Exclusive with optionsJSON.

  • optionsJSON - Path to a pre-generated options.json file. Exclusive with modules.

  • optionsPrefix - A static prefix to append to all options. An extra dot is always appended. Defaults to being empty.

  • urlPrefix - The prefix which is prepended to the declaration link. This is usually a link to a git.

  • scopes is a list of attributes which each takes name, modules, optionsJSON, optionsPrefix or urlPrefix option.

Examples

mkMultiSearch {
  baseHref = "/search/";
  title = "Custom Search";
  scopes = [ {
    name = "NixOS Modules";
    modules = [ self.inputs.nixos-modules.nixosModule ];
    urlPrefix = "https://github.com/NuschtOS/nixos-modules/blob/main/";
  } {
    name = "Example Module";
    optionsJSON = ./path/to/options.json;
    optionsPrefix = "programs.example";
    urlPrefix = "https://git.example.com/blob/main/";
  } ];
};
mkSearch { modules = [ self.inputs.nixos-modules.nixosModule ]; urlPrefix = "https://github.com/NuschtOS/nixos-modules/blob/main/"; }
mkSearch { optionsJSON = ./path/to/options.json; optionsPrefix = "programs.example"; urlPrefix = "https://git.example.com/blob/main/"; }
mkSearch { optionsJSON = ./path/to/options.json; urlPrefix = "https://git.example.com/blob/main/"; baseHref = "/search/"; title = "Custom Search"; }

Motivation

We wanted something similar to https://search.nixos.org to easily search through all the flakes options across many projects we accumulated in projects but without the need to deploy an Elasticsearch. Ideally it should be just a static site with json blob that can be deployed on GitHub pages.

FAQ

Missing declaration

This is most often caused by using nix' import keyword to load a module in the flake instead of referencing it via the path type. This causes the module system to no longer be aware of the origin of the module and the missing declaration.

If no arguments are being hand over, this can be easily fixed by removing the import keyword. (e.g. change in sops-nix) If arguments are being hand over, the module needs to be slightly refactored. It is often the easiest to move everything depending on the arguments into the flake.nix and loading the module via the module systems imports variable. (e.g. change in ifstate.nix)

default/example is a string/has extra surrounding quotes

This is caused by a missing lib.literalExpression in default/example. Please open a pull request against the source of that option to fix this.

Debugging options.json

Generating a options.json in a nix repl can be done with the following snippet:

:b (pkgs.nixosOptionsDoc { inherit ((lib.evalModules { modules = [ { config._module.check = false; } outputs.nixosModules.default ]; })) options; warningsAreErrors = false; }).optionsJSON

It is assumed that the flake was loaded before with :lf and the module(s) is/are under nixosModules.default. For some flakes this may need to be adapted.

Contact

For bugs and issues please open an issue in this repository.

If you want to chat about things or have ideas, feel free to join the Matrix chat.