-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathflake.nix
More file actions
176 lines (155 loc) · 5.32 KB
/
Copy pathflake.nix
File metadata and controls
176 lines (155 loc) · 5.32 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
{
description = "Extract files from any kind of container formats";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# nixpkgs 26.11 no longer has an x86_64-darwin stdenv. Keep this input
# only while that platform remains in unblob's CI matrix.
inputs.nixpkgs-x86_64-darwin.url = "github:NixOS/nixpkgs/nixos-26.05";
inputs.filter.url = "github:numtide/nix-filter";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.shell-hooks.url = "github:vlaci/nix-shell-hooks";
nixConfig = {
extra-substituters = [ "https://unblob.cachix.org" ];
extra-trusted-public-keys = [
"unblob.cachix.org-1:5kWA6DwOg176rSqU8TOTBXWxsDB4LoCMfGfTgL5qCAE="
];
};
outputs =
{
self,
nixpkgs,
nixpkgs-x86_64-darwin,
shell-hooks,
filter,
...
}:
let
# System types to support.
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
# Temporary patches for nixpkgs required for current unblob
nixpkgsPatches = [
./nix/patches/fs-python-3.14.patch
];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (
system:
let
nixpkgsSource = if system == "x86_64-darwin" then nixpkgs-x86_64-darwin else nixpkgs;
systemNixpkgsPatches = if system == "x86_64-darwin" then [ ] else nixpkgsPatches;
importPkgs =
nixpkgsSource: extraOverlays:
import nixpkgsSource {
inherit system;
overlays = [
self.overlays.default
shell-hooks.overlays.default
]
++ extraOverlays;
};
bootstrapPkgs = importPkgs nixpkgsSource [ ];
patchedNixpkgs = bootstrapPkgs.applyPatches {
name = "nixpkgs-patched";
src = nixpkgsSource;
patches = map (
patch: if builtins.isPath patch then patch else bootstrapPkgs.fetchpatch patch
) systemNixpkgsPatches;
};
finalPkgs = importPkgs patchedNixpkgs [
(final: prev: {
# Preserve the derivation context so consumers of `pkgs.path`
# retain the patched nixpkgs source as a build dependency.
path = "${patchedNixpkgs}";
# nix-shell-hooks currently references the former nixpkgs source
# location of auto-patchelf.sh. Use the packaged setup hook until
# it switches to a stable package path.
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
(_pythonFinal: pythonPrev: {
autoPatchelfVenvShellHook = pythonPrev.autoPatchelfVenvShellHook.overrideAttrs (_old: {
autoPatchelfHook = "${final.autoPatchelfHook}/nix-support/setup-hook";
});
})
];
})
];
in
if builtins.length systemNixpkgsPatches != 0 then finalPkgs else bootstrapPkgs
);
in
{
overlays.default = nixpkgs.lib.composeManyExtensions [
filter.overlays.default
(import ./overlay.nix)
];
packages = forAllSystems (
system:
let
inherit (nixpkgsFor.${system}) unblob;
in
{
inherit unblob;
default = unblob;
}
);
checks = forAllSystems (
system:
{
inherit (nixpkgsFor.${system}) unblob;
}
// self.devShells.${system}
);
devShells = forAllSystems (system: {
default =
let
pkgs = nixpkgsFor.${system};
in
with pkgs;
mkShell {
packages = [
python3Packages.uvVenvShellHook
python3Packages.patchVenvShellHook
python3Packages.autoPatchelfVenvShellHook
deadnix
statix
libz
cargo
cargo-deny
clippy
pinact
rustc
just
nodejs # for pyright
]
++ unblob.runtimeDeps;
uvExtraArgs = [
"--group"
"docs"
];
venvPatches = [
(
# https://github.com/NixOS/nixpkgs/blob/70f6d2ad78eee1617f0871878e509b6d78a8b13b/pkgs/development/python-modules/python-magic/default.nix#L25-L27
replaceVars "${path}/pkgs/development/python-modules/python-magic/libmagic-path.patch" {
libmagic = "${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}";
}
)
(replaceVars "${path}/pkgs/development/python-modules/cairocffi/dlopen-paths.patch" {
ext = stdenv.hostPlatform.extensions.sharedLibrary;
cairo = cairo.out;
glib = glib.out;
gdk_pixbuf = gdk-pixbuf.out;
})
];
};
});
legacyPackages = forAllSystems (system: nixpkgsFor.${system});
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt);
};
}