Skip to content
Open
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 Flakes
result
result-*
99 changes: 82 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,91 @@
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)
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
oshot = pkgs.stdenv.mkDerivation {
pname = "oshot";
version = "0.5.0-rc1";

src = ./.;

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

buildInputs = with pkgs; [
glfw3
leptonica
tesseract
zbar
gtk3
libappindicator-gtk3
dbus
systemd
libX11
libXtst
giflib
libwebp
libsysprof-capture
libXdmcp
zenity
pcre2
];

preConfigure = ''

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use nixOS, though why you need to setup a global git config just to build oshot?

export SOURCE_DATE_EPOCH=1
export GIT_AUTHOR_DATE="1970-01-01T00:00:01Z"
export GIT_COMMENTOR_DATE="1970-01-01T00:00:01Z"

git init -b nix-build
git config user.name "Nix"
git config user.email "nix@localhost"
git add .
git commit -m "dummy commit for build"
git tag -a v0.1.0 -m "v0.1.0"
'';

installPhase = ''
Comment thread
Toni500github marked this conversation as resolved.
install -Dm755 build/oshot $out/bin/oshot
install -Dm644 oshot.desktop $out/share/applications/oshot.desktop
install -Dm644 LICENSE $out/share/licenses/oshot/LICENSE
runHook preInstall

install -Dm755 oshot $out/bin/oshot
if [ -f oshot.desktop ]; then
install -Dm644 oshot.desktop $out/share/applications/oshot.desktop
fi
if [ -f LICENSE ]; then
install -Dm644 LICENSE $out/share/licenses/oshot/LICENSE
fi

runHook postInstall
'';
};
packages.x86_64-linux.default = self.packages.x86_64-linux.oshot;

default = self.packages.${system}.oshot;
});

nixosModules.default = { config, lib, pkgs, ... }: {
options.programs.oshot.enable = lib.mkEnableOption "oshot text extraction and screenshot tool";
Comment thread
Toni500github marked this conversation as resolved.

config = lib.mkIf config.programs.oshot.enable {
environment.systemPackages = [
self.packages.${pkgs.system}.oshot
];
};
};
};
}
Loading