cleanup derivations

This commit is contained in:
Adithya 2024-05-24 20:28:07 +05:30
parent b5a37173b0
commit f3374e0e31
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
4 changed files with 80 additions and 39 deletions

View file

@ -12,23 +12,27 @@
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
}; };
packages = rec {
libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { };
varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; };
fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; };
};
in in
{ {
formatter = pkgs.nixpkgs-fmt; formatter = pkgs.nixpkgs-fmt;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = with pkgs; [ packages = (with pkgs; [
go_1_22 go_1_22
gnumake gnumake
meson meson
ninja ninja
cmake cmake
pkg-config pkg-config
]; ]) ++ (with packages; [ libgovarnam ]);
}; };
packages = rec { packages = {
libgovarnam = pkgs.callPackage ./govarnam/default.nix { }; inherit (packages) libgovarnam varnam-cli fcitx5-varnam;
varnam-cli = pkgs.callPackage ./govarnam/default.nix { cli = true; };
fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; };
}; };
} }
); );

View file

@ -2,11 +2,11 @@
, buildGoModule , buildGoModule
, fetchFromGitHub , fetchFromGitHub
, pkg-config , pkg-config
, cli ? false , libgovarnam
}: }:
buildGoModule rec { buildGoModule rec {
pname = "libgovarnam"; pname = "varnam-cli";
version = "1.9.1"; version = "1.9.1";
src = fetchFromGitHub { src = fetchFromGitHub {
@ -21,46 +21,26 @@ buildGoModule rec {
CGO_ENABLED = 1; CGO_ENABLED = 1;
nativeBuildInputs = [ pkg-config ]; nativeBuildInputs = [ pkg-config libgovarnam ];
buildPhase =
let buildcli = ''go build -o varnamcli -ldflags "-s -w -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}'" ./cli'';
in ''
runHook preInstall
go build -tags "fts5" -buildmode=c-shared -ldflags "-s -w -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}' -extldflags "-Wl,-soname,${pname}.so.1,--version-script,${src}/govarnam.syms"" -o ${pname}.so . ldflags = [
${lib.optionalString cli "${buildcli}"} "-w"
"-s"
"-X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)'"
"-X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}'"
];
runHook postInstall
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp ${pname}.so $out/lib/${pname}.so.${version}
ln -s $out/lib/${pname}.so.${version} $out/lib/${pname}.so
ln -s $out/lib/${pname}.so.${version} $out/lib/${pname}.so.1
mkdir -p $out/lib/pkgconfig
cp govarnam.pc.in $out/lib/pkgconfig/govarnam.pc
sed -i "s#@INSTALL_PREFIX@#$out/lib#g" $out/lib/pkgconfig/govarnam.pc
mkdir -p $out/include/${pname}
cp *.h $out/include/${pname}/
${lib.optionalString cli "install -Dt $out/bin varnamcli"}
runHook postInstall
'';
subPackages = [
"cli"
];
meta = { meta = {
description = "Easily type Indic languages on computer and mobile. GoVarnam is a cross-platform transliteration library. Manglish -> Malayalam, Thanglish -> Tamil, Hinglish -> Hindi plus another 10 languages. GoVarnam is a near-Go port of libvarnam"; description = "Easily type Indic languages on computer and mobile. GoVarnam is a cross-platform transliteration library. Manglish -> Malayalam, Thanglish -> Tamil, Hinglish -> Hindi plus another 10 languages. GoVarnam is a near-Go port of libvarnam";
homepage = "https://github.com/varnamproject/govarnam"; homepage = "https://github.com/varnamproject/govarnam";
license = lib.licenses.agpl3Only; license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ adtya ]; maintainers = with lib.maintainers; [ adtya ];
pkgConfigModules = [ "libgovarnam" ];
}; };
} }

58
govarnam/libgovarnam.nix Normal file
View file

@ -0,0 +1,58 @@
{ lib
, buildGoModule
, fetchFromGitHub
}:
buildGoModule rec {
pname = "libgovarnam";
version = "1.9.1";
src = fetchFromGitHub {
owner = "varnamproject";
repo = "govarnam";
rev = "v${version}";
hash = "sha256-7SYdeOMgc8VBx0rsu6tWGND9mq0Td1VeGmZrpfsWsVE=";
fetchSubmodules = true;
};
vendorHash = "sha256-a7m2THvdi17muJI6p6OVX9cBMcmocYwju29beG2H8CY=";
CGO_ENABLED = 1;
buildPhase = ''
runHook preInstall
go build -tags "fts5" -buildmode=c-shared -ldflags "-s -w -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}' -extldflags "-Wl,-soname,${pname}.so.1,--version-script,${src}/govarnam.syms"" -o ${pname}.so .
runHook postInstall
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp ${pname}.so $out/lib/${pname}.so.${version}
ln -s $out/lib/${pname}.so.${version} $out/lib/${pname}.so
ln -s $out/lib/${pname}.so.${version} $out/lib/${pname}.so.1
mkdir -p $out/lib/pkgconfig
cp govarnam.pc.in $out/lib/pkgconfig/govarnam.pc
sed -i "s#@INSTALL_PREFIX@#$out#g" $out/lib/pkgconfig/govarnam.pc
sed -i "s#@VERSION@#${version}#g" $out/lib/pkgconfig/govarnam.pc
mkdir -p $out/include/${pname}
cp *.h $out/include/${pname}/
runHook postInstall
'';
meta = {
description = "Easily type Indic languages on computer and mobile. GoVarnam is a cross-platform transliteration library. Manglish -> Malayalam, Thanglish -> Tamil, Hinglish -> Hindi plus another 10 languages. GoVarnam is a near-Go port of libvarnam";
homepage = "https://github.com/varnamproject/govarnam";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ adtya ];
pkgConfigModules = [ pname ];
};
}

View file

@ -75,7 +75,6 @@ stdenv.mkDerivation rec {
homepage = "https://github.com/varnamproject/varnam-fcitx5"; homepage = "https://github.com/varnamproject/varnam-fcitx5";
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ adtya ]; maintainers = with lib.maintainers; [ adtya ];
mainProgram = "varnam-fcitx5";
platforms = lib.platforms.linux; platforms = lib.platforms.linux;
}; };
} }