Skip to content

Commit

Permalink
Merge pull request #515 from zmitchell/poetry-to-nixpkgs
Browse files Browse the repository at this point in the history
Switch from poetry to nixpkgs
  • Loading branch information
fricklerhandwerk authored Oct 16, 2023
2 parents 5bc35ca + 32b0aa0 commit 8c657ff
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1,139 deletions.
26 changes: 1 addition & 25 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 41 additions & 68 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,55 @@

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.poetry2nix = {
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/poetry2nix";
};

outputs = { self, nixpkgs, flake-utils, poetry2nix }:
outputs = { self, nixpkgs, flake-utils}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ poetry2nix.overlay ];
overlays = [
# Add sphinx-sitemap from an overlay until
# it becomes available from nixpkgs-unstable
(import ./overlay.nix)
];
};
poetryOverrides = self: super: {

# Refs https://github.com/nix-community/poetry2nix/issues/218#issuecomment-981615612
typing-extensions = super.typing-extensions.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);

sphinx = super.sphinx.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);

accessible-pygments = super.accessible-pygments.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);

sphinx-sitemap = super.sphinx-sitemap.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);

sphinx-notfound-page = super.sphinx-notfound-page.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.flit-core ];
}
);
in {
packages.default = pkgs.stdenv.mkDerivation {
name = "nix-dev";
src = self;
nativeBuildInputs = with pkgs.python310.pkgs; [
linkify-it-py
myst-parser
sphinx
sphinx-book-theme
sphinx-copybutton
sphinx-design
sphinx-notfound-page
sphinx-sitemap
];
buildPhase = ''
make html
'';
installPhase = ''
mkdir -p $out
cp -R build/html/* $out/
'';
};
in
rec {
packages = flake-utils.lib.flattenTree {
nix-dev-pyenv = pkgs.poetry2nix.mkPoetryEnv {
projectDir = self;
python = pkgs.python39;
overrides = [
(self: super: {
pydata-sphinx-theme = super.pydata-sphinx-theme.override { preferWheel = true; };
sphinx-book-theme = super.sphinx-book-theme.override { preferWheel = true; };
})
pkgs.poetry2nix.defaultPoetryOverrides
poetryOverrides
];
};
nix-dev-html = pkgs.stdenv.mkDerivation {
name = "nix-dev";
src = self;
buildInputs = [ packages.nix-dev-pyenv ];
buildPhase = ''
make html
'';
installPhase = ''
mkdir -p $out
cp -R build/html/* $out/
'';
};

devShells.default = pkgs.mkShell {
buildInputs = with pkgs.python310.pkgs; [
black
livereload
linkify-it-py
myst-parser
sphinx
sphinx-book-theme
sphinx-copybutton
sphinx-design
sphinx-notfound-page
sphinx-sitemap
];
};
defaultPackage = packages.nix-dev-html;
}
);

}
50 changes: 50 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
final: prev: let
python-module-sphinx-sitemap = {
lib,
buildPythonPackage,
fetchPypi,
sphinx,
pytest,
}: let
pname = "sphinx-sitemap";
version = "2.5.1";
in
buildPythonPackage {
inherit pname version;

src = fetchPypi {
inherit pname version;
sha256 = "sha256-mEvvBou9vCbPriCai2E5LpaBq8kZG0d80w2kBuOmDuU=";
};

propagatedBuildInputs = [
sphinx
];

nativeCheckInputs = [
pytest
];

doCheck = true;
checkPhase = ''
pytest --fixtures tests
'';

meta = with lib; {
description = "Sitemap generator for Sphinx";
homepage = "https://github.com/jdillard/sphinx-sitemap";
maintainers = with maintainers; [ ];
license = licenses.mit;
};
};
in {
python310 = prev.python310.override {
packageOverrides = python-final: python-prev: {
sphinx-sitemap = python-module-sphinx-sitemap {
inherit (prev) lib;
inherit (python-prev) buildPythonPackage fetchPypi pytest;
inherit (python-prev.pkgs) sphinx;
};
};
};
}
Loading

0 comments on commit 8c657ff

Please sign in to comment.