{"id":14968051,"url":"https://github.com/t184256/nixpkgs-python-importer","last_synced_at":"2025-10-26T00:30:54.081Z","repository":{"id":57446277,"uuid":"149743445","full_name":"t184256/nixpkgs-python-importer","owner":"t184256","description":"Violate Nix philosophy, install Python packages mid-session with `from nixpkgs.scipy import scipy`.","archived":false,"fork":false,"pushed_at":"2019-08-22T20:46:44.000Z","size":19,"stargazers_count":31,"open_issues_count":4,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-31T12:51:21.738Z","etag":null,"topics":["importlib","nix","nixos","nixpkgs","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t184256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-21T09:43:14.000Z","updated_at":"2024-09-04T10:52:30.000Z","dependencies_parsed_at":"2022-09-02T22:11:53.495Z","dependency_job_id":null,"html_url":"https://github.com/t184256/nixpkgs-python-importer","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t184256%2Fnixpkgs-python-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t184256%2Fnixpkgs-python-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t184256%2Fnixpkgs-python-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t184256%2Fnixpkgs-python-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t184256","download_url":"https://codeload.github.com/t184256/nixpkgs-python-importer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238229940,"owners_count":19437723,"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":["importlib","nix","nixos","nixpkgs","python"],"created_at":"2024-09-24T13:39:10.172Z","updated_at":"2025-10-26T00:30:53.747Z","avatar_url":"https://github.com/t184256.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nixpkgs-python-importer\n\n## What\n\nAn importlib hack that allows `from nixpkgs.pythonpackagename import modulename`.\n\nExamples:\n\n    from nixpkgs.scipy import scipy\n    import nixpkgs.scipy.scipy\n    from nixpkgs.matplotlib.matplotlib import pyplot as plt\n    import nixpkgs.matplotlib.matplotlib.pyplot as plt\n    from nixpkgs.pillow.PIL import Image\n\n\n## Why\n\nI used to be a researcher who used `python` and `xonsh` interactively a lot.\nWhile I appreciate the purity of Nix, sometimes I really want to violate it\nand pull in some dependency into my shell *right now*,\nwithout tearing my session down, editing and rebuilding an environment,\nand then recreating my session from history.\n\nA convenient way of spawning a `xonsh` instance with an extra dependency\nsoothes the nerves a bit, but doesn't really free me from the recreation part.\n\nI started writing a `xonsh` macro that ended up being a generic Python solution\nwith a pleasingly nice syntax. I mean, `from nixpkgs.scipy import scipy`.\nAin't that nice?\n\n\n## How\n\n`importlib` magic\n\n\n## Try\n\nThe quickest way to try it would be (on a recent NixOS):\n\n```\nnix run '(import \u003cnixpkgs\u003e {}).python3.withPackages(ps:[ps.nixpkgs])' -c python\n```\nthen try `from nixpkgs.pbr import pbr` (or any other package).\n\n\nIf that doesn't work, you may also try your luck with unstable nixpkgs:\n\n```\nnix run -f channel:nixos-unstable '(import \u003cnixpkgs\u003e {}).python3.withPackages(ps:[ps.nixpkgs])' -c python\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft184256%2Fnixpkgs-python-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft184256%2Fnixpkgs-python-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft184256%2Fnixpkgs-python-importer/lists"}