Skip to content

Add Nix flakes#7

Merged
Toni500github merged 13 commits into
Toni500github:mainfrom
BurntRanch:flake
Jun 12, 2026
Merged

Add Nix flakes#7
Toni500github merged 13 commits into
Toni500github:mainfrom
BurntRanch:flake

Conversation

@BurntRanch

@BurntRanch BurntRanch commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This PR:

  1. adds flake.nix and flake.lock (tested and installed on NixOS 26.05 Yarara)
  2. includes oshot.desktop in the CMake install
  3. makes the config use TESSDATA_PREFIX by default when trying to resolve ocr_path.
  4. removes the ocr-path definition in the default config, so that environment variable changes can take place normally.
  5. includes instructions in README.md for NixOS troubleshooting

Issues:

  1. flake.nix doesn't use CMake to install. This doesn't affect the reliability of the flake, but it's a big consideration. The reason CMake isn't used is because it breaks the binary.

@BurntRanch

BurntRanch commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

apparently the default config string is required to save the config
that's a major issue in NixOS since store paths can change for any reason

@Toni500github

Toni500github commented Jun 12, 2026

Copy link
Copy Markdown
Owner

apparently the default config string is required to save the config
that's a major issue in NixOS since store paths can change for any reason

I think to use the order config->env variable->args (default.ocr-path->$TESSDATA_PREFIX->-o default.ocr-path

So if anything is set after config, we'll use that instead

@BurntRanch

BurntRanch commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

I think to use the order config->env variable->args (default.ocr-path->$TESSDATA_PREFIX->-o default.ocr-path

So you're suggesting to separate the default section from the rest of the config?

The issue is that the config gets overwritten with the old store path everytime it changes

@Toni500github

Copy link
Copy Markdown
Owner

I meant to get default.ocr-path from getValue() as already done

File.ocr_path = GetValue<std::string>("default.ocr-path", File.ocr_path);

then at the end let's get $TESSDATA_PREFIX if possible

const char* env = getenv("TESSDATA_PREFIX");
if (env && env[0] != '\0')
   File.ocr_path = env;

and then it will be overwritten by parseargs() with -o default.ocr-path="new-path"

@BurntRanch

Copy link
Copy Markdown
Contributor Author

I think it'd be a good idea if you could unset variables through the UI, and also have the config empty by default
Then each line would get added depending on if it's set or not, and the unset variables would have default values

@Toni500github

Copy link
Copy Markdown
Owner

unnecessary work for just one config variable

@BurntRanch

BurntRanch commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

another gross idea could be to simply disable the option in the UI on NixOS
it would still be settable in the file, but if it isn't, it won't be saved and won't be configurable through the UI

@Toni500github

Copy link
Copy Markdown
Owner

I meant to get default.ocr-path from getValue() as already done

File.ocr_path = GetValue<std::string>("default.ocr-path", File.ocr_path);

then at the end let's get $TESSDATA_PREFIX if possible

const char* env = getenv("TESSDATA_PREFIX");
if (env && env[0] != '\0')
   File.ocr_path = env;

and then it will be overwritten by parseargs() with -o default.ocr-path="new-path"

why not just use this? This can be used on *Nix and Windows

@Toni500github

Copy link
Copy Markdown
Owner

can also avoid removing the convinient freedom to set the ocr-path to something like ~/.config/oshot/models to also be used as a path to download OCR models with the Download OCR tool

@BurntRanch

Copy link
Copy Markdown
Contributor Author

so make the env var replace the option?

@Toni500github

Toni500github commented Jun 12, 2026

Copy link
Copy Markdown
Owner

so make the env var replace the option?

From config file yes

$TESSDATA_PREFIX now supersedes ocr-path
@BurntRanch

Copy link
Copy Markdown
Contributor Author

@Toni500github check this?

@Toni500github

Copy link
Copy Markdown
Owner

change back to /usr/share/tessdata and resolve the review

@Toni500github

Copy link
Copy Markdown
Owner

I'd suggest to remove the linux-only guard since can be used for macOS and windows and other unix systems that oshot perhabs supports accidentally

@BurntRanch

BurntRanch commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

this should be all good

@Toni500github

Copy link
Copy Markdown
Owner
image

@Toni500github Toni500github merged commit 276642e into Toni500github:main Jun 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants