Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ imgui.ini
compile_commands.json
include/xdg-output-unstable-v1-client-protocol.h
src/xdg-output-unstable-v1-protocol.c

# Nix Flake
result
result-*
87 changes: 65 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,73 @@
{
description = "Nix flake for oshot; a simple and lightweight tool for extracting text from a screenshot/image (on the fly)";
description = "oshot; a program to screenshot and get text from images";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs = { self, nixpkgs }: {
packages.x86_64-linux.oshot =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "oshot";
src = self;
nativeBuildInputs = [ cmake gnumake pkg-config git ];
buildInputs = [ glfw3 leptonica libx11.dev tesseract zbar.dev libappindicator-gtk3.dev dbus.dev systemd.dev libsysprof-capture pcre2.dev libxdmcp.dev libuuid.dev libselinux.dev libsepol.dev libthai.dev libdatrie.dev libdeflate lerc.dev xz.dev zstd.dev libwebp libxkbcommon.dev libepoxy.dev libxtst giflib ];
configurePhase = ''
cmake -DCMAKE_BUILD_PREFIX=/usr -DDEBUG=0 -G "Unix Makefiles" -B build -S .
'';
buildPhase = ''
cmake --build build -j$(nproc)
'';
installPhase = ''
install -Dm755 build/oshot $out/bin/oshot
install -Dm644 oshot.desktop $out/share/applications/oshot.desktop
install -Dm644 LICENSE $out/share/licenses/oshot/LICENSE
'';
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
version = "0.5.0-rc1";

mkOshot = { disablePlugins ? false }:
pkgs.stdenv.mkDerivation {
pname = if disablePlugins then "oshot" else "oshot-plugins";
inherit version;

src = ./.;

nativeBuildInputs = with pkgs; [
cmake
ninja
pkg-config
wrapGAppsHook3
wayland-scanner
];

buildInputs = with pkgs; [
glfw3
glew
tesseract
leptonica
zbar
libGL
libpng

libx11
libxcb
libxrandr
glib
gtk3
libappindicator-gtk3

systemd
libarchive
curl
libsysprof-capture
];

cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DDISABLE_PLUGINS=${if disablePlugins then "ON" else "OFF"}"
];

installPhase = ''
cmake --install . --prefix "$out"
'';
};
in {
packages.${system} = {
oshot-plugins = mkOshot {
disablePlugins = false;
};

oshot = mkOshot {
disablePlugins = true;
};

default = self.packages.${system}.oshot;
};
packages.x86_64-linux.default = self.packages.x86_64-linux.oshot;
};
};
}
34 changes: 22 additions & 12 deletions scripts/generateVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@ set -e
OUT="./include/version.h"
TMP="$(mktemp)"

# If we're outside a git checkout and already have a version header, keep it.
if [ ! -d ./.git ] && [ -f "$OUT" ]; then
rm -f "$TMP"
exit 0
# Fallback values if git is missing or not a git repository
IS_GIT_REPO=true
if ! command -v git >/dev/null 2>&1 || [ ! -d ./.git ]; then
IS_GIT_REPO=false
fi

cp ./include/version.h.in "$TMP"
if [ "$IS_GIT_REPO" = false ]; then
HASH=${HASH:-"unknown"}
BRANCH=${BRANCH:-"unknown"}
MESSAGE=${MESSAGE:-"standalone release"}
DATE=${DATE:-"unknown"}
DIRTY=${DIRTY:-"clean"}
TAG=${TAG:-"v0.5.0"}
COMMITS=${COMMITS:-"0"}
else
HASH=${HASH-$(git rev-parse HEAD)}
BRANCH=${BRANCH-$(git branch --show-current)}
MESSAGE=${MESSAGE-$(git log -1 --pretty=%B | head -n1 | sed -e 's/#//g' -e 's/\"//g')}
DATE=${DATE-$(git show --no-patch --format=%cd --date=local)}
DIRTY=${DIRTY-$(git diff-index --quiet HEAD && echo clean || echo dirty)}
TAG=${TAG-$(git describe --tags 2>/dev/null || echo "v0.5.0")}
COMMITS=${COMMITS-$(git rev-list --count HEAD 2>/dev/null || echo "0")}
fi

HASH=${HASH-$(git rev-parse HEAD)}
BRANCH=${BRANCH-$(git branch --show-current)}
MESSAGE=${MESSAGE-$(git log -1 --pretty=%B | head -n1 | sed -e 's/#//g' -e 's/\"//g')}
DATE=${DATE-$(git show --no-patch --format=%cd --date=local)}
DIRTY=${DIRTY-$(git diff-index --quiet HEAD && echo clean || echo dirty)}
TAG=${TAG-$(git describe --tags)}
COMMITS=${COMMITS-$(git rev-list --count HEAD)}
cp ./include/version.h.in "$TMP"

sed -i -e "s#@HASH@#$HASH#" "$TMP"
sed -i -e "s#@BRANCH@#$BRANCH#" "$TMP"
Expand Down
Loading