-
Notifications
You must be signed in to change notification settings - Fork 7
/
flake.nix
137 lines (125 loc) · 4.59 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{
description = "Nix expressions for defining Replit development environments";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
inputs.nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.fenix.url = "github:nix-community/fenix";
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nil.url = "github:oxalica/nil";
inputs.nil.inputs.nixpkgs.follows = "nixpkgs";
inputs.prybar.url = "github:replit/prybar";
inputs.prybar.inputs.nixpkgs.follows = "nixpkgs";
inputs.java-language-server.url = "github:replit/java-language-server";
inputs.java-language-server.inputs.nixpkgs.follows = "nixpkgs";
inputs.ztoc-rs.url = "github:replit/ztoc-rs";
inputs.ztoc-rs.inputs.nixpkgs.follows = "nixpkgs";
inputs.replit-rtld-loader.url = "github:replit/replit_rtld_loader";
inputs.replit-rtld-loader.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nixpkgs-unstable, prybar, java-language-server, nil, fenix, replit-rtld-loader, ... }:
let
mkPkgs = nixpkgs-spec: system: import nixpkgs-spec {
inherit system;
overlays = [
self.overlays.default
prybar.overlays.default
java-language-server.overlays.default
nil.overlays.default
fenix.overlays.default
replit-rtld-loader.overlays.default
];
# replbox has an unfree license
config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
"@replit/replbox"
];
};
pkgs-23_05 = mkPkgs nixpkgs "x86_64-linux";
patched-unstable = nixpkgs-unstable.legacyPackages.x86_64-linux.applyPatches {
name = "nixpkgs-unstable-patched";
src = nixpkgs-unstable;
patches = [
# rexml broke solargraph at some point in the past.
# Attempting to run:
# echo 'x = (5 + "hey")' > main.rb
# /nix/store/.../ruby /nix/store/.../bin/solargraph typecheck main.rb
# curently emits a bunch of "Unrecognized RBS type:" warnings, followed by
# "0 problems found."
# This patch used to apply, but even when massaged to apply to the
# current unstable HEAD, still produces the same result:
# ./patches/rexml.patch
];
};
pkgs = mkPkgs patched-unstable "x86_64-linux";
in
{
overlays.default = final: prev: {
moduleit = self.packages.${prev.system}.moduleit;
lib = prev.lib // {
mkWrapper-replit_ld_library_path = package: final.stdenvNoCC.mkDerivation {
name = "${package.name}-wrapped";
inherit (package) meta version;
buildInputs = [ pkgs.makeWrapper ];
buildCommand = ''
if [ ! -d ${package}/bin ]; then
echo "No bin directory found in ${package}"
exit 1
fi
mkdir -p $out/bin
for bin in ${package}/bin/*; do
local binName=$(basename $bin)
cat >$out/bin/$binName <<-EOF
#!${final.bash}/bin/bash
if [ -n "\''${REPLIT_LD_LIBRARY_PATH-}" ]; then
if test "\''${REPLIT_RTLD_LOADER:-}" = "1" && test "\''${REPLIT_NIX_CHANNEL:-}" != "legacy"
then
# activate RTLD loader!
export LD_AUDIT="${pkgs.replit-rtld-loader}/rtld_loader.so"
else
export LD_LIBRARY_PATH="\$REPLIT_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
fi
fi
exec "$bin" "\$@"
EOF
chmod +x $out/bin/$binName
done
'';
};
};
} // rec {
python38 = pkgs.python310.override {
sourceVersion = {
major = "3";
minor = "8";
patch = "18";
suffix = "";
};
hash = "sha256-P/txzTSaMmunsvrcfn34a6V33ZxJF+UqhAGtvadAXj8=";
};
python38Full = python38.override {
self = python38Full;
pythonAttr = "python38Full";
bluezSupport = true;
x11Support = true;
};
python38Packages = python38Full.pkgs;
};
formatter.x86_64-linux = pkgs.nixpkgs-fmt;
packages.x86_64-linux = import ./pkgs {
inherit pkgs self;
};
devShells.x86_64-linux.default = pkgs.mkShell {
packages = with pkgs; [
python310
pigz
coreutils
findutils
e2fsprogs
gnutar
gzip
];
};
} // (
import ./pkgs/modules {
inherit pkgs;
inherit pkgs-23_05;
}
);
}