diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000000000000000000000000000000000000..3550a30f2de389e537ee40ca5e64a77dc185c79b
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.gitignore b/.gitignore
index 6b2702a76cdc4b356c6b9d735e91efda6bae15f7..c19183fd088eb79a3ad208b925ea38a3da9a40d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ Win32_LIB_ASM_Release
 /bin
 /build
 /CMakeUserPresets.json
+/.direnv
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000000000000000000000000000000000000..c0d09521dca739b8f90ffd144635e6edf8276135
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,55 @@
+# This is an example flake.nix for a Switch project based on devkitA64.
+# It will work on any devkitPro example with a Makefile out of the box.
+{
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+    flake-utils.url = "github:numtide/flake-utils";
+    devkitNix.url = "github:AAGaming00/devkitNix";
+  };
+
+  outputs = {
+    self,
+    nixpkgs,
+    flake-utils,
+    devkitNix,
+    ...
+  }:
+    flake-utils.lib.eachDefaultSystem (system: let
+      pkgs = import nixpkgs {
+        inherit system;
+        # devkitNix provides an overlay with the toolchains
+        overlays = [devkitNix.overlays.default];
+      };
+    in {
+
+      devShells.default = pkgs.mkShell {
+        # devkitNix packages also provide relevant tools you may want available
+        # in your PATH.
+        buildInputs = [pkgs.devkitNix.devkitA64];
+
+        # Each package provides a shell hook that sets all necessary
+        # environmental variables. This part is necessary, otherwise your build
+        # system won't know where to find devkitPro. By setting these
+        # variables we allow devkitPro's example Makefiles to work out of the box.
+        inherit (pkgs.devkitNix.devkitA64) shellHook;
+      };
+
+      packages.default = pkgs.stdenv.mkDerivation {
+        name = "ringracers";
+        src = ./.;
+
+        # `TARGET` determines the name of the executable.
+        makeFlags = ["TARGET=ringracers"];
+        # The shell hook is used in the build to point your build system to
+        # devkitPro.
+        preBuild = pkgs.devkitNix.devkitA64.shellHook;
+        # This is a simple Switch app example that only builds a single
+        # executable. If your project outputs multiple files, make `$out` a
+        # directory and copy everything there.
+        installPhase = ''
+          cp ringracers.nro $out
+        '';
+      };
+
+    });
+}