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 @@ -54,3 +54,7 @@ AppDir
.cache
imgui.ini
compile_commands.json

# Flake.nix stuff
result
result-*
19 changes: 18 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 77 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,83 @@

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
'';
};
packages.x86_64-linux.default = self.packages.x86_64-linux.oshot;
oshot-src = {
url = "github:Toni500github/oshot";
flake = false;
};
};

outputs = { self, nixpkgs, oshot-src }:
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.1.0";

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.

We are at version v0.5.0-rc1. Is this related to oshot's package version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, this is related to the oshot package version. Forgot to adjust it.


src = oshot-src;

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

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

# Initialize git AND add a tag so `git describe` works
preConfigure = ''
git init
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 = ''

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.

It seems that the flake still only considers oshot being built without plugins support. I don't use nixOS so idk, but is it possible to pass an argument to wether to build or not with plugins support? Thus install the shared libraries too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, nix has support for different branches natively, but installing shared libraries has to be manually configured. I would have to do a bit more testing to make sure it works for that.

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
'';
};

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