todoist_interface/flake.nix

60 lines
1.8 KiB
Nix
Raw Normal View History

2021-12-06 18:47:27 +01:00
{
description = "A Python API for various tools I use at work.";
inputs = {
2023-04-06 11:37:03 +02:00
nixpkgs.url = github:NixOS/nixpkgs/nixos-22.11;
2021-12-06 18:47:27 +01:00
flake-utils.url = github:numtide/flake-utils;
mach-nix.url = "github:DavHau/mach-nix";
};
outputs = { self, nixpkgs, flake-utils, mach-nix }:
with flake-utils.lib; eachSystem allSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
base-requirements = builtins.readFile ./requirements/base.txt;
pyEnv = mach-nix.lib."${system}".mkPython {
requirements = base-requirements + ''
autopep8
2021-12-06 20:26:59 +01:00
flake8
2023-04-06 14:16:07 +02:00
black
2021-12-06 18:47:27 +01:00
pytest
pytest-cov
pyinstaller
'';
};
2021-12-06 20:26:59 +01:00
in
rec {
2023-04-06 11:29:47 +02:00
devShells.default = pkgs.mkShell {
2021-12-06 20:26:59 +01:00
buildInputs = [ pyEnv ];
};
2021-12-28 14:48:57 +01:00
packages =
let
binary = { autoPatchelfHook, ... }: pkgs.stdenv.mkDerivation rec {
name = "todoist_interface";
src = self;
nativeBuildInputs = [
autoPatchelfHook
];
buildInputs = [
pkgs.coreutils
pkgs.glibc
pkgs.bintools-unwrapped
pyEnv
];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
export PATH="${pkgs.lib.makeBinPath buildInputs}";
python -m pytest tests
2023-04-06 14:47:59 +02:00
pyinstaller -F todoist_interface/__main__.py -n todoist_interface --path=todoist_interface/
2021-12-28 14:48:57 +01:00
'';
installPhase = ''
mkdir -p $out
2023-04-06 11:36:50 +02:00
cp dist/todoist_interface "$out/todoist_interface"
2021-12-28 14:48:57 +01:00
'';
};
in
pkgs.callPackage binary { };
defaultPackage = packages;
2021-12-06 18:47:27 +01:00
});
}