nixify
This commit is contained in:
parent
81bb8afc41
commit
98dcea4d7e
10 changed files with 811 additions and 478 deletions
138
flake.nix
Normal file
138
flake.nix
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
{
|
||||
description = "pygea - Pangea RSS feed generator";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
treefmt-nix,
|
||||
...
|
||||
}:
|
||||
let
|
||||
systems = [ "x86_64-linux" ];
|
||||
forAllSystems =
|
||||
fn:
|
||||
nixpkgs.lib.genAttrs systems (
|
||||
system:
|
||||
fn (
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
mkTreefmtConfig = pkgs: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config;
|
||||
in
|
||||
{
|
||||
formatter = forAllSystems (pkgs: (mkTreefmtConfig pkgs).build.wrapper);
|
||||
|
||||
packages = forAllSystems (
|
||||
pkgs:
|
||||
let
|
||||
pkg = pkgs.callPackage ./nix/packages/pygea/package.nix { };
|
||||
in
|
||||
{
|
||||
pygea = pkg;
|
||||
default = pkg;
|
||||
}
|
||||
);
|
||||
|
||||
apps = forAllSystems (
|
||||
pkgs:
|
||||
let
|
||||
package = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
in
|
||||
{
|
||||
pygea = {
|
||||
type = "app";
|
||||
program = "${package}/bin/pygea";
|
||||
meta.description = "pygea runtime";
|
||||
};
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${package}/bin/pygea";
|
||||
meta.description = "pygea runtime";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
checks = forAllSystems (
|
||||
pkgs:
|
||||
let
|
||||
inherit (pkgs.stdenv.hostPlatform) system;
|
||||
exportedPackage = self.packages.${system}.default;
|
||||
treefmtConfig = mkTreefmtConfig pkgs;
|
||||
smokePython = pkgs.python313.withPackages (ps: [
|
||||
ps.requests
|
||||
ps.beautifulsoup4
|
||||
ps.feedgen
|
||||
ps."python-dateutil"
|
||||
]);
|
||||
|
||||
smokeCheck = pkgs.runCommand "pygea-smoke" { nativeBuildInputs = [ smokePython ]; } ''
|
||||
export PYTHONPATH="${exportedPackage}/${pkgs.python313.sitePackages}:$PYTHONPATH"
|
||||
python - <<'PY'
|
||||
from pathlib import Path
|
||||
|
||||
for source_file in Path("${./.}/pygea").glob("*.py"):
|
||||
compile(source_file.read_text(encoding="utf-8"), str(source_file), "exec")
|
||||
PY
|
||||
python -c "import pygea; import pygea.utilities; import pygea.pexception"
|
||||
mkdir -p "$out"
|
||||
touch "$out/passed"
|
||||
'';
|
||||
|
||||
deadnixCheck = pkgs.runCommand "pygea-deadnix" { nativeBuildInputs = [ pkgs.deadnix ]; } ''
|
||||
cd ${./.}
|
||||
deadnix --fail .
|
||||
mkdir -p "$out"
|
||||
touch "$out/passed"
|
||||
'';
|
||||
|
||||
statixCheck = pkgs.runCommand "pygea-statix" { nativeBuildInputs = [ pkgs.statix ]; } ''
|
||||
cd ${./.}
|
||||
statix check
|
||||
mkdir -p "$out"
|
||||
touch "$out/passed"
|
||||
'';
|
||||
in
|
||||
{
|
||||
devshell-default = self.devShells.${system}.default;
|
||||
formatter = treefmtConfig.build.wrapper;
|
||||
package-default = exportedPackage;
|
||||
treefmt = treefmtConfig.build.check ./.;
|
||||
smoke = smokeCheck;
|
||||
deadnix = deadnixCheck;
|
||||
statix = statixCheck;
|
||||
}
|
||||
);
|
||||
|
||||
devShells = forAllSystems (
|
||||
pkgs:
|
||||
let
|
||||
treefmtConfig = mkTreefmtConfig pkgs;
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.python313
|
||||
pkgs.uv
|
||||
self.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||
treefmtConfig.build.wrapper
|
||||
pkgs.deadnix
|
||||
pkgs.statix
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue