{
  description = "Nix flake for the activity logging script";
  outputs =
    { nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      generatePackages =
        args:
        let
          inherit (args) dir ext handler;
        in
        ./${dir}
        |> builtins.readDir
        |> builtins.attrNames
        |> builtins.filter (file: builtins.match ".*\\.${ext}$" file != null)
        |> builtins.map (file: rec {
          name = builtins.replaceStrings [ ".${ext}" ] [ "" ] file;
          value = handler ./${dir}/${file} name;
        })
        |> builtins.listToAttrs;
    in
    {
      overlays.default = final: prev: {
        scrapy = prev.scrapy.overrideAttrs (old: rec {
          version = "2.11.2";
          src = prev.fetchFromGitHub {
            owner = "scrapy";
            repo = "scrapy";
            tag = version;
            hash = "sha256-EaO1kQ3VSTwEW+r0kSKycOxHNTPwwCVjch1ZBrTU0qQ=";
          };
        });
      };
      packages.x86_64-linux =
        let
          scriptBin = path: name: pkgs.writeScriptBin name (builtins.readFile path);
          pkgsBin = path: name: pkgs.callPackage path { };
        in
        {
          citra = pkgs.callPackage ./pkgs/citra/default.nix { branch = "nightly"; };
          pano = pkgs.callPackage ./pkgs/pano/default.nix { };
          vdhcoapp = pkgs.callPackage ./pkgs/vdhcoapp/default.nix { };
        }
        // generatePackages {
          dir = "pkgs";
          ext = "nix";
          handler = pkgsBin;
        }
        // generatePackages {
          dir = "pkgs_pr";
          ext = "nix";
          handler = pkgsBin;
        }
        // generatePackages {
          dir = "pkgs_wip";
          ext = "nix";
          handler = pkgsBin;
        }
        // generatePackages {
          dir = "src/scripts";
          ext = "sh";
          handler = scriptBin;
        }
        // generatePackages {
          dir = "src/scripts";
          ext = "py";
          handler = scriptBin;
        };
    };
}
