{"id":16950052,"url":"https://github.com/tailhook/reqtxt2nix","last_synced_at":"2025-04-11T20:40:44.669Z","repository":{"id":18557409,"uuid":"21759198","full_name":"tailhook/reqtxt2nix","owner":"tailhook","description":"Generator of nix expressions from pythonic requirements.txt","archived":false,"fork":false,"pushed_at":"2015-02-03T15:21:37.000Z","size":146,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T16:45:35.933Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tailhook.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-12T04:07:17.000Z","updated_at":"2024-03-30T16:59:37.000Z","dependencies_parsed_at":"2022-09-24T12:00:58.185Z","dependency_job_id":null,"html_url":"https://github.com/tailhook/reqtxt2nix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailhook%2Freqtxt2nix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailhook%2Freqtxt2nix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailhook%2Freqtxt2nix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailhook%2Freqtxt2nix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tailhook","download_url":"https://codeload.github.com/tailhook/reqtxt2nix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248478678,"owners_count":21110747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T21:56:42.512Z","updated_at":"2025-04-11T20:40:44.648Z","avatar_url":"https://github.com/tailhook.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========\nreqtxt2nix\n==========\n\nreqtxt2nix is a small utility which converts ``requirements.txt`` file into\n``.nix`` file that contains myEnvFun_  declaration. I.e. it helps to build\npythonic dev environments in nix.\n\nMain features:\n\n* Generates nice short and clean dev environment expression\n* Makes specific versions of python libraries from requirements.txt\n* Writes url/hash code boiler plate\n* Doesn't execute untrusted code (I mean setup.py)\n* Very short and simple script\n\nRunning::\n\n    reqtxt2nix -r requirements.txt -o ~/.nixpkgs/myproject.nix\n\nThis generates the ``~/.nixpkgs/myproject.nix`` and prints instructions on\nhow to activate it. Which boils down to::\n\nAdd the following to the ``~/.nixpkgs/config.nix``::\n\n    packageOverrides = pkgs: rec {\n        myproject = import ./myproject.nix {\n            inherit pkgs;\n            python = pkgs.python34;  # Or whatever version you prefer\n            pythonPackages = pkgs.python34Packages;\n        };\n    }\n\nThe default python printed is one, which runs ``reqtxt2nix``, usually you\nwant to change that. Remember to change the ``python34Packages`` too.\n\nThen install environment with::\n\n    nix-env -i env-myproject\n\nNow, to activate the environment run::\n\n    load-env-myproject\n\nIt works very similarly to how virtualenv works.\n\n\nAdditional Options\n==================\n\n``reqtxt2nix`` supports the folowing options which have same meaning as\nin pip:\n\n* --index-url\n* --find-links\n* --requirement\n\nAll supported both on a command-line and in ``requirements.txt`` itself.\n\nSpecifying packages on a command-line also work (however discouraged)::\n\n    ./reqtxt2nix markupsafe==0.23 \"jinja2\u003e=2.5\" -o ~/.nixpkgs/jinja.nix\n\nAlways using ``-o`` or ``--output`` is recommended, as well as writing file\ninto ``~/.nixpkgs/something.nix``.\n\n\nDependency Tracking\n===================\n\nThe ``reqtxt2nix`` does *absolutely nothing* to track dependencies. The reasons\nare following:\n\n* You are probably use ``pip freeze`` to generate ``requirements.txt`` so all\n  dependencies are already in the list\n* You don't want to get python packages from nixpkgs anyway because you have\n  frozen specific versions of each dependency\n\nWe don't add C dependencies too, because they are not declared in python.\n\nThe main idea is that it's easy to add ``buildInputs`` yourself\n(the ``reqtxt2nix`` only removes burden of adding urls and hashsums from you).\n\nWhen its stated that utility doesn't track dependencies, it doesn't mean\nutility cancels nix's own tracking. I.e. you will fail to build packages if\nthere are requirements, so you'll see error and will be able to fix pretty\nquickly.\n\n\nCustomization\n=============\n\nThere are three types of customizations.\n\n*First* one is change python version. It's outlined above.\n\n*Second* one is customizing the environment. The simplest way to do it is\noverload a function::\n\n    let myEnvFun = args: pkgs.myEnvFun args // {\n        shell = '${pkgs.zsh}/bin/zsh';\n    }\n\n    in {\n        packageOverrides = pkgs: rec {\n            myproject = import ./myproject.nix {\n                inherit pkgs;\n                inherit myEnvFun;        # pass our custimized version\n                python = pkgs.python34;\n                pythonPackages = pkgs.python34Packages;\n            };\n        }\n    }\n\nYou can also customize other aspects of ``myEnvFun``.\n\nThe *third* one is altering packages. You usually want to change two things:\n\n* ``buildInputs = [ some package names ];`` -- to set dependencies\n* ``doCheck = false;`` -- in case tests need more dependencies that you want\n\nNote that ``buildInputs`` should contain raw variable references (no ``.``\ndot) when referring to packages in same environment (actually sibling ``let``\nbindings). For system packages ``pkgs.package_name`` notation should be used.\nAnd for system *python* packages ``pythonPackages.package_name`` (regardless of\nreal python version, it's overriden on import).\n\nOther useful modifications:\n\n* Some python packages are not \"pure\", i.e. them download files when building.\n  This must be fixed by hand\n* Adding (specific versions of) C librarie\n* Use package from nixpkgs but override only version (and url/hash)\n\nSee nixos documentation on how to do all these things.\n\n\nUpdating Environment\n====================\n\nSince dependencies are sorted in same order as in original ``requirements.txt``\nyou can generate new config into ``~/.nixpkgs/myproject.nix.new`` and use your\nfavorite merge tool. Just be sure you don't overwrite previous file as it's\nlikely to contain some customizations.\n\n\nRelated Projects\n================\n\n* python2nix_ -- tries to be more smart on metadata, but creates expressions\n  one by one (while we concentrate on making build environments)\n* pypi2nix_ -- has it's own specification format and also tries to be smarter\n  (so more complex to use) than needed for me.\n\n.. _myEnvFun: https://nixos.org/wiki/Howto_develop_software_on_nixos\n.. _pypi2nix: https://github.com/garbas/pypi2nix\n.. _python2nix: https://github.com/proger/python2nix\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailhook%2Freqtxt2nix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftailhook%2Freqtxt2nix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailhook%2Freqtxt2nix/lists"}