-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix flake #81
base: master
Are you sure you want to change the base?
nix flake #81
Changes from all commits
7373904
1c28d6d
c4eff4a
539eab0
102a46d
5bc76aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
description = "Nix flake for running zotero2readwise script"; | ||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
inputs.poetry2nix.url = "github:nix-community/poetry2nix"; | ||
|
||
outputs = { self, nixpkgs, poetry2nix }: | ||
let | ||
system = "x86_64-linux"; | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication defaultPoetryOverrides; | ||
Comment on lines
+6
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance cross-platform compatibility. The current implementation hardcodes the system to "x86_64-linux". To improve cross-platform compatibility, consider using a more flexible approach. Replace the hardcoded system with a dynamic approach: outputs = { self, nixpkgs, poetry2nix }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/run";
};
});
packages = forAllSystems (system: {
default = let
inherit (poetry2nix.lib.mkPoetry2Nix { inherit (pkgs.${system}) pkgs; }) mkPoetryApplication defaultPoetryOverrides;
in
mkPoetryApplication {
# ... rest of your mkPoetryApplication configuration
};
});
}; This change will allow the flake to work on multiple architectures and operating systems. |
||
zotero2readwise = mkPoetryApplication { | ||
projectDir = ./.; | ||
# Pyzotero requires setuptools. | ||
# https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md | ||
overrides = defaultPoetryOverrides.extend (final: prev: { | ||
pyzotero = prev.pyzotero.overridePythonAttrs ( old: { | ||
buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ]; | ||
}); | ||
}); | ||
}; | ||
in | ||
{ | ||
apps.${system}.default = { | ||
type = "app"; | ||
# replace <script> with the name in the [tool.poetry.scripts] section of your pyproject.toml | ||
program = "${zotero2readwise}/bin/run"; | ||
}; | ||
}; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
__author__ = "Essi Alizadeh" | ||
__version__ = "0.4.5" | ||
|
||
TOP_DIR = Path(__file__).parent | ||
FAILED_ITEMS_DIR = TOP_DIR | ||
# If TOP_DIR is readonly os with nix, | ||
# then failed_zotero_items.json is written to the working directory instead. | ||
FAILED_ITEMS_DIR = TOP_DIR if os.access(TOP_DIR, os.W_OK) else Path.cwd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve new "Approach 3" section with minor correction.
The new section effectively introduces the Nix flake approach, aligning with the PR objectives. The command format is clear, and the note about the output file location is valuable for users.
However, there's a minor grammatical error that should be corrected:
In line 84, "you working directory" should be "your working directory".
Please apply this change:
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool