feat: refactor to add apps README
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-01-20 12:34:07 -05:00
parent 2cab8107ba
commit 546eda3ee2
12 changed files with 81 additions and 52 deletions

View file

@ -133,11 +133,11 @@
apps =
perSystem (pkgs:
import ./apps {inherit inputs pkgs;});
import ./apps {inherit pkgs self;});
appsPackages =
perSystem (pkgs:
import ./apps/packages.nix {inherit pkgs self;});
import ./apps/packages.nix {inherit inputs pkgs;});
devShells =
perSystem (pkgs:

11
apps/README.md Normal file
View file

@ -0,0 +1,11 @@
# apps
This directory contains every derivations for apps exposed by this flake.
## List of my apps found in `self.apps`
| Name | Description |
| ---- | ----------- |
| `app-extract-subs` | Extract all `srt` subtitle files from a `mkv` video with the appropriate name. |
| `app-gen-docs` | Generates the READMEs in this repository from nix attributes. |
| `app-update-sources` | Updates all derivation sources in this repository and generates a commit message for the changes made. |

View file

@ -1,9 +1,10 @@
{
runtimeInputs,
npmDepsHash,
src,
lib,
src,
npmDepsHash,
runtimeInputs,
buildNpmPackage,
meta,
makeWrapper,
nodejs_latest,
jq,
@ -13,12 +14,11 @@
inherit (builtins) fromJSON readFile;
packageJSON = fromJSON (readFile "${src}/package.json");
in
buildNpmPackage rec {
pname = packageJSON.name;
inherit (packageJSON) version;
inherit src runtimeInputs npmDepsHash;
in
buildNpmPackage {
inherit pname version src runtimeInputs npmDepsHash;
prePatch = ''
mv ./tsconfig.json ./project.json
@ -35,5 +35,6 @@ in
'';
nodejs = nodejs_latest;
meta.mainProgram = pname;
meta = {mainProgram = pname;} // meta;
}

View file

@ -1,26 +1,17 @@
{
inputs,
pkgs,
self,
...
}: let
inherit (pkgs.lib) getExe listToAttrs nameValuePair;
inherit (pkgs.lib) getExe mapAttrs' nameValuePair removePrefix;
buildApp = attrs: (pkgs.callPackage ./buildApp.nix ({} // inputs // attrs));
mkNodeApp = file: {
program = getExe (pkgs.callPackage file ({inherit buildApp;} // inputs));
mkApp = pkg: {
program = getExe pkg;
type = "app";
};
mkNodeApps = apps: listToAttrs (map (x: nameValuePair x (mkNodeApp ./${x})) apps);
in
mkNodeApps [
"extract-subs"
"update-sources"
]
// {
gen-docs = {
program = getExe (pkgs.callPackage ./gen-docs {});
type = "app";
};
}
mapAttrs' (
n: v:
nameValuePair (removePrefix "app-" n) (mkApp v)
)
self.appsPackages.${pkgs.system}

View file

@ -10,4 +10,8 @@ buildApp {
runtimeInputs = [
ffmpeg-full
];
meta.description = ''
Extract all `srt` subtitle files from a `mkv` video with the appropriate name.
'';
}

View file

@ -8,4 +8,8 @@ writeShellApplication {
name = "gen-docs";
runtimeInputs = [jq pandoc];
text = builtins.readFile ./script.sh;
meta.description = ''
Generates the READMEs in this repository from nix attributes.
'';
}

View file

@ -1,7 +1,7 @@
packageMetaFunc=$(cat << EOF
(x: {
attrs = builtins.mapAttrs (_: v: {
desc = builtins.replaceStrings ["\n"] [""] (v.meta.description or "");
desc = builtins.replaceStrings ["\n"] [" "] (v.meta.description or "");
homepage = v.meta.homepage or "";
}) (builtins.removeAttrs x.\${builtins.currentSystem} ["default"]);
})
@ -14,10 +14,11 @@ substitute() {
nix eval \
--impure \
--json \
.#"$1" \
"$FLAKE"#"$1" \
--apply "$packageMetaFunc" |
jq -r
) -t markdown --template "$2" -o "$3"
}
substitute "devShells" "$FLAKE/apps/gen-docs/templates/devShells.md" "$FLAKE/devShells/README.md"
substitute "appsPackages" "$FLAKE/apps/gen-docs/templates/apps.md" "$FLAKE/apps/README.md"

View file

@ -0,0 +1,11 @@
# apps
This directory contains every derivations for apps exposed by this flake.
## List of my apps found in `self.apps`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -7,5 +7,5 @@ This directory contains every derivations for devShells exposed by this flake.
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| $it.key$ | $it.value.desc/nowrap$ |
| `$it.key$` | $it.value.desc/nowrap$ |
$endfor$

View file

@ -1,14 +1,15 @@
{
inputs,
pkgs,
self,
...
}: let
inherit (pkgs.lib) mapAttrs removeSuffix;
inherit (pkgs.lib) listToAttrs nameValuePair;
buildApp = attrs: (pkgs.callPackage ./buildApp.nix ({} // inputs // attrs));
callPackage = file: pkgs.callPackage file ({inherit buildApp;} // inputs);
in
mapAttrs (
name: app: (pkgs.symlinkJoin {
name = "app-${name}";
paths = [(removeSuffix "/bin/${name}" (toString app.program))];
})
)
(removeAttrs self.apps.${pkgs.system} ["genflake"])
listToAttrs (map (x: nameValuePair "app-${x}" (callPackage ./${x})) [
"extract-subs"
"gen-docs"
"update-sources"
])

View file

@ -18,4 +18,9 @@ buildApp {
prefetch-npm-deps
(callPackage ../../modules/docker/updateImage.nix {})
];
meta.description = ''
Updates all derivation sources in this repository and
generates a commit message for the changes made.
'';
}

View file

@ -6,14 +6,14 @@ This directory contains every derivations for devShells exposed by this flake.
| Name | Description |
| ---- | ----------- |
| c-lang | c-lang shell to be loaded by my Neovim config dynamically. |
| csharp | csharp shell to be loaded by my Neovim config dynamically. |
| flake | Shell providing some utility scripts concerning the main flake. |
| json | json shell to be loaded by my Neovim config dynamically. |
| lua | lua shell to be loaded by my Neovim config dynamically. |
| markdown | markdown shell to be loaded by my Neovim config dynamically. |
| netdaemon | Shell that makes sure we have the right dotnet-sdk version for NetDaemon development. |
| node | Shell that provides `bumpNpmDeps`, node and typescript. |
| rust | rust shell to be loaded by my Neovim config dynamically. |
| subtitles-dev | Shell that provides the dependencies for my subtitle management scripts. |
| web | web shell to be loaded by my Neovim config dynamically. |
| `c-lang` | c-lang shell to be loaded by my Neovim config dynamically. |
| `csharp` | csharp shell to be loaded by my Neovim config dynamically. |
| `flake` | Shell providing some utility scripts concerning the main flake. |
| `json` | json shell to be loaded by my Neovim config dynamically. |
| `lua` | lua shell to be loaded by my Neovim config dynamically. |
| `markdown` | markdown shell to be loaded by my Neovim config dynamically. |
| `netdaemon` | Shell that makes sure we have the right dotnet-sdk version for NetDaemon development. |
| `node` | Shell that provides `bumpNpmDeps`, node and typescript. |
| `rust` | rust shell to be loaded by my Neovim config dynamically. |
| `subtitles-dev` | Shell that provides the dependencies for my subtitle management scripts. |
| `web` | web shell to be loaded by my Neovim config dynamically. |