{
  description = "Development and build environment for singularity-forge";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
    flake-utils.url = "github:numtide/flake-utils";
  };

  nixConfig = {
    extra-substituters = [
      "https://cache.centralcloud.com/default"
    ];
    extra-trusted-public-keys = [
      "default:ywfU21WX06iOn2Ec2lae1jYh4w8LO4IQkmp06vJzsk8="
    ];
  };

  outputs = {
    self,
    nixpkgs,
    flake-utils,
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = import nixpkgs {
        inherit system;
      };
    in {
      devShells.default = pkgs.mkShell {
        packages = with pkgs; [
          bash
          cargo
          clippy
          git
          just
          libsecret
          pkg-config
          protobuf
          rust-analyzer
          rustc
          rustfmt
          uv
          zlib
        ];

        shellHook = ''
          export SF_SOURCE_DIR="${toString ./.}"
          if [ -x "$HOME/.local/bin/mise" ]; then
            MISE_NODE_BIN="$(cd "$SF_SOURCE_DIR" && "$HOME/.local/bin/mise" which node 2>/dev/null || true)"
            if [ -n "$MISE_NODE_BIN" ]; then
              CLEAN_PATH="$(printf '%s' "$PATH" | tr ':' '\n' | grep -v '/mise/installs/node/.*/bin' | paste -sd: -)"
              export PATH="$(dirname "$MISE_NODE_BIN"):$CLEAN_PATH"
            fi
          fi
          export PATH="$SF_SOURCE_DIR/bin:$PATH"
          export RUST_BACKTRACE=1

          echo "singularity-forge development shell"
          echo "  cargo: $(command -v cargo)"
          echo "  node : repo-pinned by mise after direnv activation"
          echo "  protoc: $(command -v protoc)"
          echo "  rustc: $(command -v rustc)"
          echo ""
          echo "Build native addon:"
          echo "  node rust-engine/scripts/build.js"
        '';
      };
    });
}
