please
please copied to clipboard
Nix expression [feature request]
There usually is a ./contrib
folder that contains some integration-like files.
Some nix expert may come along and help in with the idiomic way. But there is what worked for my flake.nix
{ config, pkgs, ... }:
let
py3-with-deps-for-please = pkgs.python3.withPackages (ps: [ ps.typer ps.rich ]);
py3-code-for-please = pkgs.fetchFromGitHub {
rev = "390ecaeda5cad70b56f2b4ef64725c1d1a10a842";
owner = "NayamAmarshe";
repo = "please";
hash = "sha256-U0wT6uZ9IV4lemMD9UVTSMvGeQ9h5l1TQ9gUiH/tlJc=";
};
please-cli = pkgs.writeShellScriptBin "please" ''
${pkgs.lib.getExe py3-with-deps-for-please} ${py3-code-for-please}/please/please.py $@
'';
in
{
config.users.users.mt.shell = pkgs.fish;
config.environment.systemPackages = [
please-cli
];
}
I hope for someone to publish a correct package not only to AUR but also to nixpkgs
Here's a much more idiomatic expression:
{ pkgs ? import <nixpkgs> {}
, poetry2nix ? pkgs.poetry2nix
, fetchFromGitHub ? pkgs.fetchFromGitHub
}:
poetry2nix.mkPoetryApplication {
projectDir = fetchFromGitHub {
owner = "NayamAmarshe";
repo = "please";
rev = "0.3.1";
hash = "sha256-sQErUOGx+PXX6laqiRsJ5z3HEeEbWhlXkTIjipz1NcU=";
};
postPatch = "rm -r dist";
}
Note, however, that this uses IFD as stated (IFD isn't allowed in nixpkgs, among other issues). To avoid that, you'd need to keep a copy of the poetry.lock
and pyproject.toml
with the nix code and set
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
However if this lived in this repo, for example in contrib
, then you could instead just set projectDir = ../.;
instead of any of that.
For a "contrib" folder here, using poetry2nix
is probably fine, though for any packaging attempt in nixpkgs
I'd recommend the usage of buildPythonModule
+ format = "pyproject"
and toPythonApplication
at the top-level to increase sharability within the closure.