forked from newAM/monitorcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
92 lines (76 loc) · 2.21 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# This is a flake for use with NixOS
# See: https://nixos.wiki/wiki/Flakes
{
description = "Monitor controls using MCCS over DDC-CI";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs = {
self,
nixpkgs,
}: let
pyproject = nixpkgs.lib.importTOML ./pyproject.toml;
pname = pyproject.tool.poetry.name;
python3Overlay = final: prev:
prev.buildPythonPackage {
inherit pname;
inherit (pyproject.tool.poetry) version;
format = "pyproject";
src = builtins.path {
path = ./.;
name = "monitorcontrol";
};
nativeBuildInputs = [
prev.poetry-core
];
propagatedBuildInputs = [
prev.pyudev
];
checkInputs = [
prev.pytestCheckHook
prev.voluptuous
];
pythonImportsCheck = [
pname
];
postInstall = ''
mkdir -p $out/etc/udev/rules.d
echo 'KERNEL=="i2c-[0-9]*", GROUP="i2c"' > $out/etc/udev/rules.d/10-i2c.rules
'';
meta = with nixpkgs.lib; {
inherit (pyproject.tool.poetry) description;
homepage = pyproject.tool.poetry.repository;
license = with licenses; [mit];
};
};
overlay = final: prev: rec {
python3 = prev.python3.override {
packageOverrides = final: prev: {
monitorcontrol = python3Overlay final prev;
};
};
python3Packages = python3.pkgs;
};
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [overlay];
};
in {
packages.x86_64-linux.default = pkgs.python3Packages.monitorcontrol;
devShells.x86_64-linux.default = self.packages.x86_64-linux.default;
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;
checks.x86_64-linux = {
pkg = self.packages.x86_64-linux.default;
alejandra = pkgs.runCommand "alejandra" {} ''
${pkgs.alejandra}/bin/alejandra --check ${./.}
touch $out
'';
statix = pkgs.runCommand "statix" {} ''
${pkgs.statix}/bin/statix check ${./.}
touch $out
'';
};
overlays = {
default = overlay;
python3 = python3Overlay;
};
};
}