remove generated files and move them to prepare script

This commit is contained in:
hsjobeki 2023-01-30 14:16:36 +01:00
parent a55c1b00c6
commit 6df8e554a5
6 changed files with 10 additions and 247 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@
# testing
/coverage
/models/data/*
# !/models/data/index.ts
# nix
.direnv/

View File

@ -12,6 +12,11 @@
system = "x86_64-linux";
pkgs = inp.nixpkgs.legacyPackages.${system};
inherit (builtins.fromJSON (builtins.readFile ./package.json)) name;
prepareData = ''
cp ${inp.nixdoc-fork.packages.${system}.data.lib} ./models/data/lib.json
cp ${inp.nixdoc-fork.packages.${system}.data.build_support} ./models/data/trivial-builders.json
node ./scripts/make-builtins.js
'';
in
(inp.dream2nix.lib.makeFlakeOutputs {
systemsFromFile = ./nix_systems;
@ -24,11 +29,7 @@
];
packageOverrides = {
${name}.staticPage = {
preBuild = ''
cp ${inp.nixdoc-fork.packages.${system}.data.lib} ./models/data/lib.json
cp ${inp.nixdoc-fork.packages.${system}.data.build_support} ./models/data/trivial-builders.json
'';
preBuild = prepareData;
installPhase = ''
runHook preInstall
@ -45,6 +46,7 @@
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [ nodejs-18_x ];
shellHook = ''
${prepareData}
${self.checks.${system}.pre-commit-check.shellHook}
'';
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,238 +0,0 @@
[
{
"id": "trivial-builders.runCommand",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "runCommand",
"fn_type": null,
"description": [
"Run the shell command `buildCommand' to produce a store path named\n`name'. The attributes in `env' are added to the environment\nprior to running the command. By default `runCommand` runs in a\nstdenv with no compiler environment. `runCommandCC` uses the default\nstdenv, `pkgs.stdenv`."
],
"example": "\nrunCommand \"name\" {envVariable = true;} ''echo hello > $out''\nrunCommandCC \"name\" {} ''gcc -o myfile myfile.c; cp myfile $out'';\nThe `*Local` variants force a derivation to be built locally,\nit is not substituted.\nThis is intended for very cheap commands (<1s execution time).\nIt saves on the network roundrip and can speed up a build.\nIt is the same as adding the special fields\n`preferLocalBuild = true;`\n`allowSubstitutes = false;`\nto a derivations attributes.\n"
},
{
"id": "trivial-builders.runCommandWith",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "runCommandWith",
"fn_type": null,
"description": [
"Generalized version of the `runCommand`-variants\nwhich does customized behavior via a single\nattribute set passed as the first argument\ninstead of having a lot of variants like\n`runCommand*`. Additionally it allows changing\nthe used `stdenv` freely and has a more explicit\napproach to changing the arguments passed to\n`stdenv.mkDerivation`."
],
"example": null
},
{
"id": "trivial-builders.writeTextFile",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeTextFile",
"fn_type": null,
"description": [
"Writes a text file to the nix store.\nThe contents of text is added to the file in the store."
],
"example": "\n# Writes my-file to /nix/store/<store path>\nwriteTextFile {\nname = \"my-file\";\ntext = ''\nContents of File\n'';\n}\nSee also the `writeText` helper function below.\n# Writes executable my-file to /nix/store/<store path>/bin/my-file\nwriteTextFile {\nname = \"my-file\";\ntext = ''\nContents of File\n'';\nexecutable = true;\ndestination = \"/bin/my-file\";\n}\n"
},
{
"id": "trivial-builders.writeText",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeText",
"fn_type": null,
"description": [
"Writes a text file to nix store with no optional parameters available."
],
"example": "\n# Writes contents of file to /nix/store/<store path>\nwriteText \"my-file\"\n''\nContents of File\n'';\n"
},
{
"id": "trivial-builders.writeTextDir",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeTextDir",
"fn_type": null,
"description": [
"Writes a text file to nix store in a specific directory with no\noptional parameters available."
],
"example": "\n# Writes contents of file to /nix/store/<store path>/share/my-file\nwriteTextDir \"share/my-file\"\n''\nContents of File\n'';\n"
},
{
"id": "trivial-builders.writeScript",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeScript",
"fn_type": null,
"description": [
"Writes a text file to /nix/store/<store path> and marks the file as\nexecutable.",
"If passed as a build input, will be used as a setup hook. This makes setup\nhooks more efficient to create: you don't need a derivation that copies\nthem to $out/nix-support/setup-hook, instead you can use the file as is."
],
"example": "\n# Writes my-file to /nix/store/<store path> and makes executable\nwriteScript \"my-file\"\n''\nContents of File\n'';\n"
},
{
"id": "trivial-builders.writeScriptBin",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeScriptBin",
"fn_type": null,
"description": [
"Writes a text file to /nix/store/<store path>/bin/<name> and\nmarks the file as executable."
],
"example": "\n# Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.\nwriteScriptBin \"my-file\"\n''\nContents of File\n'';\n"
},
{
"id": "trivial-builders.writeShellScript",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeShellScript",
"fn_type": null,
"description": [
"Similar to writeScript. Writes a Shell script and checks its syntax.\nAutomatically includes interpreter above the contents passed."
],
"example": "\n# Writes my-file to /nix/store/<store path> and makes executable.\nwriteShellScript \"my-file\"\n''\nContents of File\n'';\n"
},
{
"id": "trivial-builders.writeShellScriptBin",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeShellScriptBin",
"fn_type": null,
"description": [
"Similar to writeShellScript and writeScriptBin.\nWrites an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax.\nAutomatically includes interpreter above the contents passed."
],
"example": "\n# Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.\nwriteShellScriptBin \"my-file\"\n''\nContents of File\n'';\n"
},
{
"id": "trivial-builders.writeShellApplication",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeShellApplication",
"fn_type": null,
"description": [
"Similar to writeShellScriptBin and writeScriptBin.\nWrites an executable Shell script to /nix/store/<store path>/bin/<name> and\nchecks its syntax with shellcheck and the shell's -n option.\nAutomatically includes sane set of shellopts (errexit, nounset, pipefail)\nand handles creation of PATH based on runtimeInputs",
"Note that the checkPhase uses stdenv.shell for the test run of the script,\nwhile the generated shebang uses runtimeShell. If, for whatever reason,\nthose were to mismatch you might lose fidelity in the default checks."
],
"example": "\nWrites my-file to /nix/store/<store path>/bin/my-file and makes executable.\nwriteShellApplication {\nname = \"my-file\";\nruntimeInputs = [ curl w3m ];\ntext = ''\ncurl -s 'https://nixos.org' | w3m -dump -T text/html\n'';\n}\n"
},
{
"id": "trivial-builders.concatTextFile",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "concatTextFile",
"fn_type": null,
"description": [
"concat a list of files to the nix store.\nThe contents of files are added to the file in the store."
],
"example": "\n# Writes my-file to /nix/store/<store path>\nconcatTextFile {\n name = \"my-file\";\nfiles = [ drv1 \"${drv2}/path/to/file\" ];\n}\nSee also the `concatText` helper function below.\n# Writes executable my-file to /nix/store/<store path>/bin/my-file\nconcatTextFile {\nname = \"my-file\";\nfiles = [ drv1 \"${drv2}/path/to/file\" ];\nexecutable = true;\ndestination = \"/bin/my-file\";\n}\n"
},
{
"id": "trivial-builders.concatText",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "concatText",
"fn_type": null,
"description": [
"Writes a text file to nix store with no optional parameters available."
],
"example": "\n# Writes contents of files to /nix/store/<store path>\nconcatText \"my-file\" [ file1 file2 ]\n"
},
{
"id": "trivial-builders.concatScript",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "concatScript",
"fn_type": null,
"description": [
"Writes a text file to nix store with and mark it as executable."
],
"example": "\n# Writes contents of files to /nix/store/<store path>\nconcatScript \"my-file\" [ file1 file2 ]\n"
},
{
"id": "trivial-builders.symlinkJoin",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "symlinkJoin",
"fn_type": null,
"description": [
"Create a forest of symlinks to the files in `paths'.",
"This creates a single derivation that replicates the directory structure\nof all the input paths.",
"BEWARE: it may not \"work right\" when the passed paths contain symlinks to directories."
],
"example": "\n# adds symlinks of hello to current build.\nsymlinkJoin { name = \"myhello\"; paths = [ pkgs.hello ]; }\n# adds symlinks of hello and stack to current build and prints \"links added\"\nsymlinkJoin { name = \"myexample\"; paths = [ pkgs.hello pkgs.stack ]; postBuild = \"echo links added\"; }\nThis creates a derivation with a directory structure like the following:\n/nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample\n|-- bin\n| |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello\n| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack\n`-- share\n|-- bash-completion\n| `-- completions\n| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack\n|-- fish\n| `-- vendor_completions.d\n| `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish\n...\nsymlinkJoin and linkFarm are similar functions, but they output\nderivations with different structure.\nsymlinkJoin is used to create a derivation with a familiar directory\nstructure (top-level bin/, share/, etc), but with all actual files being symlinks to\nthe files in the input derivations.\nsymlinkJoin is used many places in nixpkgs to create a single derivation\nthat appears to contain binaries, libraries, documentation, etc from\nmultiple input derivations.\nlinkFarm is instead used to create a simple derivation with symlinks to\nother derivations. A derivation created with linkFarm is often used in CI\nas a easy way to build multiple derivations at once.\n"
},
{
"id": "trivial-builders.linkFarm",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "linkFarm",
"fn_type": null,
"description": [
"Quickly create a set of symlinks to derivations.",
"This creates a simple derivation with symlinks to all inputs.",
"entries can be a list of attribute sets like",
"\n[ { name = \"name\" ; path = \"/nix/store/...\"; } ]",
"\nor an attribute set name -> path like",
"\n{ name = \"/nix/store/...\"; other = \"/nix/store/...\"; }"
],
"example": "\n# Symlinks hello and stack paths in store to current $out/hello-test and\n# $out/foobar.\nlinkFarm \"myexample\" [ { name = \"hello-test\"; path = pkgs.hello; } { name = \"foobar\"; path = pkgs.stack; } ]\nThis creates a derivation with a directory structure like the following:\n/nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample\n|-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1\n`-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10\nSee the note on symlinkJoin for the difference between linkFarm and symlinkJoin.\n"
},
{
"id": "trivial-builders.linkFarmFromDrvs",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "linkFarmFromDrvs",
"fn_type": null,
"description": [
"Easily create a linkFarm from a set of derivations.",
"This calls linkFarm with a list of entries created from the list of input\nderivations. It turns each input derivation into an attribute set\nlike { name = drv.name ; path = drv }, and passes this to linkFarm."
],
"example": "\n# Symlinks the hello, gcc, and ghc derivations in $out\nlinkFarmFromDrvs \"myexample\" [ pkgs.hello pkgs.gcc pkgs.ghc ]\nThis creates a derivation with a directory structure like the following:\n/nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample\n|-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0\n|-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5\n`-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10\n"
},
{
"id": "trivial-builders.makeSetupHook",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "makeSetupHook",
"fn_type": null,
"description": [
"Make a package that just contains a setup hook with the given contents.\nThis setup hook will be invoked by any package that includes this package\nas a buildInput. Optionally takes a list of substitutions that should be\napplied to the resulting script."
],
"example": "\n# setup hook that depends on the hello package and runs ./myscript.sh\nmyhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh;\n# writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the\n# bash interpreter.\nmyhellohookSub = makeSetupHook {\ndeps = [ hello ];\nsubstitutions = { bash = \"${pkgs.bash}/bin/bash\"; };\nmeta.platforms = lib.platforms.linux;\n} ./myscript.sh;\n# setup hook with a package test\nmyhellohookTested = makeSetupHook {\ndeps = [ hello ];\nsubstitutions = { bash = \"${pkgs.bash}/bin/bash\"; };\nmeta.platforms = lib.platforms.linux;\npassthru.tests.greeting = callPackage ./test { };\n} ./myscript.sh;\n"
},
{
"id": "trivial-builders.writeDirectReferencesToFile",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeDirectReferencesToFile",
"fn_type": null,
"description": [
"Write the set of references to a file, that is, their immediate dependencies.",
"This produces the equivalent of `nix-store -q --references`."
],
"example": null
},
{
"id": "trivial-builders.writeStringReferencesToFile",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "writeStringReferencesToFile",
"fn_type": null,
"description": [
"Extract a string's references to derivations and paths (its\ncontext) and write them to a text file, removing the input string\nitself from the dependency graph. This is useful when you want to\nmake a derivation depend on the string's references, but not its\ncontents (to avoid unnecessary rebuilds, for example).",
"Note that this only works as intended on Nix >= 2.3."
],
"example": null
},
{
"id": "trivial-builders.requireFile",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "requireFile",
"fn_type": null,
"description": [
"Print an error message if the file with the specified name and\nhash doesn't exist in the Nix store. This function should only\nbe used by non-redistributable software with an unfree license\nthat we need to require the user to download manually. It produces\npackages that cannot be built automatically."
],
"example": "\nrequireFile {\nname = \"my-file\";\nurl = \"http://example.com/download/\";\nsha256 = \"ffffffffffffffffffffffffffffffffffffffffffffffffffff\";\n}\n"
},
{
"id": "trivial-builders.applyPatches",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "applyPatches",
"fn_type": null,
"description": ["Applies a list of patches to a source directory."],
"example": "\nPatching nixpkgs\napplyPatches {\n\tsrc = pkgs.path;\n\tpatches = [\n\t(pkgs.fetchpatch {\n\turl = \"https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch\";\n\tsha256 = \"1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr\";\n\t})\n\t];\n}\n"
},
{
"id": "trivial-builders.emptyFile",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "emptyFile",
"fn_type": null,
"description": ["An immutable file in the store with a length of 0 bytes."],
"example": null
},
{
"id": "trivial-builders.emptyDirectory",
"category": "./pkgs/build-support/trivial-builders.nix",
"name": "emptyDirectory",
"fn_type": null,
"description": ["An immutable empty directory in the store."],
"example": null
}
]

View File

@ -15,9 +15,8 @@ const info = Object.entries(builtins).map(([name, meta]) => {
],
};
});
fs.writeFile("./models/builtins.json", JSON.stringify(info), (err) => {
fs.writeFile("./models/data/builtins.json", JSON.stringify(info), (err) => {
if (err) {
console.error(err);
}
// file written successfully
});