feat: add nyacc

This commit is contained in:
Jake Hamilton 2024-06-05 04:32:04 -07:00
parent 1642b2173b
commit 84633e1eb8
Signed by untrusted user: jakehamilton
GPG key ID: 9762169A1B35EA68
7 changed files with 104 additions and 9 deletions

View file

@ -3,7 +3,7 @@
"lib": { "lib": {
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-wgO96O9ALMMXtfBKuh9rYo3KIVq4nk8V7Cke4dg0MOk=", "narHash": "sha256-gJODnE6vuEI+ifNgmXywIpma4/uVfRayYknVQjDJN2c=",
"path": "../lib", "path": "../lib",
"type": "path" "type": "path"
}, },

View file

@ -3,6 +3,8 @@
config, config,
}: let }: let
system = config.aux.system; system = config.aux.system;
stage0 = config.aux.foundation.stages.stage0;
in { in {
options.aux.foundation.builders.file.text = { options.aux.foundation.builders.file.text = {
build = lib.options.create { build = lib.options.create {
@ -22,6 +24,7 @@ in {
extras ? {}, extras ? {},
... ...
}: let }: let
source = builtins.toFile "source" contents;
script = script =
'' ''
target=''${out}''${destination} target=''${out}''${destination}
@ -30,20 +33,18 @@ in {
mkdir -p ''${out}''${destinationDir} mkdir -p ''${out}''${destinationDir}
'' ''
+ '' + ''
cp ''${contentPath} ''${target} cp ${source} ''${target}
'' ''
+ lib.strings.when isExecutable '' + lib.strings.when isExecutable ''
chmod 555 ''${target} chmod 555 ''${target}
''; '';
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings ["meta" "extras" "executable" "isExecutable"]) (builtins.removeAttrs settings ["meta" "extras" "contents" "executable" "isExecutable"])
// { // {
inherit name system contents destination; inherit name system destination;
destinationDir = builtins.dirOf destination; destinationDir = builtins.dirOf destination;
passAsFile = ["contents"]; builder = "${stage0.kaem.package}/bin/kaem";
builder = "${config.aux.foundation.stages.stage0.kaem.package}/bin/kaem";
args = [ args = [
"--verbose" "--verbose"
@ -51,6 +52,10 @@ in {
"--file" "--file"
(builtins.toFile "write-text-to-file.kaem" script) (builtins.toFile "write-text-to-file.kaem" script)
]; ];
PATH = lib.paths.bin [
stage0.mescc-tools-extra.package
];
} }
); );
in in

View file

@ -27,7 +27,7 @@ in {
}: let }: let
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"]) (builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
env // env
// { // {
inherit name system; inherit name system;

View file

@ -6,6 +6,7 @@ let
exports = ./exports; exports = ./exports;
platform = ./platform; platform = ./platform;
stage0 = ./stages/stage0; stage0 = ./stages/stage0;
stage1 = ./stages/stage1;
system = ./system; system = ./system;
}; };
in in

View file

@ -5,12 +5,14 @@
cfg = config.aux.foundation.stages.stage1; cfg = config.aux.foundation.stages.stage1;
in { in {
includes = [ includes = [
./mes ./nyacc
# ./mes
]; ];
config = { config = {
exports = { exports = {
packages = { packages = {
stage1-nyacc = config.aux.foundation.stages.stage1.nyacc.package;
}; };
}; };
}; };

View file

@ -0,0 +1,78 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage1.nyacc;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
pname = "nyacc";
version = "1.00.2";
in {
options.aux.foundation.stages.stage1.nyacc = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for nyacc.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Modules for generating parsers and lexical analyzers.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://savannah.nongnu.org/projects/nyacc";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.lgpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["x86_64-linux" "aarch64-linux" "i686-linux"];
};
};
src = lib.options.create {
type = lib.types.string;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.nyacc = {
src = builtins.fetchurl {
url = "https://mirror.easyname.at/nongnu/nyacc/nyacc-${version}.tar.gz";
sha256 = "065ksalfllbdrzl12dz9d9dcxrv97wqxblslngsc6kajvnvlyvpk";
};
package = builders.kaem.build {
name = "${pname}-${version}";
meta = cfg.meta;
script = ''
ungz --file ${cfg.src} --output nyacc.tar
mkdir -p ''${out}/share
cd ''${out}/share
untar --file ''${NIX_BUILD_TOP}/nyacc.tar
'';
extras = {
#
guileModule = "${cfg.package}/share/${pname}-${version}/module";
};
};
};
};
}

View file

@ -130,6 +130,15 @@ lib: {
builtins.match "[ \t\n]*" value != null; builtins.match "[ \t\n]*" value != null;
}; };
## Return a given string if a condition is true, otherwise return
## an empty string.
##
## @type Bool -> String -> String
when = condition: value:
if condition
then value
else "";
## A table of ASCII characters mapped to their integer character code. ## A table of ASCII characters mapped to their integer character code.
## ##
## @type Attrs ## @type Attrs