Skip to content

Instantly share code, notes, and snippets.

@mtrsk
Last active September 3, 2019 13:57
Show Gist options
  • Save mtrsk/c439e4aad01e704995ab23d6bfa8d83e to your computer and use it in GitHub Desktop.
Save mtrsk/c439e4aad01e704995ab23d6bfa8d83e to your computer and use it in GitHub Desktop.
Using Nix overlays for local Python Packages. Mostly stolen ideas from https://gist.github.com/Denommus/0a72f25ce858d6a68a0f53bd825c418d
self: super:
let
py-override = {
packageOverrides = python-self: python-super: {
altgraph = python-super.buildPythonPackage rec {
pname = "altgraph";
version = "0.16.1";
doCheck = false;
src = python-super.fetchPypi {
inherit pname version;
sha256 = "ddf5320017147ba7b810198e0b6619bd7b5563aa034da388cea8546b877f9b0c";
};
};
pyinstaller = python-super.buildPythonPackage rec {
pname = "PyInstaller";
version = "3.5";
doCheck = false;
propagatedBuildInputs = with python-self; [
altgraph
];
src = python-super.fetchPypi {
inherit pname version;
sha256 = "ee7504022d1332a3324250faf2135ea56ac71fdb6309cff8cd235de26b1d0a96";
};
};
fbs = python-super.buildPythonPackage rec {
pname = "fbs";
version = "0.8.3";
doCheck = false;
propagatedBuildInputs = with python-self; [ pyinstaller ];
src = super.fetchFromGitHub {
owner = "mherrmann";
repo = "fbs";
rev = "f1d84da8d017358db08edfd21c03d2990e39b37e";
sha256 = "1n4fpzl1n6f341rkjrajxrm52azikly7z2a06w6yrzvlcm9jvsm0";
};
};
};
};
in
{
python2 = super.python2.override py-override;
python3 = super.python3.override py-override;
python37 = super.python37.override py-override;
}
@mtrsk
Copy link
Author

mtrsk commented Sep 3, 2019

Then you can use it in your local project with a pinned version of nixpkgs:

$ nix-prefetch-git --rev 7d5375ebf4cd417465327d7ab453687fd19663c9 https://github.com/NixOS/nixpkgs-channels.git > .nixpkgs-version.json
# pinned-nixpkgs.nix
{ bootstrap ? import <nixpkgs> {}
, json ? ./.nixpkgs-version.json
}:

let
  nixpkgs = builtins.fromJSON (builtins.readFile json);
  src = bootstrap.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs-channels";
    inherit (nixpkgs) rev sha256;
  };
in
  import src {
    overlays = [
      (import ./overlays.nix)
    ];
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment