Skip to content

Commit

Permalink
wrapper: update to ixx
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Oct 14, 2024
1 parent a409ad2 commit d46bd94
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 28 deletions.
25 changes: 25 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
ixx = {
# match version with npm package
url = "github:/NuschtOS/ixx/v0.0.3";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};

outputs = { nixpkgs, flake-utils, ... }:
outputs = { nixpkgs, flake-utils, ixx, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = (import nixpkgs) {
inherit system;
};
ixxPkgs = ixx.packages.${system};
in
{
devShells.default = pkgs.mkShell {
Expand All @@ -33,7 +42,7 @@

packages = rec {
nuscht-search = pkgs.callPackage ./nix/frontend.nix { };
inherit (pkgs.callPackages ./nix/wrapper.nix { inherit nuscht-search; }) mkOptionsJSON mkSearchJSON mkSearch mkMultiSearch;
inherit (pkgs.callPackages ./nix/wrapper.nix { inherit nuscht-search ixxPkgs; }) mkOptionsJSON mkSearchJSON mkSearch mkMultiSearch;
default = nuscht-search;
};
}
Expand Down
4 changes: 3 additions & 1 deletion nix/frontend.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ stdenv.mkDerivation (finalAttrs: {

pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-Ib3LtASKSLEnaLqa7nPIMX7I/FncL2pb7u7KcxaR4f8=";
# TODO: update hash
# @nuschtos/fixx is not yet released and still only a PR
hash = "sha256-QzuR/Xc8kAfqK4pO7sU2e+x9zCFPxfm6p3uBfx4eMmM=";
};

nativeBuildInputs = [ nodejs pnpm.configHook ];
Expand Down
58 changes: 36 additions & 22 deletions nix/wrapper.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, nixosOptionsDoc, jq, nuscht-search, python3, runCommand, xorg }:
{ lib, nixosOptionsDoc, jq, nuscht-search, ixxPkgs, python3, runCommand, xorg }:

rec {
mkOptionsJSON = modules: (nixosOptionsDoc {
Expand All @@ -18,29 +18,43 @@ rec {
mkSearchJSON = scopes:
let
optionsJSON = opt: opt.optionsJSON or (mkOptionsJSON opt.modules);
optionsJSONPrefixed = opt:
if opt?optionsJSON then (runCommand "options.json-prefixed"
{
nativeBuildInputs = [ jq ];
} /* bash */ ''
mkdir $out
jq -r '[to_entries[] | select(.key | test("^(_module|_freeformOptions|warnings|assertions|content)\\..*") | not)] | from_entries ${lib.optionalString (opt?optionsPrefix) ''| with_entries(.key as $key | .key |= "${opt.optionsPrefix}.\($key)")''}' ${optionsJSON opt} > $out/options.json
'') + /options.json else optionsJSON opt;
# optionsJSONPrefixed = opt:
# if opt?optionsJSON then (runCommand "options.json-prefixed"
# {
# nativeBuildInputs = [ jq ];
# } /* bash */ ''
# mkdir $out
# jq -r '[to_entries[] | select(.key | test("^(_module|_freeformOptions|warnings|assertions|content)\\..*") | not)] | from_entries ${lib.optionalString (opt?optionsPrefix) ''| with_entries(.key as $key | .key |= "${opt.optionsPrefix}.\($key)")''}' ${optionsJSON opt} > $out/options.json
# '') + /options.json else optionsJSON opt;
# in
# runCommand "options.json"
# { nativeBuildInputs = [ (python3.withPackages (ps: with ps; [ markdown pygments html-sanitizer ])) ]; }
# (''
# mkdir $out
# python \
# ${./fixup-options.py} \
# '' + lib.concatStringsSep " " (lib.flatten (map
# (opt: [
# (optionsJSONPrefixed opt)
# "'${opt.urlPrefix}'"
# ])
# scopes)) + ''
# > $out/options.json
# '');
config = {
scopes = map
(scope: (lib.filterAttrs (name: _value: name != "modules") scope) // { optionsJson = optionsJSON scope; })
scopes;
};
in
runCommand "options.json"
{ nativeBuildInputs = [ (python3.withPackages (ps: with ps; [ markdown pygments html-sanitizer ])) ]; }
(''
mkdir $out
python \
${./fixup-options.py} \
'' + lib.concatStringsSep " " (lib.flatten (map
(opt: [
(optionsJSONPrefixed opt)
"'${opt.urlPrefix}'"
])
scopes)) + ''
> $out/options.json
'');
{
value = builtins.toJSON config;
passAsFile = [ "value" ];
}
''
${lib.getExe ixxPkgs.ixx} index $valuePath
'';

# mkMultiSearch {
# baseHref = "/search/";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@feel/style": "^0.0.25",
"@fontsource/dm-mono": "^5.1.0",
"@fontsource/dm-sans": "^5.1.0",
"@nuschtos/fixx": "link:../ixx/result",
"@nuschtos/fixx": "^0.0.3",
"rxjs": "~7.8.1",
"tslib": "^2.7.0",
"zone.js": "~0.15.0"
Expand Down
9 changes: 7 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d46bd94

Please sign in to comment.