2024-08-04 06:47:08 +00:00
|
|
|
{ config, pkgs, lib, ...}:
|
2024-08-04 00:48:21 +00:00
|
|
|
let
|
|
|
|
name = "node-red";
|
2024-08-04 06:47:08 +00:00
|
|
|
packages =
|
|
|
|
with pkgs;
|
|
|
|
[
|
|
|
|
neovim
|
|
|
|
nodejs
|
|
|
|
nodePackages.npm
|
|
|
|
nodePackages.node-red
|
|
|
|
#ungoogled-chromium
|
|
|
|
];
|
|
|
|
passportOIDC = pkgs.fetchFromGitHub {
|
|
|
|
owner = "jaredhanson";
|
|
|
|
repo = "passport-openidconnect";
|
|
|
|
rev = "c69c2137c5b49534e93008aa0645a00aba1f7f0b";
|
|
|
|
sha256 = "sha256-jaeEoJNcAoczZhcuhb2Uw2LKXXARBKkPDYhIDUblWRk=";
|
|
|
|
};
|
2024-08-04 00:48:21 +00:00
|
|
|
entrypoint = pkgs.writeShellApplication {
|
|
|
|
name = "entrypoint";
|
|
|
|
|
2024-08-04 06:47:08 +00:00
|
|
|
runtimeInputs = packages;
|
2024-08-04 00:48:21 +00:00
|
|
|
|
|
|
|
text = ''
|
2024-08-04 06:47:08 +00:00
|
|
|
DATA="''${DATA-/data}"
|
|
|
|
cd "$DATA"
|
|
|
|
node-red -u "$DATA" -s "''${SETTINGS-/data/settings.js}"
|
2024-08-04 00:48:21 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in pkgs.dockerTools.streamLayeredImage {
|
|
|
|
inherit name;
|
2024-08-04 06:47:08 +00:00
|
|
|
contents = pkgs.buildEnv {
|
|
|
|
name = "imgroot";
|
|
|
|
paths = (with pkgs; [
|
|
|
|
shadow
|
|
|
|
less
|
|
|
|
bashInteractive
|
|
|
|
coreutils
|
|
|
|
findutils
|
|
|
|
dockerTools.usrBinEnv
|
|
|
|
dockerTools.binSh
|
|
|
|
dockerTools.caCertificates
|
|
|
|
#dockerTools.fakeNss
|
|
|
|
] ++ packages);
|
|
|
|
};
|
2024-08-04 00:48:21 +00:00
|
|
|
config.Cmd = [ "${entrypoint}/bin/entrypoint" ];
|
2024-08-04 06:47:08 +00:00
|
|
|
config.WorkingDir = "/data";
|
|
|
|
config.Env = with pkgs; [ "HOME=/data" ];
|
|
|
|
|
|
|
|
enableFakechroot = true;
|
|
|
|
fakeRootCommands = ''
|
|
|
|
# ${pkgs.runtimeShell}
|
|
|
|
mkdir -p tmp
|
|
|
|
chmod 1777 tmp
|
|
|
|
${pkgs.dockerTools.shadowSetup}
|
|
|
|
groupadd -r node-red
|
|
|
|
useradd -r -g node-red node-red
|
|
|
|
id node-red 2>&1 > node-red.id
|
|
|
|
mkdir -p /farts
|
|
|
|
mkdir -p /farts/copy
|
|
|
|
cp -a ${passportOIDC}/* /farts/copy/
|
|
|
|
${pkgs.nodejs}/bin/npm i --prefix /farts ${passportOIDC}
|
|
|
|
mkdir -p /data
|
|
|
|
(cd /data;${pkgs.nodejs}/bin/npm i passport-openidconnect)
|
|
|
|
chown -R node-red:node-red data
|
|
|
|
chmod -R 750 data
|
|
|
|
date > build-date.txt
|
|
|
|
'';
|
|
|
|
extraCommands = ''
|
|
|
|
#mkdir -p /data
|
|
|
|
#cd /data;${pkgs.nodejs}/bin/npm i passport-openidconnect
|
|
|
|
#(cd /data;${pkgs.nodejs}/bin/npm i passport-openidconnect)
|
|
|
|
'';
|
2024-08-04 00:48:21 +00:00
|
|
|
}
|