picoCTF/flake.nix
2023-08-24 19:02:49 +02:00

48 lines
1.1 KiB
Nix

{
description = "picoGym Practice Challenges";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
};
outputs = {
self,
nixpkgs,
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
exercises = builtins.attrNames (builtins.readDir ./exercises);
forAllExercises = nixpkgs.lib.genAttrs exercises;
in {
formatter.${system} = pkgs.alejandra;
packages.${system} = forAllExercises (
exercise:
pkgs.writers.writePython3Bin "picoCTF_${exercise}" {
#libraries = with pkgs.python3.pkgs; [requests];
} "${builtins.readFile ./exercises/${exercise}/main.py}"
);
apps.${system} = forAllExercises (
exercise: {
type = "app";
program = "${self.packages.${system}.${exercise}}/bin/picoCTF_${exercise}";
}
);
devShells.${system} =
forAllExercises (
exercise:
pkgs.mkShellNoCC {
packages = with pkgs; [python3];
}
)
// {
default = pkgs.mkShellNoCC {
packages = with pkgs; [python3];
};
};
};
}