Skip to content

Generate nix formulas for Python deps from a pip-compile'd requirements.txt file.

License

Notifications You must be signed in to change notification settings

crockeo/pipfreeze2nix

Repository files navigation

pipfreeze2nix

A tool to generate requirements.nix files from pip-compile'd requirements files.

Installation

nix profile install git+https://github.com/crockeo/pipfreeze2nix

Usage

pipfreeze2nix <path/to/requirements.txt>

Then pipfreeze2nix will generate a requirements.nix file in that same directory. You can use requirements.nix as a propagatedBulidInputs inside of a buildPythonApplication or buildPythonPackage call. For example, this project's flake.nix pulls in the requirements.nix like so:

{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = {self, flake-utils, nixpkgs}:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        python = pkgs.python310;
      in
      rec {
        defaultPackage = python.pkgs.buildPythonApplication {
          pname = "pipfreeze2nix";
          version = "0.1.0";

          src = ./src;

          propagatedBuildInputs = pkgs.callPackage ./requirements.nix {
            inherit python;
            nixpkgs = pkgs;
          };
        };
      }
    );
}

About

Generate nix formulas for Python deps from a pip-compile'd requirements.txt file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published