-
Notifications
You must be signed in to change notification settings - Fork 37
/
flake.nix
51 lines (42 loc) · 1.83 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
{
description = "High level access to the Hetzner robot";
outputs = { self, nixpkgs }: let
inherit (nixpkgs) lib;
hydraSystems = [ "i686-linux" "x86_64-linux" ];
mkPackage = pythonPackages: pythonPackages.buildPythonPackage {
pname = "hetzner";
version = let
matchVersion = builtins.match ".*version=[\"']([^\"']+)[\"'].*";
in builtins.head (matchVersion (builtins.readFile ./setup.py));
src = self;
};
in {
packages = lib.mapAttrs (lib.const (pkgs: {
hetzner = mkPackage pkgs.python3Packages;
})) nixpkgs.legacyPackages;
defaultPackage = let
getPackage = system: lib.const (self.packages.${system}.hetzner);
in lib.mapAttrs getPackage nixpkgs.legacyPackages;
checks = lib.mapAttrs (system: pkgs: let
interpreters = removeAttrs pkgs.pythonInterpreters [
# These fail to eveluate or build (the latter because we require TLS).
"graalpython37" "python3Minimal"
];
isEligible = lib.const (interpreter: let
rightPlatform = lib.elem system interpreter.meta.platforms;
rightVersion = interpreter.pythonAtLeast "3.7";
in interpreter ? pythonAtLeast && rightVersion && rightPlatform);
supported = lib.filterAttrs isEligible interpreters;
mkInterpreterPackage = lib.const (interpreter: {
name = lib.removeSuffix "3" interpreter.pname
+ "-${interpreter.pythonVersion}";
value = mkPackage interpreter.pkgs;
});
in lib.mapAttrs' mkInterpreterPackage supported) nixpkgs.legacyPackages;
hydraJobs = lib.genAttrs hydraSystems (system: let
# Hydra doesn't allow job names containing periods.
mangleName = lib.replaceStrings [ "." ] [ "_" ];
mangleAttrName = name: lib.nameValuePair (mangleName name);
in lib.mapAttrs' mangleAttrName self.checks.${system});
};
}