nix: add flake

This commit is contained in:
Bruno BELANYI 2022-11-21 15:54:11 +01:00
commit 3e790dbb87
2 changed files with 142 additions and 0 deletions

66
flake.lock Normal file
View file

@ -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
}

76
flake.nix Normal file
View file

@ -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;
};
});
}