2024-09-30 21:05:27 +00:00
|
|
|
{
|
2024-12-03 02:15:59 +00:00
|
|
|
description = "Nixpkgs PR request status checker";
|
2024-09-30 21:05:27 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2024-12-03 02:15:59 +00:00
|
|
|
|
|
|
|
pyproject-nix = {
|
|
|
|
url = "github:pyproject-nix/pyproject.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
uv2nix = {
|
|
|
|
url = "github:pyproject-nix/uv2nix";
|
|
|
|
inputs.pyproject-nix.follows = "pyproject-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
pyproject-build-systems = {
|
|
|
|
url = "github:pyproject-nix/build-system-pkgs";
|
|
|
|
inputs.pyproject-nix.follows = "pyproject-nix";
|
|
|
|
inputs.uv2nix.follows = "uv2nix";
|
2024-09-30 21:05:27 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
2024-12-03 02:15:59 +00:00
|
|
|
uv2nix,
|
|
|
|
pyproject-nix,
|
|
|
|
pyproject-build-systems,
|
|
|
|
...
|
2024-09-30 21:05:27 +00:00
|
|
|
}:
|
2024-12-03 02:15:59 +00:00
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
|
|
|
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
|
|
|
|
|
|
|
|
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
|
|
|
|
|
|
|
|
overlay = workspace.mkPyprojectOverlay {
|
|
|
|
sourcePreference = "wheel";
|
2024-09-30 21:05:27 +00:00
|
|
|
};
|
2024-12-03 02:15:59 +00:00
|
|
|
|
|
|
|
editableOverlay = workspace.mkEditablePyprojectOverlay {
|
|
|
|
root = "$REPO_ROOT";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Python sets grouped per system
|
|
|
|
pythonSets = forAllSystems (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
inherit (pkgs) stdenv;
|
|
|
|
|
|
|
|
# Base Python package set from pyproject.nix
|
|
|
|
baseSet = pkgs.callPackage pyproject-nix.build.packages {
|
2024-09-30 21:05:27 +00:00
|
|
|
python = pkgs.python312;
|
2024-12-03 02:15:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# An overlay of build fixups & test additions
|
|
|
|
pyprojectOverrides = final: prev: {
|
|
|
|
nixprstatus = prev.nixprstatus.overrideAttrs (old: {
|
|
|
|
# Add tests to passthru.tests
|
|
|
|
#
|
|
|
|
# These attribute are used in Flake checks.
|
|
|
|
passthru = old.passthru // {
|
|
|
|
tests = (old.tests or { }) // {
|
|
|
|
# Run mypy checks
|
|
|
|
mypy =
|
|
|
|
let
|
|
|
|
venv = final.mkVirtualEnv "nixprstatus-typing-env" {
|
|
|
|
nixprstatus = [ "typing" ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "${final.nixprstatus.name}-mypy";
|
|
|
|
inherit (final.nixprstatus) src;
|
|
|
|
nativeBuildInputs = [
|
|
|
|
venv
|
|
|
|
];
|
|
|
|
dontConfigure = true;
|
|
|
|
dontInstall = true;
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
mypy --strict nixprstatus --junit-xml $out/junit.xml
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Run unittest with coverage reports installed into build output
|
|
|
|
unittest =
|
|
|
|
let
|
|
|
|
venv = final.mkVirtualEnv "nixprstatus-test-env" {
|
|
|
|
nixprstatus = [ ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "${final.nixprstatus.name}-test";
|
|
|
|
inherit (final.nixprstatus) src;
|
|
|
|
nativeBuildInputs = [
|
|
|
|
venv
|
|
|
|
];
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
mkdir -p $out
|
|
|
|
python -m unittest discover tests -v > $out/unittest.txt
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
baseSet.overrideScope (
|
|
|
|
lib.composeManyExtensions [
|
|
|
|
pyproject-build-systems.overlays.default
|
|
|
|
overlay
|
|
|
|
pyprojectOverrides
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
in
|
|
|
|
# Django static roots grouped per system
|
|
|
|
{
|
|
|
|
checks = forAllSystems (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pythonSet = pythonSets.${system};
|
|
|
|
in
|
|
|
|
# Inherit tests from passthru.tests into flake checks
|
|
|
|
pythonSet.nixprstatus.passthru.tests
|
|
|
|
);
|
|
|
|
|
|
|
|
packages = forAllSystems (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
pythonSet = pythonSets.${system};
|
|
|
|
venv = pythonSet.mkVirtualEnv "nixprstatus-env" workspace.deps.default;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
default = pkgs.stdenv.mkDerivation {
|
|
|
|
pname = "nixprstatus";
|
|
|
|
version = pythonSet.nixprstatus.version;
|
|
|
|
dontConfigure = true;
|
|
|
|
dontUnpack = true;
|
|
|
|
dontBuild = true;
|
|
|
|
buildInputs = [ venv ];
|
2024-09-30 21:05:27 +00:00
|
|
|
nativeBuildInputs = [ pkgs.installShellFiles ];
|
|
|
|
postInstall = ''
|
2024-12-03 02:15:59 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
ln -s ${venv}/bin/nixprstatus $out/bin/nixprstatus
|
2024-09-30 21:05:27 +00:00
|
|
|
installShellCompletion --cmd nixprstatus \
|
2024-12-03 02:15:59 +00:00
|
|
|
--bash <($out/bin/nixprstatus --show-completion bash) \
|
|
|
|
--zsh <($out/bin/nixprstatus --show-completion zsh) \
|
|
|
|
--fish <($out/bin/nixprstatus --show-completion fish)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2024-12-03 05:38:10 +00:00
|
|
|
overlays.default = final: prev: {
|
|
|
|
nixprstatus = self.packages.${prev.system}.default;
|
|
|
|
};
|
|
|
|
|
2024-12-03 02:15:59 +00:00
|
|
|
# Use an editable Python set for development.
|
|
|
|
devShells = forAllSystems (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
editablePythonSet = pythonSets.${system}.overrideScope editableOverlay;
|
|
|
|
venv = editablePythonSet.mkVirtualEnv "nixprstatus-dev-env" {
|
|
|
|
nixprstatus = [ "dev" ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
packages = [
|
|
|
|
venv
|
|
|
|
pkgs.uv
|
|
|
|
];
|
|
|
|
shellHook = ''
|
|
|
|
unset PYTHONPATH
|
|
|
|
export REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
export UV_NO_SYNC=1
|
2024-09-30 21:05:27 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-12-03 02:15:59 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2024-09-30 21:05:27 +00:00
|
|
|
}
|