Skip to content
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 expression [feature request] #43

Open
talbergs opened this issue Mar 3, 2023 · 2 comments
Open

Nix expression [feature request] #43

talbergs opened this issue Mar 3, 2023 · 2 comments

Comments

@talbergs
Copy link

talbergs commented Mar 3, 2023

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

@tejing1
Copy link

tejing1 commented Mar 5, 2023

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.

@NobbZ
Copy link

NobbZ commented Mar 5, 2023

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.

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

No branches or pull requests

3 participants