forked from pwncollege/challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
89 lines (83 loc) · 2.26 KB
/
Copy pathflake.nix
File metadata and controls
89 lines (83 loc) · 2.26 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
{
description = "pwn.college challenges dev env";
nixConfig = {
extra-substituters = [ "https://nix-cache.challenges.pwn.college" ];
extra-trusted-public-keys = [
"nix-cache.challenges.pwn.college-1:Qj32MyanSS2fW+W7MtEFN3fWSksMT8l6IyJuG9Lw5bc="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
};
outputs =
{ self, nixpkgs }:
let
lib = nixpkgs.lib;
systems = [ "x86_64-linux" ];
forAllSystems = f: lib.genAttrs systems (system: f system);
in
{
formatter = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
pkgs.writeShellApplication {
name = "fmt";
runtimeInputs = [
pkgs.nixfmt-rfc-style
pkgs.ruff
pkgs.treefmt
];
text = ''
set -euo pipefail
exec treefmt "$@"
'';
}
);
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
pwn-challenge-runtime = import ./runtime { inherit pkgs lib; };
pwnshop = pkgs.writeShellApplication {
name = "pwnshop";
runtimeInputs = with pkgs; [
git
uv
];
text = ''
set -euo pipefail
root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
exec "$root/pwnshop" "$@"
'';
};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
clang-tools
docker
git
git-crypt
jq
pwn-challenge-runtime
pwnshop
tomlq
uv
];
shellHook = ''
if [ "$(id -u)" -eq 0 ]; then
export DOCKER_HOST="$(${lib.getExe pwn-challenge-runtime})"
elif command -v sudo >/dev/null 2>&1; then
export DOCKER_HOST="$(sudo ${lib.getExe pwn-challenge-runtime})"
else
echo "error: cannot start the challenge runtime without root privileges" >&2
return 1
fi
'';
};
}
);
};
}