From 588c584be4527649b1e67a93f955ca24f56bae91 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Wed, 22 May 2024 13:14:10 -0700 Subject: [PATCH] add nix stuff --- default.nix | 21 +++++++++++++++++++++ flake.nix | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 default.nix create mode 100644 flake.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..5e1a81c --- /dev/null +++ b/default.nix @@ -0,0 +1,21 @@ +{ pkgs ? import {} }: + +pkgs.stdenv.mkDerivation { + name = "pnpm-project"; + src = ./.; + + buildInputs = [ + pkgs.nodejs + pkgs.nodePackages.pnpm + ]; + + buildPhase = '' + pnpm install + pnpm build + ''; + + installPhase = '' + mkdir -p $out + cp -r dist/* $out/ + ''; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f4304a8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "Flake for building pnpm project"; + + 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}; + in { + defaultPackage = pkgs.callPackage ./default.nix {}; + + devShell = pkgs.mkShell { + buildInputs = [ + pkgs.nodejs + pkgs.nodePackages.pnpm + ]; + }; + } + ); +}