Last active
May 24, 2025 21:29
-
-
Save jw910731/1cb66aac30c344156e21281e36e7a3be to your computer and use it in GitHub Desktop.
Hellish python2 nix flake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| inputs = { | |
| nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling"; | |
| systems.url = "github:nix-systems/default"; | |
| devenv.url = "github:cachix/devenv"; | |
| devenv.inputs.nixpkgs.follows = "nixpkgs"; | |
| }; | |
| nixConfig = { | |
| extra-trusted-public-keys = | |
| "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; | |
| extra-substituters = "https://devenv.cachix.org"; | |
| }; | |
| outputs = { self, nixpkgs, devenv, systems, ... }@inputs: | |
| let forEachSystem = nixpkgs.lib.genAttrs (import systems); | |
| in { | |
| packages = forEachSystem (system: { | |
| devenv-up = self.devShells.${system}.default.config.procfileScript; | |
| devenv-test = self.devShells.${system}.default.config.test; | |
| }); | |
| devShells = forEachSystem (system: | |
| let | |
| pkgs = import nixpkgs { | |
| system = | |
| if system == "aarch64-darwin" then "x86_64-darwin" else system; | |
| config = { | |
| permittedInsecurePackages = | |
| [ "python-2.7.18.8" "python-2.7.18.8-env" ]; | |
| }; | |
| }; | |
| in { | |
| default = devenv.lib.mkShell { | |
| inherit inputs pkgs; | |
| modules = [{ | |
| # https://devenv.sh/reference/options/ | |
| packages = | |
| [ pkgs.python27Packages.pip pkgs.python27Packages.setuptools ]; | |
| languages.python = { | |
| enable = true; | |
| package = pkgs.python27; | |
| }; | |
| scripts."venv-setup".exec = '' | |
| ${pkgs.python27}/bin/python -m pip install --target "$DEVENV_STATE/python2.7/site-packages/" virtualenv | |
| export PYTHONPATH="$DEVENV_STATE/python2.7/site-packages/''${PYTHONPATH:+:$PYTHONPATH}" | |
| ${pkgs.python27}/bin/python -m virtualenv .venv | |
| ''; | |
| enterShell = '' | |
| export PYTHONPATH="$DEVENV_STATE/python2.7/site-packages/''${PYTHONPATH:+:$PYTHONPATH}" | |
| ''; | |
| }]; | |
| }; | |
| }); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment