Skip to content

Invidious is an alternative front-end to YouTube

chore: Add Nix development files (#5856)

Fijxu67bfb56bbe7d
diff --git a/.envrc b/.envrc
new file mode 100644
index 00000000..3550a30f
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.gitignore b/.gitignore
index 7a26e1a6..fafc9068 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,6 @@
/invidious
/sentry
/config/config.yml
+
+# direnv directory used for the Nix Flake.
+.direnv
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..0160bf2d
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1785571196,
+ "narHash": "sha256-KoTsyMQqnXQZq8deCEnu4QkyldkwH/bpMMhUcfMdGIw=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "148bab9c1c3c53136ecb44a6ea356a0ed5b39b06",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000..c8985a0a
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,27 @@
+{
+ description = "Invidious Nix Flake";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ flake-utils,
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+ devPackages = import ./packages.nix { inherit pkgs; };
+ in
+ {
+ devShells.default = pkgs.mkShell {
+ buildInputs = devPackages;
+ };
+ }
+ );
+}
diff --git a/packages.nix b/packages.nix
new file mode 100644
index 00000000..fa3da012
--- /dev/null
+++ b/packages.nix
@@ -0,0 +1,19 @@
+{ pkgs }:
+
+# Development packages, this makes Crystal 1.19 (latest available in nixpkgs)
+# and sqlite available in a `nix-shell` or `nix develop` build environment.
+#
+# We dont need to add other dependencies like `libxml2` or `libyaml` here
+# since they are already available by default in the Crystal Nix package
+# (see the output value of CRYSTAL_LIBRARY_PATH when running `crystal env`
+# Ref: https://github.com/NixOS/nixpkgs/blob/nixos-26.05/pkgs/development/compilers/crystal/default.nix#L231)
+#
+with pkgs;
+[
+ # Invidious dependencies
+ crystal_1_19
+ sqlite
+ shards
+ # Utilities
+ nixd # Nixd LSP to format .nix files
+]
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 00000000..c9df71fd
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,11 @@
+{
+ pkgs ? import <nixpkgs> { },
+}:
+
+let
+ devPackages = import ./packages.nix { inherit pkgs; };
+in
+
+pkgs.mkShell {
+ buildInputs = devPackages;
+}