summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 58429977d312a1c5619712d5aee60395d25fcd83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
  description = "teawie moment";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    pre-commit-hooks = {
      url = "github:cachix/pre-commit-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.nixpkgs-stable.follows = "nixpkgs";
      inputs.flake-compat.follows = "flake-compat";
      inputs.flake-utils.follows = "flake-utils";
    };
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = {
    self,
    nixpkgs,
    pre-commit-hooks,
    flake-utils,
    ...
  }: let
    version = "0.0.1";
    supportedSystems = with flake-utils.lib.system; [x86_64-linux x86_64-darwin aarch64-linux aarch64-darwin];
  in
    flake-utils.lib.eachSystem supportedSystems (system: let
      pkgs = import nixpkgs {inherit system;};
    in {
      packages =
        {
          teawiebot = with pkgs;
            python39Packages.buildPythonPackage {
              pname = "teawiebot";
              inherit version;
              src = ./.;
              format = "flit";
              propagatedBuildInputs = with pkgs.python39Packages; [hatchling discordpy requests];
            };
          container = with pkgs.dockerTools;
            buildImage {
              name = "teawiebot";
              tag = "latest";
              copyToRoot = [caCertificates];
              config.Cmd = ["${self.packages.${system}.teawiebot}/bin/teawiebot"];
            };
        }
        // {default = self.packages.${system}.teawiebot;};

      checks = {
        pre-commit-check = pre-commit-hooks.lib.${system}.run {
          src = ./.;
          hooks = {
            isort.enable = true;
            pylint.enable = true;
            yapf = {
              enable = true;
              name = "yapf";
              entry = "${pkgs.python39Packages.yapf}/bin/yapf -i";
              types = ["file" "python"];
            };
          };
        };
      };

      devShells = with pkgs; {
        default = mkShell {
          packages = with pkgs.python39Packages; [python39 discordpy flit pylint requests toml yapf];
          inherit (self.checks.${system}.pre-commit-check) shellHook;
        };
      };
    });
}