-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
136 lines (133 loc) · 3.78 KB
/
flake.nix
File metadata and controls
136 lines (133 loc) · 3.78 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
{
description = "Basic dependencies";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
{
lib.shell =
{
pkgs,
extraDeps ? [ ],
}:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
playwright-driver.browsers
];
buildInputs =
with pkgs;
[
nodejs_24
typescript-language-server
ripgrep
git
git-lfs
jq
]
++ extraDeps;
shellHook = ''
export PATH=$PATH:node_modules/.bin
export NIXPKGS_ALLOW_UNFREE=1
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
'';
};
lib.env =
{
pkgs,
extraDeps ? [ ],
}:
pkgs.callPackage ./env.nix { inherit extraDeps; };
lib.patch-playwright =
pkgs:
with pkgs;
writeShellScriptBin "patch-playwright" ''
path=''${1:-~/.cache/ms-playwright}
interpr=$(nix eval --raw 'nixpkgs#glibc')/lib64/ld-linux-x86-64.so.2
rpath=${google-chrome.rpath}:${
lib.makeLibraryPath [
dbus-glib
xorg.libXt
]
}
find $path/{chromium,firefox}-*/*/ -executable -type f | while read i; do
if ! [[ "$i" == *.so ]]; then
${patchelf}/bin/patchelf --set-interpreter "$interpr" "$i" || true
fi
${patchelf}/bin/patchelf --set-rpath "$rpath" "$i" || true
done
${patchelf}/bin/patchelf --set-interpreter "$interpr" $path/ffmpeg-*/ffmpeg-linux
'';
lib.playwrightEnv = pkgs: pkgs.callPackage ./env.nix { };
lib.podmanShell =
{ pkgs }:
let
podmanSetupScript =
let
registriesConf = pkgs.writeText "registries.conf" ''
[registries.search]
registries = ['docker.io']
[registries.block]
registries = []
'';
in
pkgs.writeScript "podman-setup" ''
#!${pkgs.runtimeShell}
if ! test -f ~/.config/containers/policy.json; then
install -Dm555 ${pkgs.skopeo.src}/default-policy.json ~/.config/containers/policy.json
fi
if ! test -f ~/.config/containers/registries.conf; then
install -Dm555 ${registriesConf} ~/.config/containers/registries.conf
fi
'';
in
pkgs.mkShell {
buildInputs = with pkgs; [
podman
runc
conmon
skopeo
slirp4netns
fuse-overlayfs
];
shellHook = ''
${podmanSetupScript}
'';
};
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in
rec {
devShell = self.lib.shell { inherit pkgs; };
devShells.env = self.lib.env { inherit pkgs; };
devShells.podmanShell = self.lib.podmanShell { inherit pkgs; };
devShells.tf = pkgs.mkShell {
buildInputs = with pkgs; [
go
gopls
autoconf
golangci-lint
gnumake
dqlite
terraform
];
};
packages = {
patch-playwright = self.lib.patch-playwright pkgs;
playwrightEnv = self.lib.playwrightEnv pkgs;
};
}
);
}