Skip to content

Commit

Permalink
wrapper: make mkSearch overrideable (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Nov 18, 2024
1 parent 64832c4 commit fe07070
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

packages = rec {
nuscht-search = pkgs.callPackage ./nix/frontend.nix { };
inherit (pkgs.callPackages ./nix/wrapper.nix { inherit nuscht-search ixxPkgs; }) mkOptionsJSON mkSearchJSON mkSearch mkMultiSearch;
inherit (pkgs.callPackages ./nix/wrapper.nix { inherit ixxPkgs nuscht-search; }) mkOptionsJSON mkSearchJSON mkSearch mkMultiSearch;
default = nuscht-search;
};
}
Expand Down
30 changes: 15 additions & 15 deletions nix/wrapper.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, nixosOptionsDoc, nuscht-search, ixxPkgs, runCommand, xorg }:
{ ixxPkgs, lib, nuscht-search, pkgs }:

rec {
mkOptionsJSON = { modules, specialArgs }: (nixosOptionsDoc {
mkOptionsJSON = pkgs.callPackage ({ modules, specialArgs, nixosOptionsDoc }: (nixosOptionsDoc {
inherit ((lib.evalModules {
modules = modules ++ [
({ lib, ... }: {
Expand All @@ -14,9 +14,9 @@ rec {
inherit specialArgs;
})) options;
warningsAreErrors = false;
}).optionsJSON + /share/doc/nixos/options.json;
}).optionsJSON + /share/doc/nixos/options.json);

mkSearchData = scopes:
mkSearchData = pkgs.callPackage ({ scopes, runCommand }:
let
config.scopes = map (scope: {
inherit (scope) urlPrefix;
Expand All @@ -42,22 +42,22 @@ rec {
--meta-output $out/meta \
--chunk-size 500 \
$configPath
'';
'');

# also update README examples
mkMultiSearch = { scopes, baseHref ? "/", title ? "NüschtOS Search" }:
runCommand "nuscht-search"
{ nativeBuildInputs = [ xorg.lndir ]; }
''
mkdir $out
lndir ${nuscht-search.override { inherit baseHref title; }} $out
ln -s ${mkSearchData scopes}/{meta,index.ixx} $out
'';
mkMultiSearch = pkgs.callPackage ({ scopes, baseHref ? "/", title ? "NüschtOS Search", runCommand, xorg }:
runCommand "nuscht-search" {
nativeBuildInputs = [ xorg.lndir ];
} ''
mkdir $out
lndir ${nuscht-search.override { inherit baseHref title; }} $out
ln -s ${mkSearchData { inherit scopes; }}/{meta,index.ixx} $out
'');

# also update README examples
mkSearch = { baseHref ? "/", title ? "NüschtOS Search", ... }@args:
mkSearch = pkgs.callPackage ({ baseHref ? "/", title ? "NüschtOS Search", ... }@args:
mkMultiSearch {
inherit baseHref title;
scopes = [ (lib.removeAttrs args [ "baseHref" "title" ]) ];
};
});
}

0 comments on commit fe07070

Please sign in to comment.