{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
    systems.url = "github:nix-systems/default";
    devenv.url = "github:cachix/devenv/9ba9e3b908a12ddc6c43f88c52f2bf3c1d1e82c1"; # until https://github.com/cachix/devenv/issues/756 is fixed
    emanote.url = "github:srid/emanote";
  };

  nixConfig = {
    extra-trusted-public-keys = ["devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
                                 "srid.cachix.org-1:3clnql5gjbJNEvhA/WQp7nrZlBptwpXnUk6JAv8aB2M="
    ];
    extra-substituters = [
      "https://devenv.cachix.org"
      "https://srid.cachix.org"
    ];
  };

  outputs = { self, nixpkgs, devenv, systems, emanote, ... } @ inputs:
    let
      forEachSystem = nixpkgs.lib.genAttrs (import systems);
    in
    {
      devShells = forEachSystem
        (system:
          let
            pkgs = nixpkgs.legacyPackages.${system};
          in
          {
            default = devenv.lib.mkShell {
              inherit inputs pkgs;
              modules = [
               ({ pkgs, emanote, ... }:

                {
                  # https://devenv.sh/basics/

                  # https://devenv.sh/packages/
                  packages = [
                    pkgs.git
                    pkgs.docker
                    emanote.packages.${system}.emanote
                  ];

                  enterShell = ''
                    echo 'Hello from "Emanote" environment.'
                    git --version
                    echo -n "Emanote version " && emanote --version
                  '';

                  # https://devenv.sh/languages/
                  # languages.nix.enable = true;

                  # https://devenv.sh/pre-commit-hooks/
                  pre-commit.hooks.shellcheck.enable = true;
                  pre-commit.hooks.markdownlint.enable = true;
                  pre-commit.settings.markdownlint.config = {
                    "MD041"= false;
                  };

                  # https://devenv.sh/processes/
                  # processes.ping.exec = "ping example.com";

                  processes = {
                    emanote.exec = "cd $DEVENV_ROOT/content && emanote run --port=8081";
                  };

                  scripts.showDoc.exec = "sensible-browser http://127.0.0.1:8081/";
                  scripts.generate.exec = "cd $DEVENV_ROOT/content && emanote gen $DEVENV_ROOT/static_gen";
                  scripts.nix-cleanup.exec = "nix-env --delete-generations old && nix-store --gc && nix-collect-garbage -d";

                  # See full reference at https://devenv.sh/reference/options/
                })
              ];
            };
          });
    };
}
