packaged with a flake

This commit is contained in:
Kristian Krsnik 2024-02-01 01:09:04 +01:00
parent 1c725afb1d
commit e14dcbf39c
Signed by: Kristian
GPG Key ID: FD1330AC9F909E85
7 changed files with 191 additions and 16 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
result
.direnv/

10
README
View File

@ -1,3 +1,13 @@
# Scanner Image Extractor
This is a fork of [Scanner Image Extractor](http://www.dominik-ruess.de/scannerExtract).
It uses the nix build system and slight modification to the code to make it compile.
This flake also bundles the program into a self-contained AppImage to be run anywhere.
# Original README
/*********************************************************************** /***********************************************************************
* This file is part of Scanned Image Extractor. * This file is part of Scanned Image Extractor.
* *

128
flake.lock Normal file
View File

@ -0,0 +1,128 @@
{
"nodes": {
"appimage-runtime": {
"flake": false,
"locked": {
"lastModified": 1652289700,
"narHash": "sha256-uxQBDy/JA7uEboTOUmGaZ2FAKY/0dQ9c0A0N8+J+a7I=",
"owner": "AppImageCrafters",
"repo": "appimage-runtime",
"rev": "6500a1ef68e039caba2ebab1c7ed74c2ea9e67a5",
"type": "github"
},
"original": {
"owner": "AppImageCrafters",
"repo": "appimage-runtime",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nix-appimage": {
"inputs": {
"appimage-runtime": "appimage-runtime",
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"squashfuse": "squashfuse"
},
"locked": {
"lastModified": 1695276866,
"narHash": "sha256-/BBbYIoDhIPcVwhvau/g4lzrjTnudeRLW5qaTu7LAVs=",
"owner": "ralismark",
"repo": "nix-appimage",
"rev": "17dd6001ec228ea0b8505d6904fc5796d3de5012",
"type": "github"
},
"original": {
"owner": "ralismark",
"repo": "nix-appimage",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1659526864,
"narHash": "sha256-XFzXrc1+6DZb9hBgHfEzfwylPUSqVFJbQPs8eOgYufU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "478f3cbc8448b5852539d785fbfe9a53304133be",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.05",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1706371002,
"narHash": "sha256-dwuorKimqSYgyu8Cw6ncKhyQjUDOyuXoxDTVmAXq88s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c002c6aa977ad22c60398daaa9be52f2203d0006",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nix-appimage": "nix-appimage",
"nixpkgs": "nixpkgs_2"
}
},
"squashfuse": {
"flake": false,
"locked": {
"lastModified": 1655253282,
"narHash": "sha256-RIhDXzpmrYUOwj5OYzjWKJw0cwE+L3t/9pIkg/hFXA0=",
"owner": "vasi",
"repo": "squashfuse",
"rev": "d1d7ddafb765098b34239eacaf2f9abee1fbc27c",
"type": "github"
},
"original": {
"owner": "vasi",
"repo": "squashfuse",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,38 +1,71 @@
{ {
description = ""; description = "A tool for efficiently extracting rectangular photographs.";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-appimage.url = "github:ralismark/nix-appimage";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
nix-appimage,
}: let }: let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in {
packages.${system} = { packages.${system} = let
default = pkgs.stdenvNoCC.mkDerivation { name = "scannedImageExtractor";
name = "scannerExtract"; in {
default = pkgs.gccStdenv.mkDerivation {
inherit name;
src = ./.; src = ./.;
buildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
opencv3 cmake
opencv2
liblbfgs liblbfgs
qt6.full qt5.full
libsForQt5.qt5.wrapQtAppsHook
]; ];
dontUseCmakeConfigure = true;
buildPhase = '' buildPhase = ''
mkdir $out cmake scannerExtract -DCMAKE_BUILD_TYPE=release -DOPENCV2=1
cd $out
cmake $src/scannerExtract/ -DCMAKE_BUILD_TYPE=release
make make
# (make install)
''; '';
installPhase = ''
install -m 555 ${name} -Dt $out/bin
'';
};
appImage = let
src = nix-appimage.bundlers.${system}.default self.packages.${system}.default;
in
pkgs.stdenvNoCC.mkDerivation {
inherit name src;
dontUnpack = true;
dontBuild = true;
installPhase = ''
install -m 555 $src -D $out/${name}.AppImage
'';
};
};
devShells = {
default = pkgs.mkShellNoCC {
packages = with pkgs; [
cmake
opencv2
liblbfgs
gt5.full
appimage-run
];
}; };
}; };
}; };
} }
# http://www.dominik-ruess.de/scannerExtract/

View File

@ -1,5 +1,5 @@
#include <QLocale> #include <QLocale>
#include <QForeachContainer> // #include <QForeachContainer>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>

View File

@ -774,7 +774,7 @@ void MainWindow::noRotation()
{ {
QObject* item = i.next(); QObject* item = i.next();
QRadioButton* b = dynamic_cast<QRadioButton*>( item ); QRadioButton* b = dynamic_cast<QRadioButton*>( item );
if (b > 0 && b->isChecked()) { if (b != 0 && b->isChecked()) {
b->setAutoExclusive(false); b->setAutoExclusive(false);
b->setChecked(false); b->setChecked(false);
b->setAutoExclusive(true); b->setAutoExclusive(true);
@ -788,7 +788,7 @@ void MainWindow::noAspect()
while (i.hasNext()) while (i.hasNext())
{ {
QRadioButton* b = dynamic_cast<QRadioButton*>( i.next()); QRadioButton* b = dynamic_cast<QRadioButton*>( i.next());
if (b > 0 && b->isChecked()) { if (b != 0 && b->isChecked()) {
b->setAutoExclusive(false); b->setAutoExclusive(false);
b->setChecked(false); b->setChecked(false);
b->setAutoExclusive(true); b->setAutoExclusive(true);