-
Notifications
You must be signed in to change notification settings - Fork 45
/
flake.nix
39 lines (32 loc) · 1.44 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
{
description = "A flake for the construct matrix homeserver";
outputs = { self, nixpkgs }: let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ];
in {
overlay = final: prev: rec {
matrix-construct-source = let
inherit (prev) lib linkFarm;
srcFilter = n: t: (lib.hasSuffix ".cc" n || lib.hasSuffix ".h" n || lib.hasSuffix ".S" n
|| lib.hasSuffix ".md" n || t == "directory");
repo = lib.cleanSourceWith { filter = srcFilter; src = lib.cleanSource ./.; };
buildFileWith = root: name: type: rec {
inherit name; file = "${root}/${name}";
path = if type == "directory" then buildFarmFrom name file else "${file}";
};
buildFarm = root: lib.mapAttrsToList (buildFileWith root) (builtins.readDir root);
buildFarmFrom = basename: root: linkFarm (lib.strings.sanitizeDerivationName basename) (buildFarm root);
in buildFarmFrom "construct" self;
matrix-construct = prev.callPackage ./nix/package {
rev = if self ? rev then self.rev else "development";
source = matrix-construct-source;
};
};
packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in self.overlay pkgs pkgs);
defaultPackage = forAllSystems (system: self.packages.${system}.matrix-construct);
nixosModules = {
matrix-construct = import ./nix/module self;
};
};
}