diff --git a/pkgs/development/tools/cdecl/cdecl-2.5-lex.patch b/pkgs/by-name/cd/cdecl/cdecl-2.5-lex.patch similarity index 100% rename from pkgs/development/tools/cdecl/cdecl-2.5-lex.patch rename to pkgs/by-name/cd/cdecl/cdecl-2.5-lex.patch diff --git a/pkgs/by-name/cd/cdecl/package.nix b/pkgs/by-name/cd/cdecl/package.nix new file mode 100644 index 000000000000..016a15e9bea0 --- /dev/null +++ b/pkgs/by-name/cd/cdecl/package.nix @@ -0,0 +1,82 @@ +{ + lib, + stdenv, + fetchFromGitHub, + bison, + flex, + readline, + ncurses, +}: + +stdenv.mkDerivation { + pname = "cdecl"; + version = "2.5-unstable-2024-05-07"; + + src = fetchFromGitHub { + owner = "ridiculousfish"; + repo = "cdecl-blocks"; + rev = "1e6e1596771183d9bb90bcf152d6bc2055219a7e"; + hash = "sha256-5XuiYkFe+QvVBRIXRieKoE0zbISMvU1iLgEfkw6GnlE="; + }; + + patches = [ + ./cdecl-2.5-lex.patch + # when `USE_READLINE` is enabled, this option will not be present + ./test_remove_interactive_line.patch + ]; + + prePatch = '' + substituteInPlace cdecl.c \ + --replace 'getline' 'cdecl_getline' + ''; + + strictDeps = true; + + nativeBuildInputs = [ + bison + flex + ]; + + buildInputs = [ + readline + ncurses + ]; + + env = { + NIX_CFLAGS_COMPILE = toString ( + [ + "-DBSD" + "-DUSE_READLINE" + ] + ++ lib.optionals stdenv.cc.isClang [ + "-Wno-error=int-conversion" + "-Wno-error=incompatible-function-pointer-types" + ] + ); + NIX_LDFLAGS = "-lreadline"; + }; + + makeFlags = [ + "CC=${stdenv.cc.targetPrefix}cc" + "PREFIX=${placeholder "out"}" + "BINDIR=${placeholder "out"}/bin" + "MANDIR=${placeholder "out"}/man1" + "CATDIR=${placeholder "out"}/cat1" + ]; + + doCheck = true; + checkTarget = "test"; + + preInstall = '' + mkdir -p $out/bin; + ''; + + meta = { + description = "Translator English -- C/C++ declarations"; + homepage = "https://cdecl.org"; + license = lib.licenses.publicDomain; + maintainers = with lib.maintainers; [ sigmanificient ]; + platforms = lib.platforms.unix; + mainProgram = "cdecl"; + }; +} diff --git a/pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch b/pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch new file mode 100644 index 000000000000..5a769f2dfec9 --- /dev/null +++ b/pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch @@ -0,0 +1,10 @@ +--- a/test_expected_output.txt 2024-05-07 05:47:13.184419240 +0200 ++++ b/test_expected_output.txt 2024-05-07 05:48:38.980122345 +0200 +@@ -26,7 +26,6 @@ + options + create (-c), nocreate + prompt, noprompt (-q) +- interactive (-i), nointeractive + ritchie (-r), preansi (-p), ansi (-a) or cplusplus (-+) + + Current set values are: diff --git a/pkgs/development/tools/cdecl/default.nix b/pkgs/development/tools/cdecl/default.nix deleted file mode 100644 index 48870c7d2df1..000000000000 --- a/pkgs/development/tools/cdecl/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{lib, stdenv, fetchurl, bison, flex, readline, ncurses, gnused}: - -stdenv.mkDerivation rec { - pname = "cdecl"; - version = "2.5"; - src = fetchurl { - url = "https://www.cdecl.org/files/${pname}-blocks-${version}.tar.gz"; - sha256 = "1b7k0ra30hh8mg8fqv0f0yzkaac6lfg6n376drgbpxg4wwml1rly"; - }; - - patches = [ ./cdecl-2.5-lex.patch ]; - preBuild = '' - ${gnused}/bin/sed 's/getline/cdecl_getline/g' -i cdecl.c; - makeFlagsArray=(CFLAGS="-DBSD -DUSE_READLINE -std=gnu89" LIBS=-lreadline); - makeFlags="$makeFlags PREFIX=$out BINDIR=$out/bin MANDIR=$out/man1 CATDIR=$out/cat1 CC=$CC"; - mkdir -p $out/bin; - ''; - buildInputs = [bison flex readline ncurses]; - - meta = { - description = "Translator English -- C/C++ declarations"; - license = lib.licenses.publicDomain; - maintainers = with lib.maintainers; [ ]; - platforms = lib.platforms.unix; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7a4d81c02aa8..2f97ad44b874 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6608,8 +6608,6 @@ with pkgs; ccze = callPackage ../tools/misc/ccze { }; - cdecl = callPackage ../development/tools/cdecl { }; - cdi2iso = callPackage ../tools/cd-dvd/cdi2iso { }; cdist = python3Packages.callPackage ../tools/admin/cdist { };