-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
90 lines (73 loc) · 2.79 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
{
description = "DTLS/QUIC in luvit";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
luvitpkgs = {
url = "github:aiverson/luvit-nix";
# necessary to be able to replace openssl buildinput from luvi
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, luvitpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
devShells = forAllSystems (system: { default = self.packages.${system}.devShell; });
formatter = forAllSystems (system: self.packages.${system}.formatter);
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
lit = luvitpkgs.packages.${system}.lit;
luvi = luvitpkgs.packages.${system}.luvi;
luviBase = luvitpkgs.lib.${system}.luviBase;
luvit = luvitpkgs.packages.${system}.luvit;
replaceList = from: to: l: assert builtins.elem from l; (nixpkgs.lib.remove from l) ++ [ to ];
replaceString = from: to: s: assert nixpkgs.lib.hasInfix (builtins.unsafeDiscardStringContext from) s; builtins.replaceStrings [ from ] [ to ] s;
luvi-patched = luvi.overrideAttrs (finalAttrs: prevAttrs: {
buildInputs = replaceList pkgs.openssl pkgs.quictls prevAttrs.buildInputs;
patches = [ "${self}/luvi.patch" ];
patchPhase = null;
postPatch = prevAttrs.patchPhase;
});
luviBase-patched = luviBase.overrideAttrs (finalAttrs: prevAttrs: {
text = replaceString "${luvi}" "${luvi-patched}" prevAttrs.text;
});
luvit-patched = luvit.overrideAttrs (finalAttrs: prevAttrs: {
buildInputs = replaceList luvi luvi-patched prevAttrs.buildInputs;
buildPhase = replaceString "${luviBase}" "${luviBase-patched}" prevAttrs.buildPhase;
});
devShell = pkgs.mkShell {
buildInputs = [
lit
luvit-patched
pkgs.quictls
];
};
formatter = pkgs.writeShellApplication {
name = "run-formatters";
runtimeInputs = [
pkgs.fd
pkgs.nixpkgs-fmt
pkgs.stylua
];
text = ''
fd --type=file --extension=nix --exec-batch nixpkgs-fmt --
fd --type=file --extension=lua --exec-batch stylua --
'';
};
dtls = pkgs.stdenv.mkDerivation {
name = "dtls";
src = self;
phases = [ "unpackPhase" ];
preUnpack = ''
mkdir $out
cd $out
'';
};
default = dtls;
in
{ inherit devShell formatter dtls default; });
};
}