From 7fe980d27b2e1f9696c9091f9486677b9ccd15d8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 21 Jan 2026 15:02:50 +0300 Subject: [PATCH] nix: initial tooling Signed-off-by: NotAShelf Change-Id: I5e9bfbc614604329d54240c02f620e156a6a6964 --- .envrc | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 24 ++++++++++++++++++++++++ nix/package.nix | 43 +++++++++++++++++++++++++++++++++++++++++++ shell.nix | 7 +++++++ 5 files changed, 102 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6013ccd --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1768886240, + "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..122c695 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "NodeJS Project Template"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; + + outputs = { + self, + nixpkgs, + ... + }: let + systems = ["x86_64-linux" "aarch64-linux"]; + forEachSystem = nixpkgs.lib.genAttrs systems; + pkgsForEach = nixpkgs.legacyPackages; + in { + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/package.nix {}; + }); + + devShells = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./shell.nix {}; + }); + + hydraJobs = self.packages; + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..f9e4778 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,43 @@ +{ + lib, + stdenv, + fetchPnpmDeps, + nodejs-slim, + pnpm, + pnpmConfigHook, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "nix-evaluator-stats"; + version = "0.1.0"; + + src = ../.; + + nativeBuildInputs = [ + nodejs-slim + pnpm + pnpmConfigHook # dependency resolution + ]; + + pnpmDeps = fetchPnpmDeps { + inherit (finalAttrs) pname src; + hash = "sha256-CpfaUvQbvOXljCqNwyMUJNDisnlrWCHBwhmdIzjmv+c="; + fetcherVersion = 3; # https://nixos.org/manual/nixpkgs/stable/#javascript-pnpm-fetcherVersion + }; + + buildPhase = '' + runHook preBuild + + mkdir -p $out/share/dist + pnpm run build --outDir $out/share/dist + + runHook postBuild + ''; + + meta = { + description = "Pretty visualiser for Nix evaluator stats"; + homepage = "https://github.com/notashelf/nix-evaluator-stats"; + platforms = ["x86_64-linux" "aarch64-linux"]; + license = lib.licenses.mpl20; + maintainers = [lib.maintainers.NotAShelf]; + }; +}) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..99b2c08 --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +{pkgs ? import {}}: +pkgs.mkShell { + packages = [ + pkgs.nodejs-slim + pkgs.pnpm + ]; +}