scanned-image-extractor/flake.nix

110 lines
2.7 KiB
Nix
Raw Normal View History

2024-01-29 23:24:54 +00:00
{
2024-02-01 00:09:04 +00:00
description = "A tool for efficiently extracting rectangular photographs.";
2024-01-29 23:24:54 +00:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
2024-02-01 00:09:04 +00:00
nix-appimage.url = "github:ralismark/nix-appimage";
2024-01-29 23:24:54 +00:00
};
outputs = {
self,
nixpkgs,
2024-02-01 00:09:04 +00:00
nix-appimage,
2024-01-29 23:24:54 +00:00
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
2024-02-01 16:05:45 +00:00
name = "scannedImageExtractor";
2024-02-04 16:11:20 +00:00
version = "0.2.7-beta";
2024-01-29 23:24:54 +00:00
in {
2024-02-01 16:05:45 +00:00
packages.${system} = {
default = let
desktopItem = pkgs.makeDesktopItem {
inherit name;
2024-01-29 23:24:54 +00:00
2024-02-01 16:05:45 +00:00
exec = name;
desktopName = "Scanned Image Extractor";
terminal = false;
icon = name;
mimeTypes = ["x-content/image-dcf"];
categories = ["Graphics" "Photography" "GNOME" "KDE"];
};
in
pkgs.gccStdenv.mkDerivation {
inherit name;
src = ./.;
2024-02-01 00:09:04 +00:00
2024-02-01 16:05:45 +00:00
nativeBuildInputs = with pkgs; [
cmake
2024-02-01 20:11:28 +00:00
opencv3
2024-02-01 16:05:45 +00:00
liblbfgs
qt5.full
libsForQt5.qt5.wrapQtAppsHook
];
configurePhase = ''
2024-02-01 20:11:28 +00:00
cmake scannerExtract -DCMAKE_BUILD_TYPE=release
2024-02-01 16:05:45 +00:00
'';
buildPhase = ''
make
'';
installPhase = ''
install -m 555 ${name} -Dt $out/bin
# Install .desktop file
install -m 444 ${desktopItem}/share/applications/${name}.desktop -Dt $out/share/applications
# Install icons
for dimension in 128 256; do
2024-02-04 15:55:43 +00:00
install -m 444 $src/scannerExtract/ico/${name}''${dimension}x''${dimension}.png -D $out/share/icons/hicolor/''${dimension}x''${dimension}/apps/${name}.png
2024-02-01 16:05:45 +00:00
done
'';
};
2024-02-01 00:09:04 +00:00
appImage = let
src = nix-appimage.bundlers.${system}.default self.packages.${system}.default;
in
pkgs.stdenvNoCC.mkDerivation {
inherit name src;
dontUnpack = true;
dontBuild = true;
installPhase = ''
2024-02-04 16:11:20 +00:00
install -m 555 $src -D $out/${name}-v${version}.AppImage
2024-02-01 00:09:04 +00:00
'';
};
};
2024-02-01 16:05:45 +00:00
apps.${system} = {
appImage = {
program = "${pkgs.writeShellScript "scannedImageExtractor" ''
2024-02-04 16:11:20 +00:00
${pkgs.appimage-run}/bin/appimage-run ${self.packages.${system}.appImage}/${name}-v${version}.AppImage
2024-02-01 16:05:45 +00:00
''}";
type = "app";
};
};
2024-02-06 11:36:49 +00:00
overlays = {
default = final: prev: {
scanned-image-extractor = self.packages.${system}.default;
};
};
devShells.${system} = {
2024-02-01 00:09:04 +00:00
default = pkgs.mkShellNoCC {
packages = with pkgs; [
cmake
2024-02-01 20:11:28 +00:00
opencv3
2024-02-01 00:09:04 +00:00
liblbfgs
2024-02-06 11:36:49 +00:00
qt5.full
2024-02-01 00:09:04 +00:00
appimage-run
];
2024-01-29 23:24:54 +00:00
};
};
};
}