From f196227c9a8f465b9f5e2e541d81330d4ea2a3d0 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 16 Aug 2024 19:37:58 +0200 Subject: [PATCH] add flake --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..eabe566 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1723637854, + "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9", + "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..14639fc --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "PVV doorbell matrix bot"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs, ... }@inputs: let + forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + in { + inherit inputs; + + packages = forAllSystems (system: let + inherit (pkgs) lib; + pkgs = nixpkgs.legacyPackages.${system}; + package-json = lib.importJSON ./package.json; + in { + + default = pkgs.buildNpmPackage { + pname = package-json.name; + version = package-json.version; + meta.homepage = package-json.repository.url; + meta.license = lib.getLicenseFromSpdxId package-json.license; + + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.difference ./. (lib.fileset.unions [ + ./flake.nix + ./flake.lock + ]); + }; + npmDepsHash = "sha256-UNc902yMkoWfpun1RrLYlEtOXcFd7uxlwKFWoM0/nTE="; + + postInstall = '' + ln -vs /run/secrets/pvv-doorbell-config.json $out/lib/node_modules/$pname/config.json + ''; + dontNpmBuild = true; + }; + + }); + }; + +}