Files
nix/packages/docker/shlink/default.nix
Nikolaos Karaolidis 09fbf7150c Use overlay
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-08-17 21:24:31 +03:00

84 lines
1.6 KiB
Nix

{ pkgs, ... }:
let
php = pkgs.php84.buildEnv {
extensions =
{ all, ... }:
with all;
[
curl
pdo
pdo_sqlite
pdo_pgsql
intl
gd
sockets
bcmath
filter
mbstring
zlib
];
extraConfig = ''
expose_php = Off
'';
};
shlink = pkgs.runCommandLocal "shlink" { } ''
mkdir -p $out/var/www
cp -r ${pkgs.shlink} $out/var/www/shlink
rr_config_path="$out/var/www/shlink/config/roadrunner/.rr.yml"
original_mode="$(stat -c "%a" "$rr_config_path")"
chmod u+w "$rr_config_path"
${pkgs.yq-go}/bin/yq -i '
.logs.channels.server.level = "warn" |
.logs.channels.jobs.level = "warn"
' "$rr_config_path"
chmod "$original_mode" "$rr_config_path"
'';
shlink-cli = pkgs.writeShellApplication {
name = "shlink";
text = ''
exec /var/www/shlink/bin/cli "$@"
'';
};
entrypoint = pkgs.writeTextFile {
name = "entrypoint";
executable = true;
destination = "/bin/entrypoint";
text = builtins.readFile ./entrypoint.sh;
};
in
pkgs.dockerTools.buildImage {
name = "shlink";
fromImage = import ../base { inherit pkgs; };
copyToRoot = pkgs.buildEnv {
name = "root";
paths = with pkgs; [
entrypoint
shlink
shlink-cli
php
roadrunner
];
pathsToLink = [
"/bin"
"/var"
];
};
config = {
Entrypoint = [ "entrypoint" ];
ExposedPorts = {
"8080/tcp" = { };
};
WorkingDir = "/var/www/shlink";
Volumes = {
"/var/www/shlink/data" = { };
};
};
}