add overlays, pkgs

This commit is contained in:
2023-07-13 13:09:17 +02:00
parent c7aef44265
commit e21a47a2b5
34 changed files with 8812 additions and 2 deletions

View File

@@ -20,6 +20,14 @@
username = "nb-epicenter";
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN/2SAFm50kraB1fepAizox/QRXxB7WbqVbH+5OPalDT47VIJGNKOKhixQoqhABHxEoLxdf/C83wxlCVlPV9poLfDgVkA3Lyt5r3tSFQ6QjjOJAgchWamMsxxyGBedhKvhiEzcr/Lxytnoz3kjDG8fqQJwEpdqMmJoMUfyL2Rqp16u+FQ7d5aJtwO8EUqovhMaNO7rggjPpV/uMOg+tBxxmscliN7DLuP4EMTA/FwXVzcFNbOx3K9BdpMRAaSJt4SWcJO2cS2KHA5n/H+PQI7nz5KN3Yr/upJN5fROhi/SHvK39QOx12Pv7FCuWlc+oR68vLaoCKYhnkl3DnCfc7A7";
}
{
username = "nb-dominik";
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN/2SAFm50kraB1fepAizox/QRXxB7WbqVbH+5OPalDT47VIJGNKOKhixQoqhABHxEoLxdf/C83wxlCVlPV9poLfDgVkA3Lyt5r3tSFQ6QjjOJAgchWamMsxxyGBedhKvhiEzcr/Lxytnoz3kjDG8fqQJwEpdqMmJoMUfyL2Rqp16u+FQ7d5aJtwO8EUqovhMaNO7rggjPpV/uMOg+tBxxmscliN7DLuP4EMTA/FwXVzcFNbOx3K9BdpMRAaSJt4SWcJO2cS2KHA5n/H+PQI7nz5KN3Yr/upJN5fROhi/SHvK39QOx12Pv7FCuWlc+oR68vLaoCKYhnkl3DnCfc7A7";
}
{
username = "example";
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN/2SAFm50kraB1fepAizox/QRXxB7WbqVbH+5OPalDT47VIJGNKOKhixQoqhABHxEoLxdf/C83wxlCVlPV9poLfDgVkA3Lyt5r3tSFQ6QjjOJAgchWamMsxxyGBedhKvhiEzcr/Lxytnoz3kjDG8fqQJwEpdqMmJoMUfyL2Rqp16u+FQ7d5aJtwO8EUqovhMaNO7rggjPpV/uMOg+tBxxmscliN7DLuP4EMTA/FwXVzcFNbOx3K9BdpMRAaSJt4SWcJO2cS2KHA5n/H+PQI7nz5KN3Yr/upJN5fROhi/SHvK39QOx12Pv7FCuWlc+oR68vLaoCKYhnkl3DnCfc7A7";
}
];
in {
imports = builtins.map create_users users;

View File

@@ -26,7 +26,7 @@
./hardware-configuration.nix
];
nixpkgs.overlays = [ (import ./overlays/packages.nix) ];
nixpkgs.overlays = [ (import ./utils/overlays/packages.nix) ];
# security.sudo.wheelNeedsPassword = false;
services.clevis.uuid = "7435d48f-f942-485b-9817-328ad3fc0b93";

View File

@@ -26,7 +26,7 @@
./hardware-configuration.nix
];
nixpkgs.overlays = [ (import ./overlays/packages.nix) ];
nixpkgs.overlays = [ (import ./utils/overlays/packages.nix) ];
# security.sudo.wheelNeedsPassword = false;
services.clevis.uuid = "7435d48f-f942-485b-9817-328ad3fc0b93";

View File

@@ -0,0 +1,5 @@
self: super: {
bento = (super.callPackage ../pkgs/bento { });
howdy = (super.callPackage ../pkgs/howdy { });
linux-enable-ir-emitter = (super.callPackage ../pkgs/linux-enable-ir-emitter { });
}

View File

