From 6097d0857bb783d5445daa3f0a5a5f267851caaf Mon Sep 17 00:00:00 2001 From: Sokhibjon Orzikulov Date: Wed, 25 Dec 2024 04:19:08 +0500 Subject: [PATCH] feat: nixification --- .gitignore | 7 ++++--- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 +++++++++++++++++++++++++++++ shell.nix | 29 ++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index bc2c93d..a78f503 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# Nodejs and package manager *.local .eslintcache .next @@ -15,10 +16,10 @@ build/ .env .envrc -# svelte -dist-ssr +# Nix +/result -# editor directories and files +# Editor directories and files .idea .DS_Store *.suo diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..396ec32 --- /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": 1734649271, + "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", + "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 0000000..faaa73a --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Telegram bot for Xinux community"; + + inputs = { + # Too old to work with most libraries + # nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + + # Perfect! + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + + # The flake-utils library + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem + ( + system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + # Nix script formatter + formatter = pkgs.alejandra; + + # Development environment + devShells.default = import ./shell.nix {inherit pkgs;}; + } + ); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ec0afaf --- /dev/null +++ b/shell.nix @@ -0,0 +1,29 @@ +{pkgs ? import {}}: let + getLibFolder = pkg: "${pkg}/lib"; +in + pkgs.stdenv.mkDerivation { + name = "devops-journey-shell"; + + buildInputs = with pkgs; [ + # Package managers + pnpm + yarn + + # Runtime engines + nodejs_22 + + # Nextjs dependencies + vips + ]; + + shellHook = '' + printf "Installing pnpm dependencies\n" + pnpm install + + printf "Adding node_modules to PATH\n" + export PATH="$PWD/node_modules/.bin/:$PATH" + + printf "Adding necessary aliases\n" + alias scripts='jq ".scripts" package.json' + ''; + }