From 46bf101d8c3ad916f052cc2347403e04d1f6c3a7 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 16 Jul 2023 14:26:31 +0200 Subject: [PATCH] Get flakes to work --- .gitignore | 6 +++++- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 0b859912..c45c4928 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,8 @@ dist-ssr # Custom .env.dev phanpy-dist.zip -phanpy-dist.tar.gz \ No newline at end of file +phanpy-dist.tar.gz + +# Nix +.direnv +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..807a096b --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719075281, + "narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=", + "owner": "nixOS", + "repo": "nixpkgs", + "rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af", + "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..c158f07f --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + inputs.nixpkgs.url = github:nixOS/nixpkgs/nixos-unstable; + inputs.flake-utils.url = github:numtide/flake-utils; + + outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + lib = pkgs.lib; + in + rec { + packages.default = pkgs.buildNpmPackage { + pname = "dtth-phanpy"; + version = "0.1.0"; + + nativeBuildInputs = with pkgs; [ git ]; + ESBUILD_BINARY_PATH = lib.getExe pkgs.esbuild; + + src = lib.cleanSource ./.; + + npmFlags = [ "--legacy-peer-deps" ]; + npmDepsHash = "sha256-AfrqfaGtgiXF/xftRI0bSRu/+84lvuavoI7MiZI9cck="; + # npmDepsHash = lib.fakeHash; + + # DTTH-specific env variables + PHANPY_CLIENT_NAME = "DTTH Phanpy"; + PHANPY_CLIENT_ID = "ch.dtth.phanpy"; + PHANPY_WEBSITE = "https://social.dtth.ch"; + + installPhase = '' + runHook preInstall + mkdir -p $out/lib + cp -r dist $out/lib/phanpy + runHook postInstall + ''; + }; + + devShells.default = pkgs.mkShell { + inputsFrom = [ packages.default ]; + buildInputs = with pkgs; [ nodejs ]; + }; + }); +}