-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathflake.nix
134 lines (116 loc) · 3.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
{
description = "Extract files from any kind of container formats";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
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,
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 = [
# ubi_reader: 0.8.9 -> 0.8.10
{
url = "/~https://github.com/NixOS/nixpkgs/commit/a3b3188908f87f3c2bafd6b66ab2c0df2c059fa9.patch";
hash = "sha256-MYP5q7KwbGzx01GYxvb4YwkLPV/aSzbI4Cbp+olw9a0=";
}
];
# 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
importPkgs =
nixpkgs:
import nixpkgs {
inherit system;
overlays = [
self.overlays.default
shell-hooks.overlays.default
];
};
bootstrapPkgs = importPkgs nixpkgs;
patchedNixpkgs = bootstrapPkgs.applyPatches {
name = "nixpkgs-patched";
src = nixpkgs;
patches = map bootstrapPkgs.fetchpatch nixpkgsPatches;
};
finalPkgs = importPkgs patchedNixpkgs;
in
if builtins.length nixpkgsPatches != 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
cargo
rustc
nodejs # for pyright
] ++ unblob.runtimeDeps;
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}";
}
)
];
};
});
legacyPackages = forAllSystems (system: nixpkgsFor.${system});
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
};
}