commit 0d00fa51238724f7ff9f848bd764c8990b8acf4c Author: Martin Puppe Date: Thu Sep 10 16:39:11 2020 +0200 Initial commit diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..14ebe54 --- /dev/null +++ b/README.markdown @@ -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 +``` \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..45ff894 --- /dev/null +++ b/default.nix @@ -0,0 +1,40 @@ +{pkgs ? import { + 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 + ''; + }); +} + + + + + + + + + + + + + + + + + diff --git a/dist.nix b/dist.nix new file mode 100644 index 0000000..d8aef79 --- /dev/null +++ b/dist.nix @@ -0,0 +1,30 @@ +{pkgs ? import { + 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/ + ''; +} + + + + + + + diff --git a/generate.sh b/generate.sh new file mode 100644 index 0000000..994a336 --- /dev/null +++ b/generate.sh @@ -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 \ No newline at end of file diff --git a/meta.nix b/meta.nix new file mode 100644 index 0000000..c297a57 --- /dev/null +++ b/meta.nix @@ -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"; +} \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..a3c424c --- /dev/null +++ b/shell.nix @@ -0,0 +1,15 @@ +{ pkgs ? import {} }: +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 + ]; +} \ No newline at end of file diff --git a/supplement.json b/supplement.json new file mode 100644 index 0000000..541d3c8 --- /dev/null +++ b/supplement.json @@ -0,0 +1,5 @@ +[ + { + "node-gyp-build": "^4.2.3" + } +] \ No newline at end of file