build: add nix

main
Carsten Kragelund 2023-06-12 21:43:13 +02:00
parent 71161c1872
commit 48e34120f3
Signed by: nyx
GPG Key ID: CADDADEEC9F753C0
5 changed files with 120 additions and 0 deletions

@ -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

@ -0,0 +1,22 @@
{ pkgs ? import <nixpkgs> {}, 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 ];
};
}

@ -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
}

@ -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; };
}
);
}

@ -0,0 +1,15 @@
{ pkgs ? import <nixpkgs> {}, 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"
'';
}