I’m trying to install organize in my nix configuration. It doesn’t have a nix install option and isn’t on nixpkgs, so I’m trying to write a custom flake to install it. Unfortunately, the project uses poetry, not a standard setup.py, so I need to use poetry2nix, and that’s where I’m struggling.
There’s no documentation for using poetry2nix to turn a github repository into a flake, it seems to assume the poetry.toml etc files are local to the flake. This is the best I’ve got, and it’s a bit messy:
{
description = "Nix flake for the organize Python program";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # or a stable version
# Poetry required to build this flake
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, poetry2nix }: {
packages.x86_64-linux.organize = with nixpkgs;
# The little incantation to use poetry2nix
let
system = "x86_64-linux";
pkgs = legacyPackages.${system};
poetry2nixLib = poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
in poetry2nixLib.mkPoetryApplication rec {
pname = "organize";
version = "3.2.5";
# Attempt to fetchFromGitHub as the source dir
projectDir = fetchFromGitHub {
owner = "tfeldmann";
repo = "organize";
rev = "v${version}";
sha256 = "sha256-C68S1AFfiOAMuvEU2sBHIgdQkPX6ydied4Kq4ChmLP8=";
};
meta = with lib; {
description = "Organize your files";
homepage = "https://github.com/tfeldmann/organize";
license = licenses.mit;
maintainers = with maintainers; [ tfeldmann ];
};
};
# The nixos module that installs the flake on a system
nixosModules.organizeModule = { config, pkgs, ... }: {
environment.systemPackages = [ self.packages.x86_64-linux.organize ];
};
};
}
And that fails with the error
error: undefined variable 'fetchFromGitHub'
Which is strange, because there was no problem with that part before I added all the poetry2nix stuff; it was fetching fine, it just couldn’t build because it’s a poetry project, not a setup.py project. I’m quite lost at this point, and I feel like I’m missing some crucial step etc.