@@ -0,0 +1,48 @@
diff --git a/Cargo.lock b/Cargo.lock
index fb17c7e..ef157e5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2901,10 +2901,10 @@ dependencies = [
[[package]]
name = "magnum-opus"
version = "0.4.0"
-source = "git+https://github.com/open-trade/magnum-opus#3c3d0b86ae95c84930bebffe4bcb03b3bd83342b"
+source = "git+https://github.com/TheRadioGuy/magnum-opus#171e1d021004626f7444d1e39b98f50bc3cb2604"
dependencies = [
- "bindgen",
- "target_build_utils",
+ "libc",
+ "opusic-sys",
]
[[package]]
@@ -3463,6 +3463,16 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+[[package]]
+name = "opusic-sys"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5eace752ce07a037241dba8f02c654799f051e431b27028056bcb480e83b54f5"
+dependencies = [
+ "cmake",
+ "libc",
+]
+
[[package]]
name = "os_str_bytes"
version = "6.0.0"
diff --git a/Cargo.toml b/Cargo.toml
index 1b715bd..960e8da 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -47,7 +47,7 @@ libc = "0.2"
parity-tokio-ipc = { git = "https://github.com/open-trade/parity-tokio-ipc" }
flexi_logger = { version = "0.22", features = ["async", "use_chrono_for_offset"] }
runas = "0.2"
-magnum-opus = { git = "https://github.com/open-trade/magnum-opus" }
+magnum-opus = { git = "https://github.com/TheRadioGuy/magnum-opus" }
dasp = { version = "0.11", features = ["signal", "interpolate-linear", "interpolate"], optional = true }
rubato = { version = "0.12", optional = true }
samplerate = { version = "0.2", optional = true }

View File

@@ -0,0 +1,17 @@
self: super:
{
rustdesk = super.rustdesk.overrideAttrs (old: rec {
pname = "rustdesk";
version = "nightly";
src = super.fetchFromGitHub {
owner = "rustdesk";
repo = "rustdesk";
rev = "52ce3dd2c299e262a54af0b5350fa60f66215e60";
sha256 = "01mfzgj3aw0k7sb0d2291inxmicrw09rrgfjl1pn50m2y29v0r40";
};
cargoPatches = [
./rustdesk-cargo.patch
];
});
}

37
utils/pkgs/bento.nix Normal file
View File

@@ -0,0 +1,37 @@
{ pkgs, stdenv, fetchgit }:
stdenv.mkDerivation rec {
name = "bento";
src = fetchgit {
url = "https://github.com/rapenne-s/bento.git";
rev = "6418bd64ecabbfa720c7a87ec39ee1a8b46a907e";
sha256 = "69b056298cf570debd3718b2e2cb7e63ad9465919c8190cf38043791ce61d0d6";
};
buildInputs = [ ];
patchPhase = ''
substituteInPlace bento --replace 'inotifywait' "${pkgs.inotify-tools}/bin/inotifywait";
'';
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share
install -Dm555 bento $out/bin/
install -Dm444 fleet.nix $out/share/
install -Dm444 config.sh.sample $out/share/
install -Dm444 LICENSE $out/share/
install -Dm444 README.md $out/share/
install -Dm444 utils/bento.nix $out/share/
'';
meta = with stdenv.lib; {
description = "A KISS deployment tool to keep your NixOS fleet (servers & workstations) up to date.";
homepage = "https://github.com/rapenne-s/bento";
license = licenses.MIT;
platforms = platforms.linux;
};
}

View File

@@ -0,0 +1,40 @@
{ pkgs, lib, stdenv, fetchgit }:
stdenv.mkDerivation rec {
name = "bento";
src = fetchgit {
url = "https://github.com/rapenne-s/bento.git";
rev = "6418bd64ecabbfa720c7a87ec39ee1a8b46a907e";
sha256 = "sha256-gLWoZh7fMn3cpIYSJFSVOQHA6qUIJikHXmucHX7P2WI=";
};
buildInputs = [ ];
patchPhase = ''
substituteInPlace bento --replace 'inotifywait' "${pkgs.inotify-tools}/bin/inotifywait";
'';
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share
install -Dm555 bento $out/bin/
install -Dm444 fleet.nix $out/share/
install -Dm444 config.sh.sample $out/share/
install -Dm444 LICENSE $out/share/
install -Dm444 README.md $out/share/
install -Dm444 utils/bento.nix $out/share/
'';
meta = with lib; {
description = "A KISS deployment tool to keep your NixOS fleet (servers & workstations) up to date.";
homepage = "https://github.com/rapenne-s/bento";
license = licenses.mit;
platforms = platforms.linux;
};
}
## fleet nix is for sftp server with chroot
## just copy to bento server and change configuration

3
utils/pkgs/default.nix Normal file
View File

@@ -0,0 +1,3 @@
final: prev: rec {
playactor = final.callPackage ./playactor.nix {};
}

View File

@@ -0,0 +1,135 @@
{ stdenv
, lib
, bzip2
, fetchFromGitHub
, fetchurl
, fmt
, gettext
, inih
, installShellFiles
, libevdev
, meson
, ninja
, pam
, pkg-config
, python3
}:
let
data = let
baseurl = "https://github.com/davisking/dlib-models/raw/daf943f7819a3dda8aec4276754ef918dc26491f";
in {
"dlib_face_recognition_resnet_model_v1.dat" = fetchurl {
url = "${baseurl}/dlib_face_recognition_resnet_model_v1.dat.bz2";
sha256 = "0fjm265l1fz5zdzx5n5yphl0v0vfajyw50ffamc4cd74848gdcdb";
};
"mmod_human_face_detector.dat" = fetchurl {
url = "${baseurl}/mmod_human_face_detector.dat.bz2";
sha256 = "117wv582nsn585am2n9mg5q830qnn8skjr1yxgaiihcjy109x7nv";
};
"shape_predictor_5_face_landmarks.dat" = fetchurl {
url = "${baseurl}/shape_predictor_5_face_landmarks.dat.bz2";
sha256 = "0wm4bbwnja7ik7r28pv00qrl3i1h6811zkgnjfvzv7jwpyz7ny3f";
};
};
py = python3.withPackages (p: [
p.face_recognition
(p.opencv4.override { enableGtk3 = true; })
]);
in
stdenv.mkDerivation {
pname = "howdy";
version = "unstable-2023-02-28";
src = fetchFromGitHub {
owner = "boltgolt";
repo = "howdy";
rev = "e881cc25935c7d39a074e9701a06b1fce96cc185";
hash = "sha256-BHS1J0SUNbCeAnTXrOQCtBJTaSYa5jtYYtTgfycv7VM=";
};
patches = [
# Change directory with configuration from `/etc` to `/var/lib`, since the service is expected to modify it.
./howdy.patch
];
postPatch =
let
howdypath = "${placeholder "out"}/lib/security/howdy";
in
''
substituteInPlace howdy/src/cli/add.py --replace "@pkgdatadir@" "${howdypath}"
substituteInPlace howdy/src/cli/config.py --replace '/bin/nano' 'nano'
substituteInPlace howdy/src/cli/test.py --replace "@pkgdatadir@" "${howdypath}"
substituteInPlace howdy/src/pam/main.cc \
--replace "python3" "${py}/bin/python" \
--replace "/lib/security/howdy/compare.py" "${howdypath}/compare.py"
substituteInPlace howdy/src/compare.py \
--replace "/lib/security/howdy" "${howdypath}" \
--replace "@pkgdatadir@" "${howdypath}"
'';
nativeBuildInputs = [
bzip2
installShellFiles
meson
ninja
pkg-config
];
buildInputs = [
fmt
gettext
inih
libevdev
pam
py
];
# build howdy_pam
preConfigure = ''
cd howdy/src/pam
# works around hardcoded install_dir: '/lib/security'.
# See https://github.com/boltgolt/howdy/blob/30728a6d3634479c24ffd4e094c34a30bbb43058/howdy/src/pam/meson.build#L22
export DESTDIR=$out
'';
postInstall =
let
libDir = "$out/lib/security/howdy";
inherit (lib) mapAttrsToList concatStrings;
in
''
# done with howdy_pam, go back to source root
cd ../../../..
mkdir -p $out/share/licenses/howdy
install -Dm644 LICENSE $out/share/licenses/howdy/LICENSE
rm -rf howdy/src/pam
mkdir -p ${libDir}
cp -r howdy/src/* ${libDir}
rm -rf ${libDir}/pam-config ${libDir}/dlib-data/*
${concatStrings (mapAttrsToList (n: v: ''
bzip2 -dc ${v} > ${libDir}/dlib-data/${n}
'') data)}
mkdir -p $out/bin
ln -s ${libDir}/cli.py $out/bin/howdy
mkdir -p "$out/share/bash-completion/completions"
installShellCompletion --bash howdy/src/autocomplete/howdy
'';
meta = {
description = "Windows Hello style facial authentication for Linux";
homepage = "https://github.com/boltgolt/howdy";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ fufexan ];
};
}

View File

@@ -0,0 +1,78 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.howdy;
howdy = pkgs.callPackage ./howdy.nix { };
pam_python = pkgs.callPackage ./pam-python.nix { };
# `dark_threshold` is required for X1 Carbon 7th to work
configINI = pkgs.runCommand "config.ini" { } ''
cat ${cfg.package}/lib/security/howdy/config.ini > $out
substituteInPlace $out --replace 'device_path = none' 'device_path = ${cfg.device}'
substituteInPlace $out --replace 'dark_threshold = 50' 'dark_threshold = ${
toString cfg.dark-threshold
}'
substituteInPlace $out --replace 'certainty = 3.5' 'certainty = ${
toString cfg.certainty
}'
'';
pam-rule = pkgs.lib.mkDefault (pkgs.lib.mkBefore
"auth sufficient ${pam_python}/lib/security/pam_python.so ${config.services.howdy.package}/lib/security/howdy/pam.py");
in {
options = {
services.howdy = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable howdy and PAM module for face recognition.
'';
};
package = mkOption {
type = types.package;
default = howdy;
defaultText = "howdy";
description = ''
Howdy package to use.
'';
};
device = mkOption {
type = types.path;
default = "/dev/video0";
description = ''
Device file connected to the IR sensor.
'';
};
certainty = mkOption {
type = types.int;
default = 4;
description = ''
The certainty of the detected face belonging to the user of the account. On a scale from 1 to 10, values above 5 are not recommended.
'';
};
dark-threshold = mkOption {
type = types.int;
default = 50;
description = ''
Because of flashing IR emitters, some frames can be completely unlit. Skip the frame if the lowest 1/8 of the histogram is above this percentage of the total. The lower this setting is, the more dark frames are ignored.
'';
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
environment.etc."howdy/config.ini".source = configINI;
security.pam.services = {
sudo.text = pam-rule; # Sudo
login.text = pam-rule; # User login
polkit-1.text = pam-rule; # PolKit
};
};
}

135
utils/pkgs/howdy/howdy.nix Normal file
View File

@@ -0,0 +1,135 @@
{ stdenv
, lib
, bzip2
, fetchFromGitHub
, fetchurl
, fmt
, gettext
, inih
, installShellFiles
, libevdev
, meson
, ninja
, pam
, pkg-config
, python3
}:
let
data = let
baseurl = "https://github.com/davisking/dlib-models/raw/daf943f7819a3dda8aec4276754ef918dc26491f";
in {
"dlib_face_recognition_resnet_model_v1.dat" = fetchurl {
url = "${baseurl}/dlib_face_recognition_resnet_model_v1.dat.bz2";
sha256 = "0fjm265l1fz5zdzx5n5yphl0v0vfajyw50ffamc4cd74848gdcdb";
};
"mmod_human_face_detector.dat" = fetchurl {
url = "${baseurl}/mmod_human_face_detector.dat.bz2";
sha256 = "117wv582nsn585am2n9mg5q830qnn8skjr1yxgaiihcjy109x7nv";
};
"shape_predictor_5_face_landmarks.dat" = fetchurl {
url = "${baseurl}/shape_predictor_5_face_landmarks.dat.bz2";
sha256 = "0wm4bbwnja7ik7r28pv00qrl3i1h6811zkgnjfvzv7jwpyz7ny3f";
};
};
py = python3.withPackages (p: [
p.face_recognition
(p.opencv4.override { enableGtk3 = true; })
]);
in
stdenv.mkDerivation {
pname = "howdy";
version = "unstable-2023-02-28";
src = fetchFromGitHub {
owner = "boltgolt";
repo = "howdy";
rev = "e881cc25935c7d39a074e9701a06b1fce96cc185";
hash = "sha256-BHS1J0SUNbCeAnTXrOQCtBJTaSYa5jtYYtTgfycv7VM=";
};
patches = [
# Change directory with configuration from `/etc` to `/var/lib`, since the service is expected to modify it.
./howdy.patch
];
postPatch =
let
howdypath = "${placeholder "out"}/lib/security/howdy";
in
''
substituteInPlace howdy/src/cli/add.py --replace "@pkgdatadir@" "${howdypath}"
substituteInPlace howdy/src/cli/config.py --replace '/bin/nano' 'nano'
substituteInPlace howdy/src/cli/test.py --replace "@pkgdatadir@" "${howdypath}"
substituteInPlace howdy/src/pam/main.cc \
--replace "python3" "${py}/bin/python" \
--replace "/lib/security/howdy/compare.py" "${howdypath}/compare.py"
substituteInPlace howdy/src/compare.py \
--replace "/lib/security/howdy" "${howdypath}" \
--replace "@pkgdatadir@" "${howdypath}"
'';
nativeBuildInputs = [
bzip2
installShellFiles
meson
ninja
pkg-config
];
buildInputs = [
fmt
gettext
inih
libevdev
pam
py
];
# build howdy_pam
preConfigure = ''
cd howdy/src/pam
# works around hardcoded install_dir: '/lib/security'.
# See https://github.com/boltgolt/howdy/blob/30728a6d3634479c24ffd4e094c34a30bbb43058/howdy/src/pam/meson.build#L22
export DESTDIR=$out
'';
postInstall =
let
libDir = "$out/lib/security/howdy";
inherit (lib) mapAttrsToList concatStrings;
in
''
# done with howdy_pam, go back to source root
cd ../../../..
mkdir -p $out/share/licenses/howdy
install -Dm644 LICENSE $out/share/licenses/howdy/LICENSE
rm -rf howdy/src/pam
mkdir -p ${libDir}
cp -r howdy/src/* ${libDir}
rm -rf ${libDir}/pam-config ${libDir}/dlib-data/*
${concatStrings (mapAttrsToList (n: v: ''
bzip2 -dc ${v} > ${libDir}/dlib-data/${n}
'') data)}
mkdir -p $out/bin
ln -s ${libDir}/cli.py $out/bin/howdy
mkdir -p "$out/share/bash-completion/completions"
installShellCompletion --bash howdy/src/autocomplete/howdy
'';
meta = {
description = "Windows Hello style facial authentication for Linux";
homepage = "https://github.com/boltgolt/howdy";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ fufexan ];
};
}

View File

@@ -0,0 +1,155 @@
diff --git a/howdy/src/cli/add.py b/howdy/src/cli/add.py
index 8951e31..4f793d7 100644
--- a/howdy/src/cli/add.py
+++ b/howdy/src/cli/add.py
@@ -30,9 +30,9 @@ import cv2
config_path = "/etc/howdy"
# Test if at lest 1 of the data files is there and abort if it's not
-if not os.path.isfile(config_path + "/dlib-data/shape_predictor_5_face_landmarks.dat"):
+if not os.path.isfile("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat"):
print(_("Data files have not been downloaded, please run the following commands:"))
- print("\n\tcd " + config_path + "/dlib-data")
+ print("\n\tcd " + "@pkgdatadir@/dlib-data")
print("\tsudo ./install.sh\n")
sys.exit(1)
@@ -42,23 +42,23 @@ config.read(config_path + "/config.ini")
use_cnn = config.getboolean("core", "use_cnn", fallback=False)
if use_cnn:
- face_detector = dlib.cnn_face_detection_model_v1(config_path + "/dlib-data/mmod_human_face_detector.dat")
+ face_detector = dlib.cnn_face_detection_model_v1("@pkgdatadir@/dlib-data/mmod_human_face_detector.dat")
else:
face_detector = dlib.get_frontal_face_detector()
-pose_predictor = dlib.shape_predictor(config_path + "/dlib-data/shape_predictor_5_face_landmarks.dat")
-face_encoder = dlib.face_recognition_model_v1(config_path + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
+pose_predictor = dlib.shape_predictor("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat")
+face_encoder = dlib.face_recognition_model_v1("@pkgdatadir@/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
user = builtins.howdy_user
# The permanent file to store the encoded model in
-enc_file = config_path + "/models/" + user + ".dat"
+enc_file = "/var/lib/howdy/models/" + user + ".dat"
# Known encodings
encodings = []
# Make the ./models folder if it doesn't already exist
-if not os.path.exists(config_path + "/models"):
+if not os.path.exists("/var/lib/howdy/models"):
print(_("No face model folder found, creating one"))
- os.makedirs(config_path + "/models")
+ os.makedirs("/var/lib/howdy/models")
# To try read a premade encodings file if it exists
try:
diff --git a/howdy/src/cli/clear.py b/howdy/src/cli/clear.py
index 6fa5f3e..fc7676c 100644
--- a/howdy/src/cli/clear.py
+++ b/howdy/src/cli/clear.py
@@ -8,7 +8,7 @@ import builtins
from i18n import _
# Get the full path to this file
-path = "/etc/howdy/models"
+path = "/var/lib/howdy/models"
# Get the passed user
user = builtins.howdy_user
diff --git a/howdy/src/cli/list.py b/howdy/src/cli/list.py
index 3532e9f..b9e2a31 100644
--- a/howdy/src/cli/list.py
+++ b/howdy/src/cli/list.py
@@ -10,7 +10,7 @@ import builtins
from i18n import _
# Get the absolute path and the username
-path = "/etc/howdy"
+path = "/var/lib/howdy"
user = builtins.howdy_user
# Check if the models file has been created yet
diff --git a/howdy/src/cli/remove.py b/howdy/src/cli/remove.py
index 6321e0b..7c13d79 100644
--- a/howdy/src/cli/remove.py
+++ b/howdy/src/cli/remove.py
@@ -9,7 +9,7 @@ import builtins
from i18n import _
# Get the absolute path and the username
-path = "/etc/howdy"
+path = "/var/lib/howdy"
user = builtins.howdy_user
# Check if enough arguments have been passed
diff --git a/howdy/src/cli/test.py b/howdy/src/cli/test.py
index d54929a..fa45500 100644
--- a/howdy/src/cli/test.py
+++ b/howdy/src/cli/test.py
@@ -59,20 +59,20 @@ use_cnn = config.getboolean('core', 'use_cnn', fallback=False)
if use_cnn:
face_detector = dlib.cnn_face_detection_model_v1(
- path + "/dlib-data/mmod_human_face_detector.dat"
+ "@pkgdatadir@/dlib-data/mmod_human_face_detector.dat"
)
else:
face_detector = dlib.get_frontal_face_detector()
-pose_predictor = dlib.shape_predictor(path + "/dlib-data/shape_predictor_5_face_landmarks.dat")
-face_encoder = dlib.face_recognition_model_v1(path + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
+pose_predictor = dlib.shape_predictor("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat")
+face_encoder = dlib.face_recognition_model_v1("@pkgdatadir@/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
encodings = []
models = None
try:
user = builtins.howdy_user
- models = json.load(open(path + "/models/" + user + ".dat"))
+ models = json.load(open("/var/lib/howdy/models/" + user + ".dat"))
for model in models:
encodings += model["data"]
diff --git a/howdy/src/compare.py b/howdy/src/compare.py
index be19464..86a8d8f 100644
--- a/howdy/src/compare.py
+++ b/howdy/src/compare.py
@@ -48,22 +48,22 @@ def init_detector(lock):
global face_detector, pose_predictor, face_encoder
# Test if at lest 1 of the data files is there and abort if it's not
- if not os.path.isfile(PATH + "/dlib-data/shape_predictor_5_face_landmarks.dat"):
+ if not os.path.isfile("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat"):
print(_("Data files have not been downloaded, please run the following commands:"))
- print("\n\tcd " + PATH + "/dlib-data")
+ print("\n\tcd " + "@pkgdatadir@/dlib-data")
print("\tsudo ./install.sh\n")
lock.release()
exit(1)
# Use the CNN detector if enabled
if use_cnn:
- face_detector = dlib.cnn_face_detection_model_v1(PATH + "/dlib-data/mmod_human_face_detector.dat")
+ face_detector = dlib.cnn_face_detection_model_v1("@pkgdatadir@/dlib-data/mmod_human_face_detector.dat")
else:
face_detector = dlib.get_frontal_face_detector()
# Start the others regardless
- pose_predictor = dlib.shape_predictor(PATH + "/dlib-data/shape_predictor_5_face_landmarks.dat")
- face_encoder = dlib.face_recognition_model_v1(PATH + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
+ pose_predictor = dlib.shape_predictor("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat")
+ face_encoder = dlib.face_recognition_model_v1("@pkgdatadir@/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
# Note the time it took to initialize detectors
timings["ll"] = time.time() - timings["ll"]
@@ -129,7 +129,7 @@ face_encoder = None
# Try to load the face model from the models folder
try:
- models = json.load(open(PATH + "/models/" + user + ".dat"))
+ models = json.load(open("/var/lib/howdy/models/" + user + ".dat"))
for model in models:
encodings += model["data"]

View File

@@ -0,0 +1,28 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.ir-toggle;
ir_toggle = pkgs.callPackage ./ir-toggle.nix { };
in {
options = {
services.ir-toggle = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable Chicony IR Emitter toggler.
'';
};
};
};
config = mkIf cfg.enable {
# Udev rules to start it on boot.
environment.systemPackages = [ ir_toggle ];
# Re-toggle the IR emitter after the sleep so that it could work perfectly
powerManagement.resumeCommands =
"${ir_toggle}/bin/chicony-ir-toggle on";
services.udev.packages = [ ir_toggle ];
};
}

View File

@@ -0,0 +1,17 @@
{ stdenv, fetchFromGitHub, cmake }:
stdenv.mkDerivation rec {
name = "chicony-ir-toggle";
src = fetchFromGitHub {
owner = "PetePriority";
repo = name;
rev = "5758112ae7f502035d48f24123347ba37cdbdb34";
sha256 = "1ihxkvhjbryhw5xjnw5a36f5w8nn4lnf07dzmzi6jzrn5ax131hw";
};
nativeBuildInputs = [ cmake ];
preInstall = ''
substituteInPlace ../CMakeLists.txt --replace /lib $out/lib
'';
}

View File

@@ -0,0 +1,17 @@
{ stdenv, python2, python2Packages, fetchurl, pam }:
let outPath = placeholder "out";
in stdenv.mkDerivation rec {
pname = "pam-python";
version = "1.0.7";
src = fetchurl {
url =
"https://downloads.sourceforge.net/project/pam-python/pam-python-1.0.7-1/pam-python-1.0.7.tar.gz";
sha256 = "01vylk8vmzsvxf0iwn2nizwkhdzk0vpyqh5m1rybh0sv6pz75kln";
};
buildInputs = [ python2 python2Packages.sphinx pam ];
preBuild = ''
patchShebangs .
substituteInPlace src/Makefile --replace '-Werror' '-O -Werror=cpp'
'';
makeFlags = [ "PREFIX=${outPath}" "LIBDIR=${outPath}/lib/security" ];
}

47
utils/pkgs/jxplorer.nix Normal file
View File

@@ -0,0 +1,47 @@
{ lib, stdenv, fetchurl, makeDesktopItem, ant, jdk8 }:
stdenv.mkDerivation rec {
pname = "jxplorer";
version = "3.3.1.2";
src = fetchurl {
url = "https://github.com/pegacat/${pname}/releases/download/v${version}/${pname}-${version}-project.tar.bz2";
sha256 = "/lWkavH51OqNFSLpgT+4WcQcfW3WvnnOkB03jB7bE/s=";
};
jxplorerItem = makeDesktopItem {
name = "JXplorer";
exec = "jxplorer";
comment = "A Java Ldap Browser";
desktopName = "JXplorer";
genericName = "Java Ldap Browser";
icon = "jxplorer";
};
configurePhase = ''
cat >"${pname}" << EOF
#!/bin/sh
cd "$out/opt/jxplorer"
export JAVA_HOME="${jdk8}"
sh jxplorer.sh "\$@"
EOF
chmod +x "${pname}"
'';
installPhase = ''
install -d "$out/opt/jxplorer" "$out/bin" "$out/share/pixmaps" "$out/share/applications"
cp -r ./. "$out/opt/jxplorer"
install -Dm755 "${pname}" "$out/bin/${pname}"
cp -r "${jxplorerItem}/." "$out"
install -Dm644 images/JX128.png "$out/share/pixmaps/${pname}.png"
'';
meta = with lib; {
description = "A Java Ldap Browser";
homepage = "https://sourceforge.net/projects/jxplorer/";
license = "CA Open Source Licence Version 1.0";
maintainers = with maintainers; [ benwbooth ];
platforms = platforms.linux;
};
}

View File

@@ -0,0 +1,51 @@
{ stdenv
, lib
, makeWrapper
, fetchFromGitHub
, fetchurl
, meson
, ninja
, pkg-config
, python3
, opencv
, usbutils
}:
stdenv.mkDerivation rec {
pname = "linux-enable-ir-emitter";
version = "4.5.0";
src = fetchFromGitHub {
owner = "EmixamPP";
repo = pname;
rev = version;
hash = "sha256-Dv1ukn2TkXfBk1vc+6Uq7tw8WwCAfIcKl13BoOifz+Q=";
};
patches = [
# Prevent `linux-enable-ir-emitter configure` from trying to enable systemd service, NixOS manages those declaratively.
./remove-boot-set.patch
];
nativeBuildInputs = [
makeWrapper
meson
ninja
pkg-config
];
buildInputs = [
python3
opencv
];
postInstall = ''
wrapProgram $out/bin/${pname} --prefix PATH : ${lib.makeBinPath [usbutils]}
'';
meta = {
description = "Provides support for infrared cameras that are not directly enabled out-of-the box";
homepage = "https://github.com/EmixamPP/linux-enable-ir-emitter";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ fufexan ];
platforms = lib.platforms.linux;
};
}

View File

@@ -0,0 +1,11 @@
diff --git a/sources/command/configure.py b/sources/command/configure.py
index 2cd20d2..84ffb73 100644
--- a/sources/command/configure.py
+++ b/sources/command/configure.py
@@ -25,6 +25,5 @@ def configure(device: str, emitters: int, neg_answer_limit: int) -> NoReturn:
logging.info("Do not hesitate to visit the GitHub ! https://github.com/EmixamPP/linux-enable-ir-emitter/wiki")
else:
logging.info("The driver has been successfully generated.")
- boot("enable")
exit(exit_code)

View File

@@ -0,0 +1,17 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-14_x"}:
let
nodeEnv = import ./node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}

View File

@@ -0,0 +1,689 @@
# This file originates from node2nix
{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}:
let
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
utillinux = if pkgs ? utillinux then pkgs.utillinux else pkgs.util-linux;
python = if nodejs ? python then nodejs.python else python2;
# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
tarWrapper = runCommand "tarWrapper" {} ''
mkdir -p $out/bin
cat > $out/bin/tar <<EOF
#! ${stdenv.shell} -e
$(type -p tar) "\$@" --warning=no-unknown-keyword --delay-directory-restore
EOF
chmod +x $out/bin/tar
'';
# Function that generates a TGZ file from a NPM project
buildNodeSourceDist =
{ name, version, src, ... }:
stdenv.mkDerivation {
name = "node-tarball-${name}-${version}";
inherit src;
buildInputs = [ nodejs ];
buildPhase = ''
export HOME=$TMPDIR
tgzFile=$(npm pack | tail -n 1) # Hooks to the pack command will add output (https://docs.npmjs.com/misc/scripts)
'';
installPhase = ''
mkdir -p $out/tarballs
mv $tgzFile $out/tarballs
mkdir -p $out/nix-support
echo "file source-dist $out/tarballs/$tgzFile" >> $out/nix-support/hydra-build-products
'';
};
# Common shell logic
installPackage = writeShellScript "install-package" ''
installPackage() {
local packageName=$1 src=$2
local strippedName
local DIR=$PWD
cd $TMPDIR
unpackFile $src
# Make the base dir in which the target dependency resides first
mkdir -p "$(dirname "$DIR/$packageName")"
if [ -f "$src" ]
then
# Figure out what directory has been unpacked
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
# Restore write permissions to make building work
find "$packageDir" -type d -exec chmod u+x {} \;
chmod -R u+w "$packageDir"
# Move the extracted tarball into the output folder
mv "$packageDir" "$DIR/$packageName"
elif [ -d "$src" ]
then
# Get a stripped name (without hash) of the source directory.
# On old nixpkgs it's already set internally.
if [ -z "$strippedName" ]
then
strippedName="$(stripHash $src)"
fi
# Restore write permissions to make building work
chmod -R u+w "$strippedName"
# Move the extracted directory into the output folder
mv "$strippedName" "$DIR/$packageName"
fi
# Change to the package directory to install dependencies
cd "$DIR/$packageName"
}
'';
# Bundle the dependencies of the package
#
# Only include dependencies if they don't exist. They may also be bundled in the package.
includeDependencies = {dependencies}:
lib.optionalString (dependencies != []) (
''
mkdir -p node_modules
cd node_modules
''
+ (lib.concatMapStrings (dependency:
''
if [ ! -e "${dependency.packageName}" ]; then
${composePackage dependency}
fi
''
) dependencies)
+ ''
cd ..
''
);
# Recursively composes the dependencies of a package
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
installPackage "${packageName}" "${src}"
${includeDependencies { inherit dependencies; }}
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
'';
pinpointDependencies = {dependencies, production}:
let
pinpointDependenciesFromPackageJSON = writeTextFile {
name = "pinpointDependencies.js";
text = ''
var fs = require('fs');
var path = require('path');
function resolveDependencyVersion(location, name) {
if(location == process.env['NIX_STORE']) {
return null;
} else {
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
if(fs.existsSync(dependencyPackageJSON)) {
var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
if(dependencyPackageObj.name == name) {
return dependencyPackageObj.version;
}
} else {
return resolveDependencyVersion(path.resolve(location, ".."), name);
}
}
}
function replaceDependencies(dependencies) {
if(typeof dependencies == "object" && dependencies !== null) {
for(var dependency in dependencies) {
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
if(resolvedVersion === null) {
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
} else {
dependencies[dependency] = resolvedVersion;
}
}
}
}
/* Read the package.json configuration */
var packageObj = JSON.parse(fs.readFileSync('./package.json'));
/* Pinpoint all dependencies */
replaceDependencies(packageObj.dependencies);
if(process.argv[2] == "development") {
replaceDependencies(packageObj.devDependencies);
}
else {
packageObj.devDependencies = {};
}
replaceDependencies(packageObj.optionalDependencies);
replaceDependencies(packageObj.peerDependencies);
/* Write the fixed package.json file */
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
'';
};
in
''
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
${lib.optionalString (dependencies != [])
''
if [ -d node_modules ]
then
cd node_modules
${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
cd ..
fi
''}
'';
# Recursively traverses all dependencies of a package and pinpoints all
# dependencies in the package.json file to the versions that are actually
# being used.
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
''
if [ -d "${packageName}" ]
then
cd "${packageName}"
${pinpointDependencies { inherit dependencies production; }}
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
fi
'';
# Extract the Node.js source code which is used to compile packages with
# native bindings
nodeSources = runCommand "node-sources" {} ''
tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
mv node-* $out
'';
# Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty)
addIntegrityFieldsScript = writeTextFile {
name = "addintegrityfields.js";
text = ''
var fs = require('fs');
var path = require('path');
function augmentDependencies(baseDir, dependencies) {
for(var dependencyName in dependencies) {
var dependency = dependencies[dependencyName];
// Open package.json and augment metadata fields
var packageJSONDir = path.join(baseDir, "node_modules", dependencyName);
var packageJSONPath = path.join(packageJSONDir, "package.json");
if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored
console.log("Adding metadata fields to: "+packageJSONPath);
var packageObj = JSON.parse(fs.readFileSync(packageJSONPath));
if(dependency.integrity) {
packageObj["_integrity"] = dependency.integrity;
} else {
packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
}
if(dependency.resolved) {
packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided
} else {
packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
}
if(dependency.from !== undefined) { // Adopt from property if one has been provided
packageObj["_from"] = dependency.from;
}
fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
}
// Augment transitive dependencies
if(dependency.dependencies !== undefined) {
augmentDependencies(packageJSONDir, dependency.dependencies);
}
}
}
if(fs.existsSync("./package-lock.json")) {
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
if(![1, 2].includes(packageLock.lockfileVersion)) {
process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n");
process.exit(1);
}
if(packageLock.dependencies !== undefined) {
augmentDependencies(".", packageLock.dependencies);
}
}
'';
};
# Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
reconstructPackageLock = writeTextFile {
name = "reconstructpackagelock.js";
text = ''
var fs = require('fs');
var path = require('path');
var packageObj = JSON.parse(fs.readFileSync("package.json"));
var lockObj = {
name: packageObj.name,
version: packageObj.version,
lockfileVersion: 2,
requires: true,
packages: {
"": {
name: packageObj.name,
version: packageObj.version,
license: packageObj.license,
bin: packageObj.bin,
dependencies: packageObj.dependencies,
engines: packageObj.engines,
optionalDependencies: packageObj.optionalDependencies
}
},
dependencies: {}
};
function augmentPackageJSON(filePath, packages, dependencies) {
var packageJSON = path.join(filePath, "package.json");
if(fs.existsSync(packageJSON)) {
var packageObj = JSON.parse(fs.readFileSync(packageJSON));
packages[filePath] = {
version: packageObj.version,
integrity: "sha1-000000000000000000000000000=",
dependencies: packageObj.dependencies,
engines: packageObj.engines,
optionalDependencies: packageObj.optionalDependencies
};
dependencies[packageObj.name] = {
version: packageObj.version,
integrity: "sha1-000000000000000000000000000=",
dependencies: {}
};
processDependencies(path.join(filePath, "node_modules"), packages, dependencies[packageObj.name].dependencies);
}
}
function processDependencies(dir, packages, dependencies) {
if(fs.existsSync(dir)) {
var files = fs.readdirSync(dir);
files.forEach(function(entry) {
var filePath = path.join(dir, entry);
var stats = fs.statSync(filePath);
if(stats.isDirectory()) {
if(entry.substr(0, 1) == "@") {
// When we encounter a namespace folder, augment all packages belonging to the scope
var pkgFiles = fs.readdirSync(filePath);
pkgFiles.forEach(function(entry) {
if(stats.isDirectory()) {
var pkgFilePath = path.join(filePath, entry);
augmentPackageJSON(pkgFilePath, packages, dependencies);
}
});
} else {
augmentPackageJSON(filePath, packages, dependencies);
}
}
});
}
}
processDependencies("node_modules", lockObj.packages, lockObj.dependencies);
fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2));
'';
};
# Script that links bins defined in package.json to the node_modules bin directory
# NPM does not do this for top-level packages itself anymore as of v7
linkBinsScript = writeTextFile {
name = "linkbins.js";
text = ''
var fs = require('fs');
var path = require('path');
var packageObj = JSON.parse(fs.readFileSync("package.json"));
var nodeModules = Array(packageObj.name.split("/").length).fill("..").join(path.sep);
if(packageObj.bin !== undefined) {
fs.mkdirSync(path.join(nodeModules, ".bin"))
if(typeof packageObj.bin == "object") {
Object.keys(packageObj.bin).forEach(function(exe) {
if(fs.existsSync(packageObj.bin[exe])) {
console.log("linking bin '" + exe + "'");
fs.symlinkSync(
path.join("..", packageObj.name, packageObj.bin[exe]),
path.join(nodeModules, ".bin", exe)
);
}
else {
console.log("skipping non-existent bin '" + exe + "'");
}
})
}
else {
if(fs.existsSync(packageObj.bin)) {
console.log("linking bin '" + packageObj.bin + "'");
fs.symlinkSync(
path.join("..", packageObj.name, packageObj.bin),
path.join(nodeModules, ".bin", packageObj.name.split("/").pop())
);
}
else {
console.log("skipping non-existent bin '" + packageObj.bin + "'");
}
}
}
else if(packageObj.directories !== undefined && packageObj.directories.bin !== undefined) {
fs.mkdirSync(path.join(nodeModules, ".bin"))
fs.readdirSync(packageObj.directories.bin).forEach(function(exe) {
if(fs.existsSync(path.join(packageObj.directories.bin, exe))) {
console.log("linking bin '" + exe + "'");
fs.symlinkSync(
path.join("..", packageObj.name, packageObj.directories.bin, exe),
path.join(nodeModules, ".bin", exe)
);
}
else {
console.log("skipping non-existent bin '" + exe + "'");
}
})
}
'';
};
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
let
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
in
''
# Pinpoint the versions of all dependencies to the ones that are actually being used
echo "pinpointing versions of dependencies..."
source $pinpointDependenciesScriptPath
# Patch the shebangs of the bundled modules to prevent them from
# calling executables outside the Nix store as much as possible
patchShebangs .
# Deploy the Node.js package by running npm install. Since the
# dependencies have been provided already by ourselves, it should not
# attempt to install them again, which is good, because we want to make
# it Nix's responsibility. If it needs to install any dependencies
# anyway (e.g. because the dependency parameters are
# incomplete/incorrect), it fails.
#
# The other responsibilities of NPM are kept -- version checks, build
# steps, postprocessing etc.
export HOME=$TMPDIR
cd "${packageName}"
runHook preRebuild
${lib.optionalString bypassCache ''
${lib.optionalString reconstructLock ''
if [ -f package-lock.json ]
then
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
rm package-lock.json
else
echo "No package-lock.json file found, reconstructing..."
fi
node ${reconstructPackageLock}
''}
node ${addIntegrityFieldsScript}
''}
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
runHook postRebuild
if [ "''${dontNpmInstall-}" != "1" ]
then
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
rm -f npm-shrinkwrap.json
npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install
fi
# Link executables defined in package.json
node ${linkBinsScript}
'';
# Builds and composes an NPM package including all its dependencies
buildNodePackage =
{ name
, packageName
, version ? null
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, preRebuild ? ""
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, meta ? {}
, ... }@args:
let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
in
stdenv.mkDerivation ({
name = "${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
inherit nodejs;
inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall preRebuild unpackPhase buildPhase;
compositionScript = composePackage args;
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
installPhase = ''
source ${installPackage}
# Create and enter a root node_modules/ folder
mkdir -p $out/lib/node_modules
cd $out/lib/node_modules
# Compose the package and all its dependencies
source $compositionScriptPath
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
# Create symlink to the deployed executable folder, if applicable
if [ -d "$out/lib/node_modules/.bin" ]
then
ln -s $out/lib/node_modules/.bin $out/bin
# Fixup all executables
ls $out/bin/* | while read i
do
file="$(readlink -f "$i")"
chmod u+rwx "$file"
if isScript "$file"
then
sed -i 's/\r$//' "$file" # convert crlf to lf
fi
done
fi
# Create symlinks to the deployed manual page folders, if applicable
if [ -d "$out/lib/node_modules/${packageName}/man" ]
then
mkdir -p $out/share
for dir in "$out/lib/node_modules/${packageName}/man/"*
do
mkdir -p $out/share/man/$(basename "$dir")
for page in "$dir"/*
do
ln -s $page $out/share/man/$(basename "$dir")
done
done
fi
# Run post install hook, if provided
runHook postInstall
'';
meta = {
# default to Node.js' platforms
platforms = nodejs.meta.platforms;
} // meta;
} // extraArgs);
# Builds a node environment (a node_modules folder and a set of binaries)
buildNodeDependencies =
{ name
, packageName
, version ? null
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:
let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
in
stdenv.mkDerivation ({
name = "node-dependencies-${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall unpackPhase buildPhase;
includeScript = includeDependencies { inherit dependencies; };
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
installPhase = ''
source ${installPackage}
mkdir -p $out/${packageName}
cd $out/${packageName}
source $includeScriptPath
# Create fake package.json to make the npm commands work properly
cp ${src}/package.json .
chmod 644 package.json
${lib.optionalString bypassCache ''
if [ -f ${src}/package-lock.json ]
then
cp ${src}/package-lock.json .
chmod 644 package-lock.json
fi
''}
# Go to the parent folder to make sure that all packages are pinpointed
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
# Expose the executables that were installed
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
mv ${packageName} lib
ln -s $out/lib/node_modules/.bin $out/bin
'';
} // extraArgs);
# Builds a development shell
buildNodeShell =
{ name
, packageName
, version ? null
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:
let
nodeDependencies = buildNodeDependencies args;
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "unpackPhase" "buildPhase" ];
in
stdenv.mkDerivation ({
name = "node-shell-${name}${if version == null then "" else "-${version}"}";
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/shell <<EOF
#! ${stdenv.shell} -e
$shellHook
exec ${stdenv.shell}
EOF
chmod +x $out/bin/shell
'';
# Provide the dependencies in a development shell through the NODE_PATH environment variable
inherit nodeDependencies;
shellHook = lib.optionalString (dependencies != []) ''
export NODE_PATH=${nodeDependencies}/lib/node_modules
export PATH="${nodeDependencies}/bin:$PATH"
'';
} // extraArgs);
in
{
buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
buildNodePackage = lib.makeOverridable buildNodePackage;
buildNodeDependencies = lib.makeOverridable buildNodeDependencies;
buildNodeShell = lib.makeOverridable buildNodeShell;
}

View File

@@ -0,0 +1,719 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? []}:
let
sources = {
"@sindresorhus/is-4.6.0" = {
name = "_at_sindresorhus_slash_is";
packageName = "@sindresorhus/is";
version = "4.6.0";
src = fetchurl {
url = "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz";
sha512 = "t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==";
};
};
"@szmarczak/http-timer-4.0.6" = {
name = "_at_szmarczak_slash_http-timer";
packageName = "@szmarczak/http-timer";
version = "4.0.6";
src = fetchurl {
url = "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz";
sha512 = "4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==";
};
};
"@types/cacheable-request-6.0.3" = {
name = "_at_types_slash_cacheable-request";
packageName = "@types/cacheable-request";
version = "6.0.3";
src = fetchurl {
url = "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz";
sha512 = "IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==";
};
};
"@types/http-cache-semantics-4.0.1" = {
name = "_at_types_slash_http-cache-semantics";
packageName = "@types/http-cache-semantics";
version = "4.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz";
sha512 = "SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==";
};
};
"@types/keyv-3.1.4" = {
name = "_at_types_slash_keyv";
packageName = "@types/keyv";
version = "3.1.4";
src = fetchurl {
url = "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz";
sha512 = "BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==";
};
};
"@types/node-13.13.52" = {
name = "_at_types_slash_node";
packageName = "@types/node";
version = "13.13.52";
src = fetchurl {
url = "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz";
sha512 = "s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==";
};
};
"@types/node-18.16.1" = {
name = "_at_types_slash_node";
packageName = "@types/node";
version = "18.16.1";
src = fetchurl {
url = "https://registry.npmjs.org/@types/node/-/node-18.16.1.tgz";
sha512 = "DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA==";
};
};
"@types/responselike-1.0.0" = {
name = "_at_types_slash_responselike";
packageName = "@types/responselike";
version = "1.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz";
sha512 = "85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==";
};
};
"ansi-regex-3.0.1" = {
name = "ansi-regex";
packageName = "ansi-regex";
version = "3.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz";
sha512 = "+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==";
};
};
"ansi-styles-3.2.1" = {
name = "ansi-styles";
packageName = "ansi-styles";
version = "3.2.1";
src = fetchurl {
url = "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz";
sha512 = "VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==";
};
};
"ansi-styles-4.3.0" = {
name = "ansi-styles";
packageName = "ansi-styles";
version = "4.3.0";
src = fetchurl {
url = "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz";
sha512 = "zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==";
};
};
"asn1-0.2.6" = {
name = "asn1";
packageName = "asn1";
version = "0.2.6";
src = fetchurl {
url = "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz";
sha512 = "ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==";
};
};
"at-least-node-1.0.0" = {
name = "at-least-node";
packageName = "at-least-node";
version = "1.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz";
sha512 = "+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==";
};
};
"cacheable-lookup-5.0.4" = {
name = "cacheable-lookup";
packageName = "cacheable-lookup";
version = "5.0.4";
src = fetchurl {
url = "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz";
sha512 = "2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==";
};
};
"cacheable-request-7.0.2" = {
name = "cacheable-request";
packageName = "cacheable-request";
version = "7.0.2";
src = fetchurl {
url = "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz";
sha512 = "pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==";
};
};
"chalk-2.4.2" = {
name = "chalk";
packageName = "chalk";
version = "2.4.2";
src = fetchurl {
url = "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz";
sha512 = "Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==";
};
};
"chalk-4.1.2" = {
name = "chalk";
packageName = "chalk";
version = "4.1.2";
src = fetchurl {
url = "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz";
sha512 = "oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==";
};
};
"clime-0.5.14" = {
name = "clime";
packageName = "clime";
version = "0.5.14";
src = fetchurl {
url = "https://registry.npmjs.org/clime/-/clime-0.5.14.tgz";
sha512 = "+q7UDQ+EcruHtZRtd2QVs+t/jf9MpuOyhHbuHcYWvjX8jdly6AU7z3/7MiI0Kj0hzueIEX9JM7vPnkzBrG082Q==";
};
};
"clone-response-1.0.3" = {
name = "clone-response";
packageName = "clone-response";
version = "1.0.3";
src = fetchurl {
url = "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz";
sha512 = "ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==";
};
};
"color-convert-1.9.3" = {
name = "color-convert";
packageName = "color-convert";
version = "1.9.3";
src = fetchurl {
url = "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz";
sha512 = "QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==";
};
};
"color-convert-2.0.1" = {
name = "color-convert";
packageName = "color-convert";
version = "2.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz";
sha512 = "RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==";
};
};
"color-name-1.1.3" = {
name = "color-name";
packageName = "color-name";
version = "1.1.3";
src = fetchurl {
url = "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz";
sha512 = "72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==";
};
};
"color-name-1.1.4" = {
name = "color-name";
packageName = "color-name";
version = "1.1.4";
src = fetchurl {
url = "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz";
sha512 = "dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==";
};
};
"debug-4.3.4" = {
name = "debug";
packageName = "debug";
version = "4.3.4";
src = fetchurl {
url = "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz";
sha512 = "PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==";
};
};
"decompress-response-6.0.0" = {
name = "decompress-response";
packageName = "decompress-response";
version = "6.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz";
sha512 = "aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==";
};
};
"defer-to-connect-2.0.1" = {
name = "defer-to-connect";
packageName = "defer-to-connect";
version = "2.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz";
sha512 = "4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==";
};
};
"define-lazy-prop-2.0.0" = {
name = "define-lazy-prop";
packageName = "define-lazy-prop";
version = "2.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz";
sha512 = "Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==";
};
};
"end-of-stream-1.4.4" = {
name = "end-of-stream";
packageName = "end-of-stream";
version = "1.4.4";
src = fetchurl {
url = "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz";
sha512 = "+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==";
};
};
"escape-string-regexp-1.0.5" = {
name = "escape-string-regexp";
packageName = "escape-string-regexp";
version = "1.0.5";
src = fetchurl {
url = "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz";
sha512 = "vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==";
};
};
"extendable-error-0.1.7" = {
name = "extendable-error";
packageName = "extendable-error";
version = "0.1.7";
src = fetchurl {
url = "https://registry.npmjs.org/extendable-error/-/extendable-error-0.1.7.tgz";
sha512 = "UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==";
};
};
"fs-extra-9.1.0" = {
name = "fs-extra";
packageName = "fs-extra";
version = "9.1.0";
src = fetchurl {
url = "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz";
sha512 = "hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==";
};
};
"get-stream-5.2.0" = {
name = "get-stream";
packageName = "get-stream";
version = "5.2.0";
src = fetchurl {
url = "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz";
sha512 = "nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==";
};
};
"got-11.8.6" = {
name = "got";
packageName = "got";
version = "11.8.6";
src = fetchurl {
url = "https://registry.npmjs.org/got/-/got-11.8.6.tgz";
sha512 = "6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==";
};
};
"graceful-fs-4.2.11" = {
name = "graceful-fs";
packageName = "graceful-fs";
version = "4.2.11";
src = fetchurl {
url = "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz";
sha512 = "RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==";
};
};
"has-flag-3.0.0" = {
name = "has-flag";
packageName = "has-flag";
version = "3.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz";
sha512 = "sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==";
};
};
"has-flag-4.0.0" = {
name = "has-flag";
packageName = "has-flag";
version = "4.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz";
sha512 = "EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==";
};
};
"http-cache-semantics-4.1.1" = {
name = "http-cache-semantics";
packageName = "http-cache-semantics";
version = "4.1.1";
src = fetchurl {
url = "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz";
sha512 = "er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==";
};
};
"http2-wrapper-1.0.3" = {
name = "http2-wrapper";
packageName = "http2-wrapper";
version = "1.0.3";
src = fetchurl {
url = "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz";
sha512 = "V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==";
};
};
"hyphenate-0.2.5" = {
name = "hyphenate";
packageName = "hyphenate";
version = "0.2.5";
src = fetchurl {
url = "https://registry.npmjs.org/hyphenate/-/hyphenate-0.2.5.tgz";
sha512 = "mSY0+dVLWFq7iIUgiID3EWo5S8rLnZa595mcuWiN8di91n6eL+WS8HKmcpiZZIX7iElri0a/2hOYpwzldsY4gQ==";
};
};
"is-docker-2.2.1" = {
name = "is-docker";
packageName = "is-docker";
version = "2.2.1";
src = fetchurl {
url = "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz";
sha512 = "F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==";
};
};
"is-wsl-2.2.0" = {
name = "is-wsl";
packageName = "is-wsl";
version = "2.2.0";
src = fetchurl {
url = "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz";
sha512 = "fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==";
};
};
"ix-4.6.1" = {
name = "ix";
packageName = "ix";
version = "4.6.1";
src = fetchurl {
url = "https://registry.npmjs.org/ix/-/ix-4.6.1.tgz";
sha512 = "W4aSy2cJxEgPgtr7aNOPNp/gobmWxoNUrMqH4Wowc80FFX71kqtnGMsJnIPiVN9c5tlVbOUNzjhhKcuYxsL1qQ==";
};
};
"json-buffer-3.0.1" = {
name = "json-buffer";
packageName = "json-buffer";
version = "3.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz";
sha512 = "4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==";
};
};
"jsonfile-6.1.0" = {
name = "jsonfile";
packageName = "jsonfile";
version = "6.1.0";
src = fetchurl {
url = "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz";
sha512 = "5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==";
};
};
"keyv-4.5.2" = {
name = "keyv";
packageName = "keyv";
version = "4.5.2";
src = fetchurl {
url = "https://registry.npmjs.org/keyv/-/keyv-4.5.2.tgz";
sha512 = "5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g==";
};
};
"lowercase-keys-2.0.0" = {
name = "lowercase-keys";
packageName = "lowercase-keys";
version = "2.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz";
sha512 = "tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==";
};
};
"mimic-response-1.0.1" = {
name = "mimic-response";
packageName = "mimic-response";
version = "1.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz";
sha512 = "j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==";
};
};
"mimic-response-3.1.0" = {
name = "mimic-response";
packageName = "mimic-response";
version = "3.1.0";
src = fetchurl {
url = "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz";
sha512 = "z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==";
};
};
"ms-2.1.2" = {
name = "ms";
packageName = "ms";
version = "2.1.2";
src = fetchurl {
url = "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz";
sha512 = "sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==";
};
};
"node-rsa-1.1.1" = {
name = "node-rsa";
packageName = "node-rsa";
version = "1.1.1";
src = fetchurl {
url = "https://registry.npmjs.org/node-rsa/-/node-rsa-1.1.1.tgz";
sha512 = "Jd4cvbJMryN21r5HgxQOpMEqv+ooke/korixNNK3mGqfGJmy0M77WDDzo/05969+OkMy3XW1UuZsSmW9KQm7Fw==";
};
};
"normalize-url-6.1.0" = {
name = "normalize-url";
packageName = "normalize-url";
version = "6.1.0";
src = fetchurl {
url = "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz";
sha512 = "DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==";
};
};
"once-1.4.0" = {
name = "once";
packageName = "once";
version = "1.4.0";
src = fetchurl {
url = "https://registry.npmjs.org/once/-/once-1.4.0.tgz";
sha512 = "lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==";
};
};
"open-8.4.2" = {
name = "open";
packageName = "open";
version = "8.4.2";
src = fetchurl {
url = "https://registry.npmjs.org/open/-/open-8.4.2.tgz";
sha512 = "7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==";
};
};
"p-cancelable-2.1.1" = {
name = "p-cancelable";
packageName = "p-cancelable";
version = "2.1.1";
src = fetchurl {
url = "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz";
sha512 = "BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==";
};
};
"parse-messy-time-2.1.0" = {
name = "parse-messy-time";
packageName = "parse-messy-time";
version = "2.1.0";
src = fetchurl {
url = "https://registry.npmjs.org/parse-messy-time/-/parse-messy-time-2.1.0.tgz";
sha512 = "zErlfRLhoiJpCYLdEwTXU9bBwc750TK70TzjUA5h0vfLGw3595tj4Dl2LMoUTrEmFWZwtaIcJ/FjGIVv7nx/HA==";
};
};
"pump-3.0.0" = {
name = "pump";
packageName = "pump";
version = "3.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz";
sha512 = "LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==";
};
};
"quick-lru-5.1.1" = {
name = "quick-lru";
packageName = "quick-lru";
version = "5.1.1";
src = fetchurl {
url = "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz";
sha512 = "WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==";
};
};
"reflect-metadata-0.1.13" = {
name = "reflect-metadata";
packageName = "reflect-metadata";
version = "0.1.13";
src = fetchurl {
url = "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz";
sha512 = "Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==";
};
};
"resolve-alpn-1.2.1" = {
name = "resolve-alpn";
packageName = "resolve-alpn";
version = "1.2.1";
src = fetchurl {
url = "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz";
sha512 = "0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==";
};
};
"responselike-2.0.1" = {
name = "responselike";
packageName = "responselike";
version = "2.0.1";
src = fetchurl {
url = "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz";
sha512 = "4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==";
};
};
"safer-buffer-2.1.2" = {
name = "safer-buffer";
packageName = "safer-buffer";
version = "2.1.2";
src = fetchurl {
url = "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz";
sha512 = "YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==";
};
};
"strip-ansi-4.0.0" = {
name = "strip-ansi";
packageName = "strip-ansi";
version = "4.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz";
sha512 = "4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==";
};
};
"supports-color-5.5.0" = {
name = "supports-color";
packageName = "supports-color";
version = "5.5.0";
src = fetchurl {
url = "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz";
sha512 = "QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==";
};
};
"supports-color-7.2.0" = {
name = "supports-color";
packageName = "supports-color";
version = "7.2.0";
src = fetchurl {
url = "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz";
sha512 = "qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==";
};
};
"tslib-2.5.0" = {
name = "tslib";
packageName = "tslib";
version = "2.5.0";
src = fetchurl {
url = "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz";
sha512 = "336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==";
};
};
"universalify-2.0.0" = {
name = "universalify";
packageName = "universalify";
version = "2.0.0";
src = fetchurl {
url = "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz";
sha512 = "hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==";
};
};
"villa-0.2.11" = {
name = "villa";
packageName = "villa";
version = "0.2.11";
src = fetchurl {
url = "https://registry.npmjs.org/villa/-/villa-0.2.11.tgz";
sha512 = "ZDQx/lhi8F2FdHWvjv5Ig+VbxPvNROHM11C+RSogiUF69amUhCLoGOYPzj/YhCv8pEUbH3ybasqNPjU4498elQ==";
};
};
"wrappy-1.0.2" = {
name = "wrappy";
packageName = "wrappy";
version = "1.0.2";
src = fetchurl {
url = "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz";
sha512 = "l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==";
};
};
};
in
{
playactor = nodeEnv.buildNodePackage {
name = "playactor";
packageName = "playactor";
version = "0.4.1";
src = fetchurl {
url = "https://registry.npmjs.org/playactor/-/playactor-0.4.1.tgz";
sha512 = "3uNLv5SWeg3dKTSQaP/SOnhUbaGOaENzZd9fJ8RbqKdNmF3TMvAU2s+jd3gH5nErAOxO9KcdLZ9YRMoXomsUSQ==";
};
dependencies = [
sources."@sindresorhus/is-4.6.0"
sources."@szmarczak/http-timer-4.0.6"
sources."@types/cacheable-request-6.0.3"
sources."@types/http-cache-semantics-4.0.1"
sources."@types/keyv-3.1.4"
sources."@types/node-18.16.1"
sources."@types/responselike-1.0.0"
sources."ansi-regex-3.0.1"
sources."ansi-styles-4.3.0"
sources."asn1-0.2.6"
sources."at-least-node-1.0.0"
sources."cacheable-lookup-5.0.4"
sources."cacheable-request-7.0.2"
sources."chalk-4.1.2"
(sources."clime-0.5.14" // {
dependencies = [
sources."ansi-styles-3.2.1"
sources."chalk-2.4.2"
sources."color-convert-1.9.3"
sources."color-name-1.1.3"
sources."has-flag-3.0.0"
sources."supports-color-5.5.0"
];
})
sources."clone-response-1.0.3"
sources."color-convert-2.0.1"
sources."color-name-1.1.4"
sources."debug-4.3.4"
(sources."decompress-response-6.0.0" // {
dependencies = [
sources."mimic-response-3.1.0"
];
})
sources."defer-to-connect-2.0.1"
sources."define-lazy-prop-2.0.0"
sources."end-of-stream-1.4.4"
sources."escape-string-regexp-1.0.5"
sources."extendable-error-0.1.7"
sources."fs-extra-9.1.0"
sources."get-stream-5.2.0"
sources."got-11.8.6"
sources."graceful-fs-4.2.11"
sources."has-flag-4.0.0"
sources."http-cache-semantics-4.1.1"
sources."http2-wrapper-1.0.3"
sources."hyphenate-0.2.5"
sources."is-docker-2.2.1"
sources."is-wsl-2.2.0"
(sources."ix-4.6.1" // {
dependencies = [
sources."@types/node-13.13.52"
];
})
sources."json-buffer-3.0.1"
sources."jsonfile-6.1.0"
sources."keyv-4.5.2"
sources."lowercase-keys-2.0.0"
sources."mimic-response-1.0.1"
sources."ms-2.1.2"
sources."node-rsa-1.1.1"
sources."normalize-url-6.1.0"
sources."once-1.4.0"
sources."open-8.4.2"
sources."p-cancelable-2.1.1"
sources."parse-messy-time-2.1.0"
sources."pump-3.0.0"
sources."quick-lru-5.1.1"
sources."reflect-metadata-0.1.13"
sources."resolve-alpn-1.2.1"
sources."responselike-2.0.1"
sources."safer-buffer-2.1.2"
sources."strip-ansi-4.0.0"
sources."supports-color-7.2.0"
sources."tslib-2.5.0"
sources."universalify-2.0.0"
sources."villa-0.2.11"
sources."wrappy-1.0.2"
];
buildInputs = globalBuildInputs;
meta = {
description = "play around with your playstation devices";
homepage = "https://github.com/dhleong/playactor#readme";
license = "ISC";
};
production = true;
bypassCache = true;
reconstructLock = true;
};
}

View File

@@ -0,0 +1,12 @@
{ buildPythonPackage, fetchPypi }:
buildPythonPackage rec {
pname = "pyelectroluxconnect";
version = "0.3.12";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-g9UxkWuTIqJe0/CDk3kwU3dSmc+GXlfDMxdzu6CqyY0=";
};
doCheck = false;
}

View File

@@ -0,0 +1,17 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-14_x"}:
let
nodeEnv = import ./node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}

View File

@@ -0,0 +1,686 @@
# This file originates from node2nix
{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}:
let
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
utillinux = if pkgs ? utillinux then pkgs.utillinux else pkgs.util-linux;
python = if nodejs ? python then nodejs.python else python2;
# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
tarWrapper = runCommand "tarWrapper" {} ''
mkdir -p $out/bin
cat > $out/bin/tar <<EOF
#! ${stdenv.shell} -e
$(type -p tar) "\$@" --warning=no-unknown-keyword --delay-directory-restore
EOF
chmod +x $out/bin/tar
'';
# Function that generates a TGZ file from a NPM project
buildNodeSourceDist =
{ name, version, src, ... }:
stdenv.mkDerivation {
name = "node-tarball-${name}-${version}";
inherit src;
buildInputs = [ nodejs ];
buildPhase = ''
export HOME=$TMPDIR
tgzFile=$(npm pack | tail -n 1) # Hooks to the pack command will add output (https://docs.npmjs.com/misc/scripts)
'';
installPhase = ''
mkdir -p $out/tarballs
mv $tgzFile $out/tarballs
mkdir -p $out/nix-support
echo "file source-dist $out/tarballs/$tgzFile" >> $out/nix-support/hydra-build-products
'';
};
# Common shell logic
installPackage = writeShellScript "install-package" ''
installPackage() {
local packageName=$1 src=$2
local strippedName
local DIR=$PWD
cd $TMPDIR
unpackFile $src
# Make the base dir in which the target dependency resides first
mkdir -p "$(dirname "$DIR/$packageName")"
if [ -f "$src" ]
then
# Figure out what directory has been unpacked
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
# Restore write permissions to make building work
find "$packageDir" -type d -exec chmod u+x {} \;
chmod -R u+w "$packageDir"
# Move the extracted tarball into the output folder
mv "$packageDir" "$DIR/$packageName"
elif [ -d "$src" ]
then
# Get a stripped name (without hash) of the source directory.
# On old nixpkgs it's already set internally.
if [ -z "$strippedName" ]
then
strippedName="$(stripHash $src)"
fi
# Restore write permissions to make building work
chmod -R u+w "$strippedName"
# Move the extracted directory into the output folder
mv "$strippedName" "$DIR/$packageName"
fi
# Change to the package directory to install dependencies
cd "$DIR/$packageName"
}
'';
# Bundle the dependencies of the package
#
# Only include dependencies if they don't exist. They may also be bundled in the package.
includeDependencies = {dependencies}:
lib.optionalString (dependencies != []) (
''
mkdir -p node_modules
cd node_modules
''
+ (lib.concatMapStrings (dependency:
''
if [ ! -e "${dependency.packageName}" ]; then
${composePackage dependency}
fi
''
) dependencies)
+ ''
cd ..
''
);
# Recursively composes the dependencies of a package
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
installPackage "${packageName}" "${src}"
${includeDependencies { inherit dependencies; }}
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
'';
pinpointDependencies = {dependencies, production}:
let
pinpointDependenciesFromPackageJSON = writeTextFile {
name = "pinpointDependencies.js";
text = ''
var fs = require('fs');
var path = require('path');
function resolveDependencyVersion(location, name) {
if(location == process.env['NIX_STORE']) {
return null;
} else {
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
if(fs.existsSync(dependencyPackageJSON)) {
var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
if(dependencyPackageObj.name == name) {
return dependencyPackageObj.version;
}
} else {
return resolveDependencyVersion(path.resolve(location, ".."), name);
}
}
}
function replaceDependencies(dependencies) {
if(typeof dependencies == "object" && dependencies !== null) {
for(var dependency in dependencies) {
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
if(resolvedVersion === null) {
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
} else {
dependencies[dependency] = resolvedVersion;
}
}
}
}
/* Read the package.json configuration */
var packageObj = JSON.parse(fs.readFileSync('./package.json'));
/* Pinpoint all dependencies */
replaceDependencies(packageObj.dependencies);
if(process.argv[2] == "development") {
replaceDependencies(packageObj.devDependencies);
}
else {
packageObj.devDependencies = {};
}
replaceDependencies(packageObj.optionalDependencies);
replaceDependencies(packageObj.peerDependencies);
/* Write the fixed package.json file */
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
'';
};
in
''
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
${lib.optionalString (dependencies != [])
''
if [ -d node_modules ]
then
cd node_modules
${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
cd ..
fi
''}
'';
# Recursively traverses all dependencies of a package and pinpoints all
# dependencies in the package.json file to the versions that are actually
# being used.
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
''
if [ -d "${packageName}" ]
then
cd "${packageName}"
${pinpointDependencies { inherit dependencies production; }}
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
fi
'';
# Extract the Node.js source code which is used to compile packages with
# native bindings
nodeSources = runCommand "node-sources" {} ''
tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
mv node-* $out
'';
# Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty)
addIntegrityFieldsScript = writeTextFile {
name = "addintegrityfields.js";
text = ''
var fs = require('fs');
var path = require('path');
function augmentDependencies(baseDir, dependencies) {
for(var dependencyName in dependencies) {
var dependency = dependencies[dependencyName];
// Open package.json and augment metadata fields
var packageJSONDir = path.join(baseDir, "node_modules", dependencyName);
var packageJSONPath = path.join(packageJSONDir, "package.json");
if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored
console.log("Adding metadata fields to: "+packageJSONPath);
var packageObj = JSON.parse(fs.readFileSync(packageJSONPath));
if(dependency.integrity) {
packageObj["_integrity"] = dependency.integrity;
} else {
packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
}
if(dependency.resolved) {
packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided
} else {
packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
}
if(dependency.from !== undefined) { // Adopt from property if one has been provided
packageObj["_from"] = dependency.from;
}
fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
}
// Augment transitive dependencies
if(dependency.dependencies !== undefined) {
augmentDependencies(packageJSONDir, dependency.dependencies);
}
}
}
if(fs.existsSync("./package-lock.json")) {
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
if(![1, 2].includes(packageLock.lockfileVersion)) {
process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n");
process.exit(1);
}
if(packageLock.dependencies !== undefined) {
augmentDependencies(".", packageLock.dependencies);
}
}
'';
};
# Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
reconstructPackageLock = writeTextFile {
name = "reconstructpackagelock.js";
text = ''
var fs = require('fs');
var path = require('path');
var packageObj = JSON.parse(fs.readFileSync("package.json"));
var lockObj = {
name: packageObj.name,
version: packageObj.version,
lockfileVersion: 2,
requires: true,
packages: {
"": {
name: packageObj.name,
version: packageObj.version,
license: packageObj.license,
bin: packageObj.bin,
dependencies: packageObj.dependencies,
engines: packageObj.engines,
optionalDependencies: packageObj.optionalDependencies
}
},
dependencies: {}
};
function augmentPackageJSON(filePath, packages, dependencies) {
var packageJSON = path.join(filePath, "package.json");
if(fs.existsSync(packageJSON)) {
var packageObj = JSON.parse(fs.readFileSync(packageJSON));
packages[filePath] = {
version: packageObj.version,
integrity: "sha1-000000000000000000000000000=",
dependencies: packageObj.dependencies,
engines: packageObj.engines,
optionalDependencies: packageObj.optionalDependencies
};
dependencies[packageObj.name] = {
version: packageObj.version,
integrity: "sha1-000000000000000000000000000=",
dependencies: {}
};
processDependencies(path.join(filePath, "node_modules"), packages, dependencies[packageObj.name].dependencies);
}
}
function processDependencies(dir, packages, dependencies) {
if(fs.existsSync(dir)) {
var files = fs.readdirSync(dir);
files.forEach(function(entry) {
var filePath = path.join(dir, entry);
var stats = fs.statSync(filePath);
if(stats.isDirectory()) {
if(entry.substr(0, 1) == "@") {
// When we encounter a namespace folder, augment all packages belonging to the scope
var pkgFiles = fs.readdirSync(filePath);
pkgFiles.forEach(function(entry) {
if(stats.isDirectory()) {
var pkgFilePath = path.join(filePath, entry);
augmentPackageJSON(pkgFilePath, packages, dependencies);
}
});
} else {
augmentPackageJSON(filePath, packages, dependencies);
}
}
});
}
}
processDependencies("node_modules", lockObj.packages, lockObj.dependencies);
fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2));
'';
};
# Script that links bins defined in package.json to the node_modules bin directory
# NPM does not do this for top-level packages itself anymore as of v7
linkBinsScript = writeTextFile {
name = "linkbins.js";
text = ''
var fs = require('fs');
var path = require('path');
var packageObj = JSON.parse(fs.readFileSync("package.json"));
var nodeModules = Array(packageObj.name.split("/").length).fill("..").join(path.sep);
if(packageObj.bin !== undefined) {
fs.mkdirSync(path.join(nodeModules, ".bin"))
if(typeof packageObj.bin == "object") {
Object.keys(packageObj.bin).forEach(function(exe) {
if(fs.existsSync(packageObj.bin[exe])) {
console.log("linking bin '" + exe + "'");
fs.symlinkSync(
path.join("..", packageObj.name, packageObj.bin[exe]),
path.join(nodeModules, ".bin", exe)
);
}
else {
console.log("skipping non-existent bin '" + exe + "'");
}
})
}
else {
if(fs.existsSync(packageObj.bin)) {
console.log("linking bin '" + packageObj.bin + "'");
fs.symlinkSync(
path.join("..", packageObj.name, packageObj.bin),
path.join(nodeModules, ".bin", packageObj.name.split("/").pop())
);
}
else {
console.log("skipping non-existent bin '" + packageObj.bin + "'");
}
}
}
else if(packageObj.directories !== undefined && packageObj.directories.bin !== undefined) {
fs.mkdirSync(path.join(nodeModules, ".bin"))
fs.readdirSync(packageObj.directories.bin).forEach(function(exe) {
if(fs.existsSync(path.join(packageObj.directories.bin, exe))) {
console.log("linking bin '" + exe + "'");
fs.symlinkSync(
path.join("..", packageObj.name, packageObj.directories.bin, exe),
path.join(nodeModules, ".bin", exe)
);
}
else {
console.log("skipping non-existent bin '" + exe + "'");
}
})
}
'';
};
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
let
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
in
''
# Pinpoint the versions of all dependencies to the ones that are actually being used
echo "pinpointing versions of dependencies..."
source $pinpointDependenciesScriptPath
# Patch the shebangs of the bundled modules to prevent them from
# calling executables outside the Nix store as much as possible
patchShebangs .
# Deploy the Node.js package by running npm install. Since the
# dependencies have been provided already by ourselves, it should not
# attempt to install them again, which is good, because we want to make
# it Nix's responsibility. If it needs to install any dependencies
# anyway (e.g. because the dependency parameters are
# incomplete/incorrect), it fails.
#
# The other responsibilities of NPM are kept -- version checks, build
# steps, postprocessing etc.
export HOME=$TMPDIR
cd "${packageName}"
runHook preRebuild
${lib.optionalString bypassCache ''
${lib.optionalString reconstructLock ''
if [ -f package-lock.json ]
then
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
rm package-lock.json
else
echo "No package-lock.json file found, reconstructing..."
fi
node ${reconstructPackageLock}
''}
node ${addIntegrityFieldsScript}
''}
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
runHook postRebuild
if [ "''${dontNpmInstall-}" != "1" ]
then
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
rm -f npm-shrinkwrap.json
npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install
fi
# Link executables defined in package.json
node ${linkBinsScript}
'';
# Builds and composes an NPM package including all its dependencies
buildNodePackage =
{ name
, packageName
, version ? null
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, preRebuild ? ""
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, meta ? {}
, ... }@args:
let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
in
stdenv.mkDerivation ({
name = "${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
inherit nodejs;
inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall preRebuild unpackPhase buildPhase;
compositionScript = composePackage args;
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
installPhase = ''
source ${installPackage}
# Create and enter a root node_modules/ folder
mkdir -p $out/lib/node_modules
cd $out/lib/node_modules
# Compose the package and all its dependencies
source $compositionScriptPath
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
# Create symlink to the deployed executable folder, if applicable
if [ -d "$out/lib/node_modules/.bin" ]
then
ln -s $out/lib/node_modules/.bin $out/bin
# Patch the shebang lines of all the executables
ls $out/bin/* | while read i
do
file="$(readlink -f "$i")"
chmod u+rwx "$file"
patchShebangs "$file"
done
fi
# Create symlinks to the deployed manual page folders, if applicable
if [ -d "$out/lib/node_modules/${packageName}/man" ]
then
mkdir -p $out/share
for dir in "$out/lib/node_modules/${packageName}/man/"*
do
mkdir -p $out/share/man/$(basename "$dir")
for page in "$dir"/*
do
ln -s $page $out/share/man/$(basename "$dir")
done
done
fi
# Run post install hook, if provided
runHook postInstall
'';
meta = {
# default to Node.js' platforms
platforms = nodejs.meta.platforms;
} // meta;
} // extraArgs);
# Builds a node environment (a node_modules folder and a set of binaries)
buildNodeDependencies =
{ name
, packageName
, version ? null
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:
let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
in
stdenv.mkDerivation ({
name = "node-dependencies-${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall unpackPhase buildPhase;
includeScript = includeDependencies { inherit dependencies; };
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
installPhase = ''
source ${installPackage}
mkdir -p $out/${packageName}
cd $out/${packageName}
source $includeScriptPath
# Create fake package.json to make the npm commands work properly
cp ${src}/package.json .
chmod 644 package.json
${lib.optionalString bypassCache ''
if [ -f ${src}/package-lock.json ]
then
cp ${src}/package-lock.json .
chmod 644 package-lock.json
fi
''}
# Go to the parent folder to make sure that all packages are pinpointed
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
# Expose the executables that were installed
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
mv ${packageName} lib
ln -s $out/lib/node_modules/.bin $out/bin
'';
} // extraArgs);
# Builds a development shell
buildNodeShell =
{ name
, packageName
, version ? null
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:
let
nodeDependencies = buildNodeDependencies args;
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "unpackPhase" "buildPhase" ];
in
stdenv.mkDerivation ({
name = "node-shell-${name}${if version == null then "" else "-${version}"}";
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/shell <<EOF
#! ${stdenv.shell} -e
$shellHook
exec ${stdenv.shell}
EOF
chmod +x $out/bin/shell
'';
# Provide the dependencies in a development shell through the NODE_PATH environment variable
inherit nodeDependencies;
shellHook = lib.optionalString (dependencies != []) ''
export NODE_PATH=${nodeDependencies}/lib/node_modules
export PATH="${nodeDependencies}/bin:$PATH"
'';
} // extraArgs);
in
{
buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
buildNodePackage = lib.makeOverridable buildNodePackage;
buildNodeDependencies = lib.makeOverridable buildNodeDependencies;
buildNodeShell = lib.makeOverridable buildNodeShell;
}

View File

@@ -0,0 +1,5 @@
[
{ "room-assistant" : "2.20.0" },
{ "@nuxt/opencollective" : "0.3.2" },
{ "canvas": "2.11.0" }
]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem}:
let
nodePackages = import ./default.nix {
inherit pkgs system;
};
in
nodePackages // {
"room-assistant-2.20.0" = nodePackages."room-assistant-2.20.0".override {
buildInputs = [
pkgs.pkgconfig
nodePackages."@nuxt/opencollective-0.3.2"
# nodePackages."canvas-2.11.0"
pkgs.bluez
pkgs.libudev-zero
pkgs.nodePackages.node-pre-gyp
pkgs.nodePackages.node-gyp
# canvas stuff
pkgs.cairo
pkgs.pango
pkgs.libpng
pkgs.libuuid
pkgs.libGL
# pkgs.libjpeg_original
pkgs.libjpeg
pkgs.giflib
# pkgs.librsvg
pkgs.netsurf.libsvgtiny
];
};
}

View File

@@ -0,0 +1,95 @@
{ lib, stdenv, fetchurl }:
let
generic = {
version, sha256,
eol ? false, extraVulnerabilities ? []
}: let
major = lib.versions.major version;
in stdenv.mkDerivation rec {
pname = "selfServicePassword";
inherit version;
src = fetchurl {
url = "https://github.com/ltb-project/self-service-password/archive/refs/tags/v${version}.tar.gz";
inherit sha256;
};
installPhase = ''
runHook preInstall
mkdir -p $out/
cp -R . $out/
runHook postInstall
'';
meta = with lib; {
description = "PHP application that allows users to change their password in an LDAP directory.";
homepage = "https://github.com/ltb-project/self-service-password";
license = licenses.agpl3Plus;
platforms = with platforms; unix;
};
};
in {
selfServicePassword = generic {
version = "1.5.2";
sha256 = "dcef404e6b715f16bda71381647af38052a67deef4d387312856596ef131e030";
};
systemd.services = {
# When upgrading the Nextcloud package, Nextcloud can report errors such as
# "The files of the app [all apps in /var/lib/nextcloud/apps] were not replaced correctly"
# Restarting phpfpm on Nextcloud package update fixes these issues (but this is a workaround).
phpfpm-selfservicepassword.restartTriggers = [ selfServicePassword ];
selfservicepassword-setup = let
c = cfg.config;
writePhpArrary = a: "[${concatMapStringsSep "," (val: ''"${toString val}"'') a}]";
overrideConfig = pkgs.writeText "config.inc.local.php" ''
<?php
$lang = "en";
$allowed_lang = array("en", "de");
$show_menu = true;
$header_name_preset_login = "Auth-User";
'';
in {
wantedBy = [ "multi-user.target" ];
before = [ "phpfpm-selfservicepassword.service" ];
script = ''
ln -sf ${overrideConfig} ${datadir}/config/override.config.php
'';
serviceConfig.Type = "oneshot";
serviceConfig.User = "selfservicepassword";
};
};
services.phpfpm = {
pools.selfServicePassword = {
user = "selfservicepassword";
group = "selfservicepassword";
phpPackage = phpPackage;
phpEnv = {
PATH = "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin";
};
settings = mapAttrs (name: mkDefault) {
"listen.owner" = config.services.nginx.user;
"listen.group" = config.services.nginx.group;
};
extraConfig = cfg.poolConfig;
};
};
users.users.selfservicepassword = {
home = "${cfg.home}";
group = "selfservicepassword";
isSystemUser = true;
};
users.groups.selfservicepassword.members = [ "selfservicepassword" config.services.nginx.user ];
services.nginx.enable = mkDefault true;
services.nginx.virtualHosts.${cfg.hostName} = {
root = cfg.package;
locations = {};
};
}

View File

@@ -0,0 +1,28 @@
{ stdenv
, makeWrapper
, rspamd
,
}:
stdenv.mkDerivation {
name = "sieve-rspamd-filter";
nativeBuildInputs = [ makeWrapper ];
src = ./src;
installPhase = ''
for sieve in $src/*.sieve; do
install -D "$sieve" "$out/share/sieve-rspamd-filter/$(basename $sieve)"
done
mkdir $out/bin
cat > $out/bin/learn-spam.sh <<'EOF'
#!/bin/sh
exec ${rspamd}/bin/rspamc -h /run/rspamd.sock learn_spam
EOF
cat > $out/bin/learn-ham.sh <<'EOF'
#!/bin/sh
exec ${rspamd}/bin/rspamc -h /run/rspamd.sock learn_ham
EOF
chmod +x $out/bin/*.sh
'';
}

View File

@@ -0,0 +1,5 @@
require ["fileinto"];
if header :is "X-Spam" "Yes" {
fileinto "Spam";
}

View File

@@ -0,0 +1,15 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "learn-ham.sh" [ "${username}" ];

View File

@@ -0,0 +1,7 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "learn-spam.sh" [ "${username}" ];

205
utils/pkgs/thunderbird.nix Normal file
View File

@@ -0,0 +1,205 @@
# Update instructions:
#
# To update `thunderbird-bin`'s `release_sources.nix`, run from the nixpkgs root:
#
# nix-shell maintainers/scripts/update.nix --argstr package pkgs.thunderbird-bin-unwrapped
{ lib, stdenv, fetchurl, config, wrapGAppsHook
, alsa-lib
, atk
, cairo
, curl
, cups
, dbus-glib
, dbus
, fontconfig
, freetype
, gdk-pixbuf
, glib
, glibc
, gtk2
, gtk3
, libkrb5
, libX11
, libXScrnSaver
, libxcb
, libXcomposite
, libXcursor
, libXdamage
, libXext
, libXfixes
, libXi
, libXinerama
, libXrender
, libXrandr
, libXt
, libXtst
, libcanberra
, libnotify
, adwaita-icon-theme
, libGLU, libGL
, nspr
, nss_latest
, pango
, pipewire
, pciutils
, heimdal
, libpulseaudio
, systemd
, writeScript
, writeText
, xidel
, coreutils
, gnused
, gnugrep
, gnupg
, ffmpeg
, runtimeShell
, mesa # thunderbird wants gbm for drm+dmabuf
, systemLocale ? config.i18n.defaultLocale or "en_US"
, generated
}:
let
mozillaPlatforms = {
i686-linux = "linux-i686";
x86_64-linux = "linux-x86_64";
};
policies = { DisableAppUpdate = true; } // config.thunderbird.policies or { };
policiesJson = writeText "thunderbird-policies.json" (builtins.toJSON { inherit policies; });
mozLocale =
if systemLocale == "ca_ES@valencia"
then "ca-valencia"
else lib.replaceStrings ["_"] ["-"] systemLocale;
version = "112.0b7";
in
with import <nixpkgs> {};
stdenv.mkDerivation {
pname = "thunderbird-bin";
inherit version;
src = fetchurl {
url = "https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/${version}/linux-x86_64/en-US/thunderbird-${version}.tar.bz2";
};
libPath = lib.makeLibraryPath
[ stdenv.cc.cc
alsa-lib
atk
cairo
curl
cups
dbus-glib
dbus
fontconfig
freetype
gdk-pixbuf
glib
glibc
gtk2
gtk3
libkrb5
mesa
libX11
libXScrnSaver
libXcomposite
libXcursor
libxcb
libXdamage
libXext
libXfixes
libXi
libXinerama
libXrender
libXrandr
libXt
libXtst
libcanberra
libnotify
libGLU libGL
nspr
nss_latest
pango
pipewire
pciutils
heimdal
libpulseaudio
systemd
ffmpeg
] + ":" + lib.makeSearchPathOutput "lib" "lib64" [
stdenv.cc.cc
];
inherit gtk3;
nativeBuildInputs = [ wrapGAppsHook ];
buildInputs = [ gtk3 adwaita-icon-theme ];
# "strip" after "patchelf" may break binaries.
# See: https://github.com/NixOS/patchelf/issues/10
dontStrip = true;
dontPatchELF = true;
patchPhase = ''
# Don't download updates from Mozilla directly
echo 'pref("app.update.auto", "false");' >> defaults/pref/channel-prefs.js
'';
# See "Note on GPG support" in `../thunderbird/default.nix` for explanations
# on adding `gnupg` and `gpgme` into PATH/LD_LIBRARY_PATH.
installPhase =
''
mkdir -p "$prefix/usr/lib/thunderbird-bin-${version}"
cp -r * "$prefix/usr/lib/thunderbird-bin-${version}"
mkdir -p "$out/bin"
ln -s "$prefix/usr/lib/thunderbird-bin-${version}/thunderbird" "$out/bin/"
for executable in \
thunderbird thunderbird-bin plugin-container \
updater crashreporter webapprt-stub
do
if [ -e "$out/usr/lib/thunderbird-bin-${version}/$executable" ]; then
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
"$out/usr/lib/thunderbird-bin-${version}/$executable"
fi
done
find . -executable -type f -exec \
patchelf --set-rpath "$libPath" \
"$out/usr/lib/thunderbird-bin-${version}/{}" \;
# wrapThunderbird expects "$out/lib" instead of "$out/usr/lib"
ln -s "$out/usr/lib" "$out/lib"
gappsWrapperArgs+=(--argv0 "$out/bin/.thunderbird-wrapped")
# See: https://github.com/mozilla/policy-templates/blob/master/README.md
mkdir -p "$out/lib/thunderbird-bin-${version}/distribution";
ln -s ${policiesJson} "$out/lib/thunderbird-bin-${version}/distribution/policies.json";
'';
passthru.updateScript = import ./../../browsers/firefox-bin/update.nix {
inherit writeScript xidel coreutils gnused gnugrep curl gnupg runtimeShell;
pname = "thunderbird-bin";
baseName = "thunderbird";
channel = "release";
basePath = "pkgs/applications/networking/mailreaders/thunderbird-bin";
baseUrl = "http://archive.mozilla.org/pub/thunderbird/releases/";
};
meta = with lib; {
changelog = "https://www.thunderbird.net/en-US/thunderbird/${version}/releasenotes/";
description = "Mozilla Thunderbird, a full-featured email client (binary package)";
homepage = "http://www.mozilla.org/thunderbird/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.mpl20;
maintainers = with lib.maintainers; [ lovesegfault ];
platforms = builtins.attrNames mozillaPlatforms;
hydraPlatforms = [ ];
};
}