-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
52 lines (50 loc) · 1.86 KB
/
flake.nix
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
{
description = "master thesis data";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix, ... }@inputs:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
# see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples.
inherit (poetry2nix.legacyPackages.${system}) mkPoetryApplication defaultPoetryOverrides;
pkgs = import nixpkgs { inherit system; };
myAppEnv = pkgs.poetry2nix.mkPoetryEnv {
projectDir = ./.;
editablePackageSources = {
my-app = ./master_thesis_data;
};
overrides = defaultPoetryOverrides.extend
(self: super: {
pathspec = super.pathspec.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.flit-core ];
}
);
});
};
preCommitHook = pkgs.runCommand "pre-commit-hook"
{
nativeBuildInputs = [ pkgs.nixpkgs-fmt myAppEnv ];
} ''
nixpkgs-fmt --check ${./.}
black --config ${./pyproject.toml} --check ${./.}
mypy --config ${./pyproject.toml} ${./.}
touch $out
'';
in
{
packages = {
master-thesis-data = mkPoetryApplication { projectDir = self; };
default = self.packages.${system}.master-thesis-data;
};
formatter = pkgs.nixpkgs-fmt;
devShells.default = myAppEnv.env.overrideAttrs (oldAttrs: {
buildInputs = (oldAttrs.buildInputs or [ ]) ++ [ pkgs.poetry pkgs.python3 ];
});
checks.default = preCommitHook;
});
}