diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..f861751 --- /dev/null +++ b/.envrc @@ -0,0 +1,7 @@ +if type -P lorri &>/dev/null; then + echo 'direnv using lorri' + eval "$(lorri direnv)" +else + echo 'direnv using nix-direnv' + use nix +fi \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..68fc0c0 --- /dev/null +++ b/default.nix @@ -0,0 +1,22 @@ +{ pkgs ? import {}, lib ? pkgs.lib }: +let + package = builtins.fromJSON (builtins.readFile ./package.json); +in +pkgs.buildNpmPackage rec { + pname = package.name; + version = package.version; + + src = ./.; + + npmDepsHash = "sha256-R06AIzbXKud5cFYAn1hsuOndSu20s59eRMkwjNQynXA="; + + # The prepack script runs the build script, which we'd rather do in the build phase. + npmPackFlags = [ "--ignore-scripts" ]; + + meta = with lib; { + description = package.description; + homepage = package.homepage; + license = builtins.getAttr (toLower package.license) licenses; + maintainers = with maintainers; [ nyx ]; + }; +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0061fb4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1686596538, + "narHash": "sha256-kw7+Br/nNOHwmYG0lxMvMbWG0BE2meypCmyjijbb5yI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "eb6e16e3c5d77c5a80edc1731ac53e5e040d6044", + "type": "github" + }, + "original": { + "owner": "nixos", + "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..d02ddd6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,16 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/23.05"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = import ./shell.nix { inherit pkgs; }; + } + ); +} \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..378d86f --- /dev/null +++ b/shell.nix @@ -0,0 +1,15 @@ +{ pkgs ? import {}, lib ? pkgs.lib }: +let + NPM_CONFIG_PREFIX = toString ./npm_config_prefix; +in pkgs.mkShell { + packages = with pkgs; [ + nodejs_18 + nodePackages.npm + ]; + + inherit NPM_CONFIG_PREFIX; + + shellHook = '' + export PATH="${NPM_CONFIG_PREFIX}/bin:$PATH" + ''; +} \ No newline at end of file