Initial commit

This commit is contained in:
Martin Puppe 2020-09-10 16:39:11 +02:00
commit 0d00fa5123
7 changed files with 121 additions and 0 deletions

17
README.markdown Normal file
View file

@ -0,0 +1,17 @@
# Nix support for financier
This repository contains files for building [financier](https://gitlab.com/mpuppe/financier/).
You first need to generate the necessary Nix files:
``` bash
nix-shell
bash generate.sh
exit
```
Afterwards, the distribution for financier can be build:
``` bash
nix-build dist.nix
```

40
default.nix Normal file
View file

@ -0,0 +1,40 @@
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem}:
let
meta = import ./meta.nix;
derivations = import ./node2nix.nix {
inherit pkgs system;
};
in
derivations // {
package = derivations.package.overrideAttrs (oldAttrs: rec {
src = pkgs.fetchgit { inherit (meta) url rev sha256; };
# Puppeteer (a dependency for testing) would try to download Chromium
# during installation. Downloading Chromium would not work though because
# Nix builds are sandboxed and cannot download arbitrary things. We
# therefore prevent Puppeteer from downloading anything.
preInstallPhases = "skipChromiumDownload";
skipChromiumDownload = ''
export PUPPETEER_SKIP_DOWNLOAD=1
'';
});
}

30
dist.nix Normal file
View file

@ -0,0 +1,30 @@
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem}:
let
financier = (import ./default.nix { inherit pkgs system; }).package;
meta = import ./meta.nix;
in
pkgs.stdenv.mkDerivation {
inherit (meta) version;
pname = "financier-dist";
src = "${financier}/lib/node_modules/financier";
buildInputs = [ financier.nodejs ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
env NO_UPDATE_NOTIFIER=true npm run build
'';
installPhase = ''
cp -r dist $out/
'';
}

5
generate.sh Normal file
View file

@ -0,0 +1,5 @@
node2nix "-$FINCANCIER_NODE_VERSION" --development \
--input "$FINANCIER_SRC/package.json" \
--lock "$FINANCIER_SRC/package-lock.json" \
--supplement-input supplement.json \
--composition node2nix.nix

9
meta.nix Normal file
View file

@ -0,0 +1,9 @@
rec {
version = "1.7.3";
nodeVersion = "12";
# Arguments for fetchgit
url = "https://gitlab.com/mpuppe/financier.git";
rev = "83367cae265af4a036a05766c6f80ea22d1cc1ec";
sha256 = "0h7222j9fk4b3fkc7c6gbhl0xranpl5swapkwibb0aba0g6fykfg";
}

15
shell.nix Normal file
View file

@ -0,0 +1,15 @@
{ pkgs ? import <nixpkgs> {} }:
let
meta = import ./meta.nix;
src = pkgs.fetchgit { inherit (meta) url rev sha256; };
in
pkgs.mkShell {
shellHook = ''
export FINANCIER_SRC="${src}"
export FINANCIER_NODE_VERSION="${meta.nodeVersion}"
'';
buildInputs = with pkgs; [
nodePackages.node2nix
nix-prefetch-scripts
];
}

5
supplement.json Normal file
View file

@ -0,0 +1,5 @@
[
{
"node-gyp-build": "^4.2.3"
}
]