From 3e790dbb8747ce9b7f03e30eea793bdfc374edbc Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 21 Nov 2022 15:54:11 +0100 Subject: [PATCH] nix: add flake --- flake.lock | 66 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..55f7277 --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes" : { + "flake-utils" : { + "locked" : { + "lastModified" : 1667395993, + "narHash" : + "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner" : "numtide", + "repo" : "flake-utils", + "rev" : "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type" : "github" + }, + "original" : { + "owner" : "numtide", + "ref" : "master", + "repo" : "flake-utils", + "type" : "github" + } + }, + "nixpkgs" : { + "locked" : { + "lastModified" : 1669029319, + "narHash" : + "sha256-EdTqXZ/xBk7xjSCPGNbL0WnoWHEkYjwe78C6gZoUC0E=", + "owner" : "NixOS", + "repo" : "nixpkgs", + "rev" : "79bb815a1cdc789f6b036d2047e217ab3e989fff", + "type" : "github" + }, + "original" : { + "owner" : "NixOS", + "ref" : "nixpkgs-unstable", + "repo" : "nixpkgs", + "type" : "github" + } + }, + "pre-commit-hooks" : { + "inputs" : + {"flake-utils" : ["flake-utils"], "nixpkgs" : ["nixpkgs"]}, + "locked" : { + "lastModified" : 1669018323, + "narHash" : + "sha256-/2Ixw4v5JbbhH+sE6huvyG+txhBGIcx5iWIZ4kWtilU=", + "owner" : "cachix", + "repo" : "pre-commit-hooks.nix", + "rev" : "46fb5634676994bd333a94c8bd322eb1854ff223", + "type" : "github" + }, + "original" : { + "owner" : "cachix", + "ref" : "master", + "repo" : "pre-commit-hooks.nix", + "type" : "github" + } + }, + "root" : { + "inputs" : { + "flake-utils" : "flake-utils", + "nixpkgs" : "nixpkgs", + "pre-commit-hooks" : "pre-commit-hooks" + } + } + }, + "root" : "root", + "version" : 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f188aa0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + description = "Python application managed with poetry2nix"; + + inputs = { + flake-utils = { + type = "github"; + owner = "numtide"; + repo = "flake-utils"; + ref = "master"; + }; + + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixpkgs-unstable"; + }; + + pre-commit-hooks = { + type = "github"; + owner = "cachix"; + repo = "pre-commit-hooks.nix"; + ref = "master"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = { self, flake-utils, nixpkgs, pre-commit-hooks }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + python = pkgs.python3.withPackages (ps: with ps; [ + black + isort + mypy + ]); + in + { + checks = { + pre-commit = pre-commit-hooks.lib.${system}.run { + src = self; + + hooks = { + black = { + enable = true; + }; + + clang-format = { + enable = true; + types_or = [ "c" "c++" ]; + }; + + isort = { + enable = true; + }; + + nixpkgs-fmt = { + enable = true; + }; + }; + }; + }; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + python + pyright + ]; + + inherit (self.checks.${system}.pre-commit) shellHook; + }; + }); +}