aux-search/flake-info/assets/commands/flake_info.nix

162 lines
5.4 KiB
Nix
Raw Normal View History

{ flake ? null }:
2021-08-17 08:55:08 +00:00
let
resolved = builtins.getFlake "input-flake";
2021-08-17 08:55:08 +00:00
nixpkgs = (import <nixpkgs> {});
lib = nixpkgs.lib;
# filter = lib.filterAttrs (key: _ : key == "apps" || key == "packages");
withSystem = fn: lib.mapAttrs (system: drvs: (fn system drvs));
isValid = d:
let
r = builtins.tryEval (lib.isDerivation d && ! (lib.attrByPath [ "meta" "broken" ] false d) &&
builtins.seq d.name true && d ? outputs);
2021-08-17 08:55:08 +00:00
in
r.success && r.value;
validPkgs = lib.filterAttrs (k: v: isValid v);
2021-08-17 08:55:08 +00:00
readPackages = system: drvs: lib.mapAttrsToList (
attribute_name: drv: (
{
entry_type = "package";
2021-08-17 08:55:08 +00:00
attribute_name = attribute_name;
system = system;
name = drv.name;
# TODO consider using `builtins.parseDrvName`
version = drv.version or "";
2021-08-17 08:55:08 +00:00
outputs = drv.outputs;
# paths = builtins.listToAttrs ( map (output: {name = output; value = drv.${output};}) drv.outputs );
default_output = drv.outputName;
2021-08-17 08:55:08 +00:00
}
// lib.optionalAttrs (drv ? meta && drv.meta ? description) { inherit (drv.meta) description; }
// lib.optionalAttrs (drv ? meta && drv.meta ? license) { inherit (drv.meta) license; }
)
) (validPkgs drvs);
2021-08-17 08:55:08 +00:00
readApps = system: apps: lib.mapAttrsToList (
attribute_name: app: (
{
entry_type = "app";
2021-08-17 08:55:08 +00:00
attribute_name = attribute_name;
system = system;
}
// lib.optionalAttrs (app ? outPath) { bin = app.outPath; }
// lib.optionalAttrs (app ? program) { bin = app.program; }
// lib.optionalAttrs (app ? type) { type = app.type; }
)
) apps;
readNixOSOptions = let
2021-08-17 08:55:08 +00:00
declarations = module: (
lib.evalModules {
modules = (if lib.isList module then module else [ module ]) ++ [
(
{ ... }: {
_module.check = false;
}
)
];
specialArgs = {
# !!! NixOS-specific. Unfortunately, NixOS modules can rely on the `modulesPath`
# argument to import modules from the nixos tree. However, most of the time
# this is done to import *profiles* which do not declare any options, so we
# can allow it.
modulesPath = "${nixpkgs.path}/nixos/modules";
};
2021-08-17 08:55:08 +00:00
}
).options;
cleanUpOption = extraAttrs: opt:
2021-08-17 08:55:08 +00:00
let
applyOnAttr = n: f: lib.optionalAttrs (builtins.hasAttr n opt) { ${n} = f opt.${n}; };
Flake support/frontend (#324) * Setup flake info extraction Prepare data model fro derivations (#1) Add flake info data (#1) Implement fetching general flake info (#1) Expose CLI (#1) Keep cargo happy Add some doc comments Pin to local nixpkgs to excessive downloads Extend visibility of some data objects Add command to extract infomation about defivations (#1) Add call new feature in main (#1) Include more information in derivation (#1) Add log access Always debug log stderr from nix Format nix script Collect systems per package Remove unnecessary imports Create flake Remove top level version field Represent collected systems/version pairs in rust Fix quotation marks in tests Add correct cargo hash Add iconv dependency Return a list from nix script Export as json Undo version by platform distinction Remove nixpkgs override Apply cargo fmt Flatten export structure Allow for complex licenses Prepare using a central nix file Implement nix part o accessing apps Include the correct filename Add accessor for `all` key Access all available information by default Track more information about Apps Run cargo fmt Fix: allow local builds Prepare next version of the flake info tool Include examples and pull script Expose flake info as library Include thiserror for custom errors Define a source data type Collects source types and their metadata, collected in a json file Add command line argument for input files Mutually exclusive with --flake Refactor functions to extract information given a flake identifier Add kind specifier as CLI argument Amend Argument parsing to require eiteher flake or targets to be defined Run extraction for specified flake or list of flakes as specified in a json file Resolves #5 References #7 Use internal tag to distnguich target types Include target falg usage in examples Set include provided source if available (resolves #9) Resolve flake name Update examples Dont include empty license or description Fix a misfomatting in cargot.toml Add elastic dependencies Implement a wrapper around the elasticsearch client Implements pushing exports (#4) Temporarily skip serializing an unimplemented field in elastic output Extract reading source list files from binary Add lazy_static as dependency Implement createing and pushing to elastic index Add elastic options Provide default name and env falbac for elastic index Modify app binary and type as optionals App can be a derivation too Update examples Add more elastic commands Supported: - ensure - clear - push Rename elastic search config struct Add elastic push support to binary Rename flag to enable elastic push Imporve error messages and format binary source Fix nix file incorrectly expecting meta fields Changing flake descriotions to an optional field deserialize git_ref as hash Implement temporary stores and gc of these prevents flakes from accessing store paths Pass extra arguments to nix Update cargo hash and skip integration tests Move flake.nix to root folder and add apps for all components Fix command invocation that fails test Update README(s) Add help for extra arguments (cherry picked from commit be4bc3dd929178bef66114c2201aaa88e47e9add) * Safely read legacyPackages * Read nixosOptions from flake * Update ES Mapping * Show more detailed error and backtrace if available * Try reading options only if key is defined * Format nix script * Add error context when attempting deserialization * Fix derivation representation to fit nix output * Add push elasticsearch settings * Add Flake channel * Rename import module * Remove Flakes Channel * Prepare nixpkgs import * Separate import/export types * Break up nixpkgs package representation * Use the same naming scheme for Nixpkgs entries and flake entries * Document import module * Remove serialization attributes * Reversable type and SerDe implemetation * Add *_reverse fields * Unpublicating export fields * Read from NixOption struct * serialize empty fields as null * Tag export json variants * Serialize a single option-declaration * Format npkgs parse test * Define NixOption Sorry thats too late.. * Parse system key * Make Package output compatible with the frontend * Add Url-only licesnse variant * Add StringOrStruct type * Add accessor method for elements catched by OneOrMany * New utility to flatten in homogenous lists recursively * Add Maintainer type catching maintaiers used in nixpkgs * Format Implementatio n * Remove explicit representation of platforms * Open nixpkgs parser to cover all packages * Convert all imported fields to their export representation * Define reverse fields in ES schema * Format nixpkgs command runner * Expose shorthand to pull a specific channel by command line * Extract utility functions into their own module * Implement AttributeQuery generation * Integrate query in export * Implement *_set attributes * Document purpose of export module * Use more descriptive github blob route * Complete Option Export representation Reuse the same option type for nixpkgs and flakes * Enable nixpkgs option import * Expose nixpkgs option import functions and integrate in binary * Chunk ElasticSearch Bulk operations * Address Example/Default field formatting * Add abort strategy for existing indices * New command line interface using subcommands * Document new interface * Bump version * Add nixpkgs cron job * More precise name for nixpkgs cron job * Add Flakes cron job * Read version from file and fix channel names * Correct file names for flake group import * Fix group command * Run new cron jobs on PR * Update Cargo sources * Integrate new flakes route * Add search type option * Add flake types and messages * Add flake types * Extract Request body builders and expose more types * Combine Package and Option Search * Factor out html body * Dispatch messages by search type to flake page * Correct type naming * Remove Debug instructions and unimplemented flake search type * Do not reload Flake search page while the search subject is unchanged * Implement switching subjects * Fix init type signature * Add url/git based flakes to mapping * Parse flake info * Link to flake repo and show flake maintainer * Fix optional decoded values * Add group and type as search buckts * Show search selection in all cases * Move flake decoding to search * Show flake information for options * Hardcode flakesearch to only search a specified flake index * Improve experimental state notice * Fix category select not present in some cases * Change default flake index * Show correct category title * Add missing imports * Serialize more optional fields as null * elastic-test.rs file not needed anymore * names of the workflows should be immediately obvious. * better jobs names * rename the flakes group * need to provide --elastic-schema-version via the cli option * typo * Fix errors in workflow files * Install flake enabled nix by default * Fix variable substitution * Use string group names * Provide elastic schema verion only through cli * Fix scheduled task name * Improve error reporting * Allow insecure packages here * Add missing imports * Tree-wide: cargo-fmt * only import nixpkgs for now * no importing of flakes * also bump a version * fixing cron-flakes.yml * make it obvious that this is for frontend * missed this when merging * Extract hashes - Split out revision info from flakes - Retrieve current nixpkgs revision from github * Write aliases, enabled by default * Filter additional platforms * Change alias structure * expect channel like nixpkgs identifiers * Don't cause error if push is aborted * Specify correct channel identifier * Allow options to evaluate unfree packages * Retrieve and delete specific aliases * Specify import path correclty * Fix channel warmup * Abort push if channel already indexed * Remove debug pr hook for import action * Fix indentation by tab * Make flakes show again * Fix import group naming in flake wrokflow * Rename flake group to match imported index * Run nixpkgs import on pr activity (Debugging behavior) * Just show literal Examples, resolves #336 * Use actual nixpkgs branch names * Trim derivation/option declaration path, resolves #335 Remove /nix/store/*-source prefix * Fix sidebar width and close button position * Placeholder texts in flake result area * Show flake install info * Don't show package/option selection before search * Make sure install command for nixos is always shown * Add toml source config support * Rewrite current example flake group as toml * Update flake cron job * flake-info: use saner nix packaging method When trying to first work in this I naive approached it with `nix-shell`. That of course lead to the fixed output bollocks failing with a hash mismatch. By making use of the `cargoLock` attribute on `buildRustPackage` we can tame the FOD-beast and only have to provide one hash manually for a single package (that we fetch from a GitHub repository). This also means that updating dependencies will be simpler as the native Cargo.lock file can be used. (cherry picked from commit c3a0e46d1eb56e128e6923e6c493eb836fc81e85) * Update flake lock file * Do not build python import script * add flake names to the title as well * Disable debug imports on prs Co-authored-by: Rok Garbas <rok@garbas.si> Co-authored-by: Andreas Rammhold <andreas@rammhold.de>
2021-08-25 22:40:42 +00:00
mkDeclaration = decl:
let
discard = lib.concatStringsSep "/" (lib.take 4 (lib.splitString "/" decl)) + "/";
Flake support/frontend (#324) * Setup flake info extraction Prepare data model fro derivations (#1) Add flake info data (#1) Implement fetching general flake info (#1) Expose CLI (#1) Keep cargo happy Add some doc comments Pin to local nixpkgs to excessive downloads Extend visibility of some data objects Add command to extract infomation about defivations (#1) Add call new feature in main (#1) Include more information in derivation (#1) Add log access Always debug log stderr from nix Format nix script Collect systems per package Remove unnecessary imports Create flake Remove top level version field Represent collected systems/version pairs in rust Fix quotation marks in tests Add correct cargo hash Add iconv dependency Return a list from nix script Export as json Undo version by platform distinction Remove nixpkgs override Apply cargo fmt Flatten export structure Allow for complex licenses Prepare using a central nix file Implement nix part o accessing apps Include the correct filename Add accessor for `all` key Access all available information by default Track more information about Apps Run cargo fmt Fix: allow local builds Prepare next version of the flake info tool Include examples and pull script Expose flake info as library Include thiserror for custom errors Define a source data type Collects source types and their metadata, collected in a json file Add command line argument for input files Mutually exclusive with --flake Refactor functions to extract information given a flake identifier Add kind specifier as CLI argument Amend Argument parsing to require eiteher flake or targets to be defined Run extraction for specified flake or list of flakes as specified in a json file Resolves #5 References #7 Use internal tag to distnguich target types Include target falg usage in examples Set include provided source if available (resolves #9) Resolve flake name Update examples Dont include empty license or description Fix a misfomatting in cargot.toml Add elastic dependencies Implement a wrapper around the elasticsearch client Implements pushing exports (#4) Temporarily skip serializing an unimplemented field in elastic output Extract reading source list files from binary Add lazy_static as dependency Implement createing and pushing to elastic index Add elastic options Provide default name and env falbac for elastic index Modify app binary and type as optionals App can be a derivation too Update examples Add more elastic commands Supported: - ensure - clear - push Rename elastic search config struct Add elastic push support to binary Rename flag to enable elastic push Imporve error messages and format binary source Fix nix file incorrectly expecting meta fields Changing flake descriotions to an optional field deserialize git_ref as hash Implement temporary stores and gc of these prevents flakes from accessing store paths Pass extra arguments to nix Update cargo hash and skip integration tests Move flake.nix to root folder and add apps for all components Fix command invocation that fails test Update README(s) Add help for extra arguments (cherry picked from commit be4bc3dd929178bef66114c2201aaa88e47e9add) * Safely read legacyPackages * Read nixosOptions from flake * Update ES Mapping * Show more detailed error and backtrace if available * Try reading options only if key is defined * Format nix script * Add error context when attempting deserialization * Fix derivation representation to fit nix output * Add push elasticsearch settings * Add Flake channel * Rename import module * Remove Flakes Channel * Prepare nixpkgs import * Separate import/export types * Break up nixpkgs package representation * Use the same naming scheme for Nixpkgs entries and flake entries * Document import module * Remove serialization attributes * Reversable type and SerDe implemetation * Add *_reverse fields * Unpublicating export fields * Read from NixOption struct * serialize empty fields as null * Tag export json variants * Serialize a single option-declaration * Format npkgs parse test * Define NixOption Sorry thats too late.. * Parse system key * Make Package output compatible with the frontend * Add Url-only licesnse variant * Add StringOrStruct type * Add accessor method for elements catched by OneOrMany * New utility to flatten in homogenous lists recursively * Add Maintainer type catching maintaiers used in nixpkgs * Format Implementatio n * Remove explicit representation of platforms * Open nixpkgs parser to cover all packages * Convert all imported fields to their export representation * Define reverse fields in ES schema * Format nixpkgs command runner * Expose shorthand to pull a specific channel by command line * Extract utility functions into their own module * Implement AttributeQuery generation * Integrate query in export * Implement *_set attributes * Document purpose of export module * Use more descriptive github blob route * Complete Option Export representation Reuse the same option type for nixpkgs and flakes * Enable nixpkgs option import * Expose nixpkgs option import functions and integrate in binary * Chunk ElasticSearch Bulk operations * Address Example/Default field formatting * Add abort strategy for existing indices * New command line interface using subcommands * Document new interface * Bump version * Add nixpkgs cron job * More precise name for nixpkgs cron job * Add Flakes cron job * Read version from file and fix channel names * Correct file names for flake group import * Fix group command * Run new cron jobs on PR * Update Cargo sources * Integrate new flakes route * Add search type option * Add flake types and messages * Add flake types * Extract Request body builders and expose more types * Combine Package and Option Search * Factor out html body * Dispatch messages by search type to flake page * Correct type naming * Remove Debug instructions and unimplemented flake search type * Do not reload Flake search page while the search subject is unchanged * Implement switching subjects * Fix init type signature * Add url/git based flakes to mapping * Parse flake info * Link to flake repo and show flake maintainer * Fix optional decoded values * Add group and type as search buckts * Show search selection in all cases * Move flake decoding to search * Show flake information for options * Hardcode flakesearch to only search a specified flake index * Improve experimental state notice * Fix category select not present in some cases * Change default flake index * Show correct category title * Add missing imports * Serialize more optional fields as null * elastic-test.rs file not needed anymore * names of the workflows should be immediately obvious. * better jobs names * rename the flakes group * need to provide --elastic-schema-version via the cli option * typo * Fix errors in workflow files * Install flake enabled nix by default * Fix variable substitution * Use string group names * Provide elastic schema verion only through cli * Fix scheduled task name * Improve error reporting * Allow insecure packages here * Add missing imports * Tree-wide: cargo-fmt * only import nixpkgs for now * no importing of flakes * also bump a version * fixing cron-flakes.yml * make it obvious that this is for frontend * missed this when merging * Extract hashes - Split out revision info from flakes - Retrieve current nixpkgs revision from github * Write aliases, enabled by default * Filter additional platforms * Change alias structure * expect channel like nixpkgs identifiers * Don't cause error if push is aborted * Specify correct channel identifier * Allow options to evaluate unfree packages * Retrieve and delete specific aliases * Specify import path correclty * Fix channel warmup * Abort push if channel already indexed * Remove debug pr hook for import action * Fix indentation by tab * Make flakes show again * Fix import group naming in flake wrokflow * Rename flake group to match imported index * Run nixpkgs import on pr activity (Debugging behavior) * Just show literal Examples, resolves #336 * Use actual nixpkgs branch names * Trim derivation/option declaration path, resolves #335 Remove /nix/store/*-source prefix * Fix sidebar width and close button position * Placeholder texts in flake result area * Show flake install info * Don't show package/option selection before search * Make sure install command for nixos is always shown * Add toml source config support * Rewrite current example flake group as toml * Update flake cron job * flake-info: use saner nix packaging method When trying to first work in this I naive approached it with `nix-shell`. That of course lead to the fixed output bollocks failing with a hash mismatch. By making use of the `cargoLock` attribute on `buildRustPackage` we can tame the FOD-beast and only have to provide one hash manually for a single package (that we fetch from a GitHub repository). This also means that updating dependencies will be simpler as the native Cargo.lock file can be used. (cherry picked from commit c3a0e46d1eb56e128e6923e6c493eb836fc81e85) * Update flake lock file * Do not build python import script * add flake names to the title as well * Disable debug imports on prs Co-authored-by: Rok Garbas <rok@garbas.si> Co-authored-by: Andreas Rammhold <andreas@rammhold.de>
2021-08-25 22:40:42 +00:00
path = if lib.hasPrefix builtins.storeDir decl then lib.removePrefix discard decl else decl;
in
path;
2021-08-17 08:55:08 +00:00
# Replace functions by the string <function>
substFunction = x:
if builtins.isAttrs x then
lib.mapAttrs (_:substFunction ) x
2021-08-17 08:55:08 +00:00
else if builtins.isList x then
map substFunction x
else if lib.isFunction x then
"function"
2021-08-17 08:55:08 +00:00
else
x;
2021-08-17 08:55:08 +00:00
in
Flake support/frontend (#324) * Setup flake info extraction Prepare data model fro derivations (#1) Add flake info data (#1) Implement fetching general flake info (#1) Expose CLI (#1) Keep cargo happy Add some doc comments Pin to local nixpkgs to excessive downloads Extend visibility of some data objects Add command to extract infomation about defivations (#1) Add call new feature in main (#1) Include more information in derivation (#1) Add log access Always debug log stderr from nix Format nix script Collect systems per package Remove unnecessary imports Create flake Remove top level version field Represent collected systems/version pairs in rust Fix quotation marks in tests Add correct cargo hash Add iconv dependency Return a list from nix script Export as json Undo version by platform distinction Remove nixpkgs override Apply cargo fmt Flatten export structure Allow for complex licenses Prepare using a central nix file Implement nix part o accessing apps Include the correct filename Add accessor for `all` key Access all available information by default Track more information about Apps Run cargo fmt Fix: allow local builds Prepare next version of the flake info tool Include examples and pull script Expose flake info as library Include thiserror for custom errors Define a source data type Collects source types and their metadata, collected in a json file Add command line argument for input files Mutually exclusive with --flake Refactor functions to extract information given a flake identifier Add kind specifier as CLI argument Amend Argument parsing to require eiteher flake or targets to be defined Run extraction for specified flake or list of flakes as specified in a json file Resolves #5 References #7 Use internal tag to distnguich target types Include target falg usage in examples Set include provided source if available (resolves #9) Resolve flake name Update examples Dont include empty license or description Fix a misfomatting in cargot.toml Add elastic dependencies Implement a wrapper around the elasticsearch client Implements pushing exports (#4) Temporarily skip serializing an unimplemented field in elastic output Extract reading source list files from binary Add lazy_static as dependency Implement createing and pushing to elastic index Add elastic options Provide default name and env falbac for elastic index Modify app binary and type as optionals App can be a derivation too Update examples Add more elastic commands Supported: - ensure - clear - push Rename elastic search config struct Add elastic push support to binary Rename flag to enable elastic push Imporve error messages and format binary source Fix nix file incorrectly expecting meta fields Changing flake descriotions to an optional field deserialize git_ref as hash Implement temporary stores and gc of these prevents flakes from accessing store paths Pass extra arguments to nix Update cargo hash and skip integration tests Move flake.nix to root folder and add apps for all components Fix command invocation that fails test Update README(s) Add help for extra arguments (cherry picked from commit be4bc3dd929178bef66114c2201aaa88e47e9add) * Safely read legacyPackages * Read nixosOptions from flake * Update ES Mapping * Show more detailed error and backtrace if available * Try reading options only if key is defined * Format nix script * Add error context when attempting deserialization * Fix derivation representation to fit nix output * Add push elasticsearch settings * Add Flake channel * Rename import module * Remove Flakes Channel * Prepare nixpkgs import * Separate import/export types * Break up nixpkgs package representation * Use the same naming scheme for Nixpkgs entries and flake entries * Document import module * Remove serialization attributes * Reversable type and SerDe implemetation * Add *_reverse fields * Unpublicating export fields * Read from NixOption struct * serialize empty fields as null * Tag export json variants * Serialize a single option-declaration * Format npkgs parse test * Define NixOption Sorry thats too late.. * Parse system key * Make Package output compatible with the frontend * Add Url-only licesnse variant * Add StringOrStruct type * Add accessor method for elements catched by OneOrMany * New utility to flatten in homogenous lists recursively * Add Maintainer type catching maintaiers used in nixpkgs * Format Implementatio n * Remove explicit representation of platforms * Open nixpkgs parser to cover all packages * Convert all imported fields to their export representation * Define reverse fields in ES schema * Format nixpkgs command runner * Expose shorthand to pull a specific channel by command line * Extract utility functions into their own module * Implement AttributeQuery generation * Integrate query in export * Implement *_set attributes * Document purpose of export module * Use more descriptive github blob route * Complete Option Export representation Reuse the same option type for nixpkgs and flakes * Enable nixpkgs option import * Expose nixpkgs option import functions and integrate in binary * Chunk ElasticSearch Bulk operations * Address Example/Default field formatting * Add abort strategy for existing indices * New command line interface using subcommands * Document new interface * Bump version * Add nixpkgs cron job * More precise name for nixpkgs cron job * Add Flakes cron job * Read version from file and fix channel names * Correct file names for flake group import * Fix group command * Run new cron jobs on PR * Update Cargo sources * Integrate new flakes route * Add search type option * Add flake types and messages * Add flake types * Extract Request body builders and expose more types * Combine Package and Option Search * Factor out html body * Dispatch messages by search type to flake page * Correct type naming * Remove Debug instructions and unimplemented flake search type * Do not reload Flake search page while the search subject is unchanged * Implement switching subjects * Fix init type signature * Add url/git based flakes to mapping * Parse flake info * Link to flake repo and show flake maintainer * Fix optional decoded values * Add group and type as search buckts * Show search selection in all cases * Move flake decoding to search * Show flake information for options * Hardcode flakesearch to only search a specified flake index * Improve experimental state notice * Fix category select not present in some cases * Change default flake index * Show correct category title * Add missing imports * Serialize more optional fields as null * elastic-test.rs file not needed anymore * names of the workflows should be immediately obvious. * better jobs names * rename the flakes group * need to provide --elastic-schema-version via the cli option * typo * Fix errors in workflow files * Install flake enabled nix by default * Fix variable substitution * Use string group names * Provide elastic schema verion only through cli * Fix scheduled task name * Improve error reporting * Allow insecure packages here * Add missing imports * Tree-wide: cargo-fmt * only import nixpkgs for now * no importing of flakes * also bump a version * fixing cron-flakes.yml * make it obvious that this is for frontend * missed this when merging * Extract hashes - Split out revision info from flakes - Retrieve current nixpkgs revision from github * Write aliases, enabled by default * Filter additional platforms * Change alias structure * expect channel like nixpkgs identifiers * Don't cause error if push is aborted * Specify correct channel identifier * Allow options to evaluate unfree packages * Retrieve and delete specific aliases * Specify import path correclty * Fix channel warmup * Abort push if channel already indexed * Remove debug pr hook for import action * Fix indentation by tab * Make flakes show again * Fix import group naming in flake wrokflow * Rename flake group to match imported index * Run nixpkgs import on pr activity (Debugging behavior) * Just show literal Examples, resolves #336 * Use actual nixpkgs branch names * Trim derivation/option declaration path, resolves #335 Remove /nix/store/*-source prefix * Fix sidebar width and close button position * Placeholder texts in flake result area * Show flake install info * Don't show package/option selection before search * Make sure install command for nixos is always shown * Add toml source config support * Rewrite current example flake group as toml * Update flake cron job * flake-info: use saner nix packaging method When trying to first work in this I naive approached it with `nix-shell`. That of course lead to the fixed output bollocks failing with a hash mismatch. By making use of the `cargoLock` attribute on `buildRustPackage` we can tame the FOD-beast and only have to provide one hash manually for a single package (that we fetch from a GitHub repository). This also means that updating dependencies will be simpler as the native Cargo.lock file can be used. (cherry picked from commit c3a0e46d1eb56e128e6923e6c493eb836fc81e85) * Update flake lock file * Do not build python import script * add flake names to the title as well * Disable debug imports on prs Co-authored-by: Rok Garbas <rok@garbas.si> Co-authored-by: Andreas Rammhold <andreas@rammhold.de>
2021-08-25 22:40:42 +00:00
opt
// { entry_type = "option"; }
2021-08-17 08:55:08 +00:00
// applyOnAttr "default" substFunction
// applyOnAttr "example" substFunction # (_: { __type = "function"; })
2021-08-17 08:55:08 +00:00
// applyOnAttr "type" substFunction
Flake support/frontend (#324) * Setup flake info extraction Prepare data model fro derivations (#1) Add flake info data (#1) Implement fetching general flake info (#1) Expose CLI (#1) Keep cargo happy Add some doc comments Pin to local nixpkgs to excessive downloads Extend visibility of some data objects Add command to extract infomation about defivations (#1) Add call new feature in main (#1) Include more information in derivation (#1) Add log access Always debug log stderr from nix Format nix script Collect systems per package Remove unnecessary imports Create flake Remove top level version field Represent collected systems/version pairs in rust Fix quotation marks in tests Add correct cargo hash Add iconv dependency Return a list from nix script Export as json Undo version by platform distinction Remove nixpkgs override Apply cargo fmt Flatten export structure Allow for complex licenses Prepare using a central nix file Implement nix part o accessing apps Include the correct filename Add accessor for `all` key Access all available information by default Track more information about Apps Run cargo fmt Fix: allow local builds Prepare next version of the flake info tool Include examples and pull script Expose flake info as library Include thiserror for custom errors Define a source data type Collects source types and their metadata, collected in a json file Add command line argument for input files Mutually exclusive with --flake Refactor functions to extract information given a flake identifier Add kind specifier as CLI argument Amend Argument parsing to require eiteher flake or targets to be defined Run extraction for specified flake or list of flakes as specified in a json file Resolves #5 References #7 Use internal tag to distnguich target types Include target falg usage in examples Set include provided source if available (resolves #9) Resolve flake name Update examples Dont include empty license or description Fix a misfomatting in cargot.toml Add elastic dependencies Implement a wrapper around the elasticsearch client Implements pushing exports (#4) Temporarily skip serializing an unimplemented field in elastic output Extract reading source list files from binary Add lazy_static as dependency Implement createing and pushing to elastic index Add elastic options Provide default name and env falbac for elastic index Modify app binary and type as optionals App can be a derivation too Update examples Add more elastic commands Supported: - ensure - clear - push Rename elastic search config struct Add elastic push support to binary Rename flag to enable elastic push Imporve error messages and format binary source Fix nix file incorrectly expecting meta fields Changing flake descriotions to an optional field deserialize git_ref as hash Implement temporary stores and gc of these prevents flakes from accessing store paths Pass extra arguments to nix Update cargo hash and skip integration tests Move flake.nix to root folder and add apps for all components Fix command invocation that fails test Update README(s) Add help for extra arguments (cherry picked from commit be4bc3dd929178bef66114c2201aaa88e47e9add) * Safely read legacyPackages * Read nixosOptions from flake * Update ES Mapping * Show more detailed error and backtrace if available * Try reading options only if key is defined * Format nix script * Add error context when attempting deserialization * Fix derivation representation to fit nix output * Add push elasticsearch settings * Add Flake channel * Rename import module * Remove Flakes Channel * Prepare nixpkgs import * Separate import/export types * Break up nixpkgs package representation * Use the same naming scheme for Nixpkgs entries and flake entries * Document import module * Remove serialization attributes * Reversable type and SerDe implemetation * Add *_reverse fields * Unpublicating export fields * Read from NixOption struct * serialize empty fields as null * Tag export json variants * Serialize a single option-declaration * Format npkgs parse test * Define NixOption Sorry thats too late.. * Parse system key * Make Package output compatible with the frontend * Add Url-only licesnse variant * Add StringOrStruct type * Add accessor method for elements catched by OneOrMany * New utility to flatten in homogenous lists recursively * Add Maintainer type catching maintaiers used in nixpkgs * Format Implementatio n * Remove explicit representation of platforms * Open nixpkgs parser to cover all packages * Convert all imported fields to their export representation * Define reverse fields in ES schema * Format nixpkgs command runner * Expose shorthand to pull a specific channel by command line * Extract utility functions into their own module * Implement AttributeQuery generation * Integrate query in export * Implement *_set attributes * Document purpose of export module * Use more descriptive github blob route * Complete Option Export representation Reuse the same option type for nixpkgs and flakes * Enable nixpkgs option import * Expose nixpkgs option import functions and integrate in binary * Chunk ElasticSearch Bulk operations * Address Example/Default field formatting * Add abort strategy for existing indices * New command line interface using subcommands * Document new interface * Bump version * Add nixpkgs cron job * More precise name for nixpkgs cron job * Add Flakes cron job * Read version from file and fix channel names * Correct file names for flake group import * Fix group command * Run new cron jobs on PR * Update Cargo sources * Integrate new flakes route * Add search type option * Add flake types and messages * Add flake types * Extract Request body builders and expose more types * Combine Package and Option Search * Factor out html body * Dispatch messages by search type to flake page * Correct type naming * Remove Debug instructions and unimplemented flake search type * Do not reload Flake search page while the search subject is unchanged * Implement switching subjects * Fix init type signature * Add url/git based flakes to mapping * Parse flake info * Link to flake repo and show flake maintainer * Fix optional decoded values * Add group and type as search buckts * Show search selection in all cases * Move flake decoding to search * Show flake information for options * Hardcode flakesearch to only search a specified flake index * Improve experimental state notice * Fix category select not present in some cases * Change default flake index * Show correct category title * Add missing imports * Serialize more optional fields as null * elastic-test.rs file not needed anymore * names of the workflows should be immediately obvious. * better jobs names * rename the flakes group * need to provide --elastic-schema-version via the cli option * typo * Fix errors in workflow files * Install flake enabled nix by default * Fix variable substitution * Use string group names * Provide elastic schema verion only through cli * Fix scheduled task name * Improve error reporting * Allow insecure packages here * Add missing imports * Tree-wide: cargo-fmt * only import nixpkgs for now * no importing of flakes * also bump a version * fixing cron-flakes.yml * make it obvious that this is for frontend * missed this when merging * Extract hashes - Split out revision info from flakes - Retrieve current nixpkgs revision from github * Write aliases, enabled by default * Filter additional platforms * Change alias structure * expect channel like nixpkgs identifiers * Don't cause error if push is aborted * Specify correct channel identifier * Allow options to evaluate unfree packages * Retrieve and delete specific aliases * Specify import path correclty * Fix channel warmup * Abort push if channel already indexed * Remove debug pr hook for import action * Fix indentation by tab * Make flakes show again * Fix import group naming in flake wrokflow * Rename flake group to match imported index * Run nixpkgs import on pr activity (Debugging behavior) * Just show literal Examples, resolves #336 * Use actual nixpkgs branch names * Trim derivation/option declaration path, resolves #335 Remove /nix/store/*-source prefix * Fix sidebar width and close button position * Placeholder texts in flake result area * Show flake install info * Don't show package/option selection before search * Make sure install command for nixos is always shown * Add toml source config support * Rewrite current example flake group as toml * Update flake cron job * flake-info: use saner nix packaging method When trying to first work in this I naive approached it with `nix-shell`. That of course lead to the fixed output bollocks failing with a hash mismatch. By making use of the `cargoLock` attribute on `buildRustPackage` we can tame the FOD-beast and only have to provide one hash manually for a single package (that we fetch from a GitHub repository). This also means that updating dependencies will be simpler as the native Cargo.lock file can be used. (cherry picked from commit c3a0e46d1eb56e128e6923e6c493eb836fc81e85) * Update flake lock file * Do not build python import script * add flake names to the title as well * Disable debug imports on prs Co-authored-by: Rok Garbas <rok@garbas.si> Co-authored-by: Andreas Rammhold <andreas@rammhold.de>
2021-08-25 22:40:42 +00:00
// applyOnAttr "declarations" (map mkDeclaration)
// extraAttrs;
in
{ module, modulePath ? null }: let
opts = lib.optionAttrSetToDocList (declarations module);
extraAttrs = lib.optionalAttrs (modulePath != null) {
flake = modulePath;
};
in
map (cleanUpOption extraAttrs) (lib.filter (x: x.visible && !x.internal && lib.head x.loc != "_module") opts);
2021-08-17 08:55:08 +00:00
readFlakeOptions = let
nixosModulesOpts = builtins.concatLists (lib.mapAttrsToList (moduleName: module:
readNixOSOptions {
inherit module;
modulePath = [ flake moduleName ];
}
) (resolved.nixosModules or {}));
2021-08-17 08:55:08 +00:00
nixosModuleOpts = lib.optionals (resolved ? nixosModule) (
readNixOSOptions {
module = resolved.nixosModule;
modulePath = [ flake ];
}
);
2021-08-17 08:55:08 +00:00
in
# We assume that `nixosModules` includes `nixosModule` when there
# are multiple modules
if nixosModulesOpts != [] then nixosModulesOpts else nixosModuleOpts;
2021-08-17 08:55:08 +00:00
read = reader: set: lib.flatten (lib.attrValues (withSystem reader set));
legacyPackages' = read readPackages (resolved.legacyPackages or {});
packages' = read readPackages (resolved.packages or {});
2021-08-17 08:55:08 +00:00
apps' = read readApps (resolved.apps or {});
2021-08-17 08:55:08 +00:00
collectSystems = lib.lists.foldr (
drv@{ attribute_name, system, ... }: set:
let
present = set."${attribute_name}" or ({ platforms = []; } // drv);
2021-08-17 08:55:08 +00:00
drv' = present // {
platforms = present.platforms ++ [ system ];
};
drv'' = removeAttrs drv' [ "system" ];
in
set // {
${attribute_name} = drv'';
}
) {};
in
rec {
legacyPackages = lib.attrValues (collectSystems legacyPackages');
packages = lib.attrValues (collectSystems packages');
apps = lib.attrValues (collectSystems apps');
options = readFlakeOptions;
2021-08-17 08:55:08 +00:00
all = packages ++ apps ++ options;
# nixpkgs-specific, doesn't use the flake argument
nixos-options = lib.mapAttrsToList (name: option: option // { inherit name; })
(builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile
"${(import <nixpkgs/nixos/release.nix> {}).options}/share/doc/nixos/options.json")));
2021-08-17 08:55:08 +00:00
}