{ description = "republisher-redux - offline RSS and Atom feed mirroring"; inputs = { nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; 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"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, treefmt-nix, pyproject-nix, uv2nix, pyproject-build-systems, ... }: let systems = [ "x86_64-linux" ]; forAllSystems = fn: nixpkgs.lib.genAttrs systems ( system: fn ( import nixpkgs { inherit system; config.allowUnfree = true; } ) ); mkFfmpegPackage = pkgs: pkgs.ffmpeg-full.override { withUnfree = true; withFdkAac = true; }; mkTreefmtConfig = pkgs: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config; workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; }; overlay = workspace.mkPyprojectOverlay { sourcePreference = "wheel"; }; pyprojectOverrides = final: prev: { sgmllib3k = prev.sgmllib3k.overrideAttrs (old: { nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ final.setuptools ]; }); }; mkPackage = pkgs: let ffmpegPackage = mkFfmpegPackage pkgs; pythonSet = (pkgs.callPackage pyproject-nix.build.packages { python = pkgs.python313; }).overrideScope ( pkgs.lib.composeManyExtensions [ pyproject-build-systems.overlays.default overlay pyprojectOverrides ] ); baseVenv = pythonSet.mkVirtualEnv "republisher-redux-env" workspace.deps.default; testVenv = pythonSet.mkVirtualEnv "republisher-redux-test-env" { "republisher-redux" = [ "dev" ]; }; tests = pkgs.stdenv.mkDerivation { name = "republisher-redux-tests"; src = ./.; dontConfigure = true; dontBuild = true; nativeBuildInputs = [ testVenv ]; checkPhase = '' runHook preCheck export HOME="$(mktemp -d)" pytest tests/ -v runHook postCheck ''; doCheck = true; installPhase = '' mkdir -p "$out" touch "$out/passed" ''; }; runtimePackage = pkgs.symlinkJoin { name = "republisher-redux"; paths = [ baseVenv ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' rm -f "$out/bin/repub" makeWrapper "${baseVenv}/bin/repub" "$out/bin/repub" \ --prefix PATH : "${pkgs.lib.makeBinPath [ ffmpegPackage ]}" ''; meta.mainProgram = "repub"; }; in pkgs.runCommand "republisher-redux" { inherit (runtimePackage) meta; passthru = { inherit tests testVenv runtimePackage; }; } '' test -f "${tests}/passed" ln -s "${runtimePackage}" "$out" ''; in { formatter = forAllSystems (pkgs: (mkTreefmtConfig pkgs).build.wrapper); packages = forAllSystems ( pkgs: let pkg = mkPackage pkgs; in { "republisher-redux" = pkg; default = pkg; } ); apps = forAllSystems ( pkgs: let package = self.packages.${pkgs.stdenv.hostPlatform.system}.default; in { repub = { type = "app"; program = "${package}/bin/repub"; meta.description = "republisher-redux runtime"; }; default = { type = "app"; program = "${package}/bin/repub"; meta.description = "republisher-redux runtime"; }; } ); checks = forAllSystems ( pkgs: let system = pkgs.stdenv.hostPlatform.system; exportedPackage = self.packages.${system}.default; testVenv = exportedPackage.testVenv; treefmtConfig = mkTreefmtConfig pkgs; src = ./.; blackCheck = pkgs.stdenv.mkDerivation { name = "republisher-redux-black"; inherit src; dontConfigure = true; dontBuild = true; nativeBuildInputs = [ testVenv ]; checkPhase = '' runHook preCheck black --check repub/ tests/ runHook postCheck ''; doCheck = true; installPhase = '' mkdir -p "$out" touch "$out/passed" ''; }; flake8Check = pkgs.stdenv.mkDerivation { name = "republisher-redux-flake8"; inherit src; dontConfigure = true; dontBuild = true; nativeBuildInputs = [ testVenv ]; checkPhase = '' runHook preCheck flake8 repub/ tests/ runHook postCheck ''; doCheck = true; installPhase = '' mkdir -p "$out" touch "$out/passed" ''; }; isortCheck = pkgs.stdenv.mkDerivation { name = "republisher-redux-isort"; inherit src; dontConfigure = true; dontBuild = true; nativeBuildInputs = [ testVenv ]; checkPhase = '' runHook preCheck isort --check-only repub/ tests/ runHook postCheck ''; doCheck = true; installPhase = '' mkdir -p "$out" touch "$out/passed" ''; }; in { devshell-default = self.devShells.${system}.default; formatter = treefmtConfig.build.wrapper; package-default = exportedPackage; tests = exportedPackage.tests; treefmt = treefmtConfig.build.check ./.; black = blackCheck; flake8 = flake8Check; isort = isortCheck; } ); devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = [ pkgs.python313 pkgs.uv (mkFfmpegPackage pkgs) ]; env.LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc ]; env.UV_PROJECT_ENVIRONMENT = ".venv"; env.UV_PYTHON_DOWNLOADS = "never"; }; }); }; }