Nix Firebase

A quick blog post on using nix
with Firebase.
Getting Firebase to work with Nix just requires a few package to get going 😂 If you have worked with Firebase, you know setting up the environment can be royal pain. Never fear, Nix can help with getting you ready to start developing locally.
Firebase provides a fantastic suite of tools for building modern web and mobile applications. Nix enhances this by providing a declarative and reproducible way to manage your deployment pipeline. Use Nix to define your Firebase project dependencies, configuration files, and deployment scripts, ensuring that your applications are always deployed in a consistent and reliable manner. This combination simplifies the process of managing complex Firebase projects and ensures that your applications are always deployed in a predictable and reproducible way.
Firebase Packages
Firebase uses nodejs for its development environment. However it also requires additional packages depending on which Firebase tools you require.
- Lets create a
shell.nix
script
1with import <nixpkgs> {};
2
3pkgs.mkShell {
4 name = "firebase-dev";
5
6 nativeBuildInputs = with pkgs; [
7 nodejs_20 # Nodejs 20
8 nodePackages_latest.webpack # Webpack support
9 firebase-tools # Firebase Tools
10 cacert # Support certificates
11 ];
12
13 LANGUAGE = "Firebase";
14 VERSION = "firebase --version";
15
16 shellHook = ''
17 # Optional: Script environment start up
18 echo "Welcome to $LANGUAGE Development Environment"
19 $VERSION
20 '';
21}
The above script will still give us a firebase
development environment
complete with a nice message to let us know the shell is running.
In general Firebase will require both nodejs
,cacert
and firebase-tools
.
The additional of webpack is optional.
- Run a Pure environment
Remember a pure environment tries to ignore the existing host configuration 😂
Nix will automatically look for the file shell.nix
so you dont need to added this parameter 🥰
1nix-shell --pure
Expected Output:
1Welcome to Firebase Development Environment
213.35.1
Awesome, Firebase is configured and ready to go!
- Exit the Nix Shell
1exit
Nice we now have a super quick and easy way to run Firebase on a Nix machine. Nix will take care of the machine config and setup.