From 2e17c257815cd8c9951442d0da7ddcb1976f9eb1 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 15 Mar 2023 00:43:31 -0500 Subject: [PATCH] Get ICDM working Update libkiwix, kiwixtools, zimlib to latest upstream Update flake.nix to easily build stable/unstable systems --- flake.nix | 17 ++++++------ overlays/default.nix | 1 + overlays/kiwix-tools.nix | 4 +-- overlays/libkiwix.nix | 6 ++--- overlays/zimlib.nix | 57 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 overlays/zimlib.nix diff --git a/flake.nix b/flake.nix index 9eba4ca..f14421d 100644 --- a/flake.nix +++ b/flake.nix @@ -35,10 +35,12 @@ inputs.ffmac.overlay ]; + unstable = args: (machine (args // { channel = nixunstable; })); machine = { system ? "x86_64-linux", name, - channel ? stable + channel ? stable, + extraMods ? [] }: let nixpkgs = channel; @@ -47,7 +49,6 @@ modules = [ { nixpkgs.overlays = overlays; } agenix.nixosModule - wsl.nixosModules.wsl ./modules-all ./modules-linux ./hosts/${name} @@ -58,7 +59,7 @@ inherit nixpkgs; }; } - ]; + ] ++ extraMods; specialArgs = { home-manager = inputs.home-manager; inherit nixpkgs; @@ -67,16 +68,16 @@ in { nixosConfigurations = { - "2maccabees" = machine { system = "aarch64-linux"; name = "2maccabees"; channel = nixunstable; }; - jude = machine { name = "jude"; channel = nixunstable; }; - "icdm-root" = machine { name = "icdm-root"; }; + "2maccabees" = unstable { system = "aarch64-linux"; name = "2maccabees"; }; + jude = unstable { name = "jude"; }; + "icdm-root" = unstable { name = "icdm-root"; }; "linode" = machine { name = "linode"; }; "lappy" = machine { name = "lappy"; }; "iso" = machine { name = "iso"; }; # nix build '.#nixosConfigurations.wsl.config.system.build.installer' - "nixos" = machine { name = "wsl"; system = "aarch64-linux"; channel = nixunstable; }; + "nixos" = unstable { name = "wsl"; system = "aarch64-linux"; extraMods = [ wsl.nixosModules.wsl ]; }; # nix build '.#nixosConfigurations.wsl-aarch.config.system.build.installer' - "nixos-arm" = machine { name = "wsl"; system = "aarch64-linux"; channel = nixunstable; }; + "nixos-arm" = unstable { name = "wsl"; system = "aarch64-linux"; extraMods = [ wsl.nixosModules.wsl ]; }; }; darwinConfigurations = diff --git a/overlays/default.nix b/overlays/default.nix index 22fdcfb..6223620 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -64,6 +64,7 @@ in rec { }; kiwix-tools = super.callPackage ./kiwix-tools.nix {}; libkiwix = super.callPackage ./libkiwix.nix {}; + zimlib = super.callPackage ./zimlib.nix {}; xonsh = super.xonsh.overridePythonAttrs (old: rec{ python3 = self.gregpy; diff --git a/overlays/kiwix-tools.nix b/overlays/kiwix-tools.nix index 0f14137..0a542ef 100644 --- a/overlays/kiwix-tools.nix +++ b/overlays/kiwix-tools.nix @@ -19,9 +19,7 @@ stdenv.mkDerivation rec { owner = "kiwix"; repo = pname; rev = version; - # For 3.3.0 - #sha256 = "sha256-jeIyHTbgGrYknLaTNNSFVFo9zXyyGZU6dIVv49bEhBw="; - sha256 = "sha256-i3wr0VZCeH3aRCgphIyn6U91Ja+qVT4NVAzJSmniu8o="; + sha256 = "sha256-r3/aTH/YoDuYpKLPakP4toS3OtiRueTUjmR34rdmr+w="; }; nativeBuildInputs = [ diff --git a/overlays/libkiwix.nix b/overlays/libkiwix.nix index ba2dbd3..111d513 100644 --- a/overlays/libkiwix.nix +++ b/overlays/libkiwix.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { owner = "kiwix"; repo = pname; rev = version; - sha256 = "sha256-vE8bJrNx0oojTgcDhlr+SyfzdpigCZ0pQ2cPYaiZlgw="; + sha256 = "sha256-4FxLxJxVhqbeNqX4vorHkROUuRURvE6AXlteIZCEBtc="; }; nativeBuildInputs = [ @@ -47,10 +47,10 @@ stdenv.mkDerivation rec { zlib ]; - mesonFlags = [ "--debug" ]; + mesonFlags = [ "--debug" "-Dc_args=-I${zimlib}/include/" ]; # Built-in python script uses /usr/bin/env - patchPhase = "patchShebangs --build scripts/kiwix-compile-resources"; + patchPhase = "patchShebangs --build scripts/*"; meta = with lib; { description = "Kiwix file library for use by other applications"; diff --git a/overlays/zimlib.nix b/overlays/zimlib.nix new file mode 100644 index 0000000..ff00ac2 --- /dev/null +++ b/overlays/zimlib.nix @@ -0,0 +1,57 @@ +{ lib, stdenv, fetchFromGitHub +, meson, ninja, pkg-config +, python3 +, icu +, libuuid +, xapian +, xz +, zstd +, gtest +}: + +stdenv.mkDerivation rec { + pname = "zimlib"; + version = "8.1.0"; + + src = fetchFromGitHub { + owner = "openzim"; + repo = "libzim"; + rev = version; + sha256 = "sha256-ab7UUF+I0/xaGChvdjylEQRHLOjmtg/wk+/JEGehGLE="; + }; + + nativeBuildInputs = [ + meson + pkg-config + ninja + python3 + ]; + + propagatedBuildInputs = [ + icu + libuuid + xapian + xz + zstd + ]; + + postPatch = '' + patchShebangs scripts + ''; + + mesonFlags = [ "-Dtest_data_dir=none" ]; + + checkInputs = [ + gtest + ]; + + doCheck = true; + + meta = with lib; { + description = "Library for reading and writing ZIM files"; + homepage = "https://www.openzim.org/wiki/Zimlib"; + license = licenses.gpl2; + maintainers = with maintainers; [ ajs124 ]; + platforms = platforms.linux; + }; +}