Compare commits
2 commits
953ded2042
...
edcd0a4ddf
Author | SHA1 | Date | |
---|---|---|---|
edcd0a4ddf | |||
c3319b9712 |
6 changed files with 13366 additions and 0 deletions
|
@ -39,6 +39,7 @@
|
||||||
nixosModules = {
|
nixosModules = {
|
||||||
reposilite = import ./modules/reposilite.nix;
|
reposilite = import ./modules/reposilite.nix;
|
||||||
asus-numpad = import ./modules/asus-numpad.nix self;
|
asus-numpad = import ./modules/asus-numpad.nix self;
|
||||||
|
shlink = import ./modules/shlink.nix self;
|
||||||
};
|
};
|
||||||
|
|
||||||
formatter = forEachSystem (system: (pkgsFor system).nixfmt-rfc-style);
|
formatter = forEachSystem (system: (pkgsFor system).nixfmt-rfc-style);
|
||||||
|
|
87
modules/shlink.nix
Normal file
87
modules/shlink.nix
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
self:
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.services.shlink;
|
||||||
|
inherit (pkgs.stdenv.hostPlatform) system;
|
||||||
|
|
||||||
|
basePath = "${cfg.package}/share/php/shlink";
|
||||||
|
|
||||||
|
vars = builtins.map (a: "--set ${a.name} ${a.value}") (lib.attrsToList cfg.environment);
|
||||||
|
varsStr = lib.concatStringsSep " " vars;
|
||||||
|
wrappedPkg = pkgs.symlinkJoin {
|
||||||
|
name = "shlink-wrapped";
|
||||||
|
paths = [ cfg.package ];
|
||||||
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
|
|
||||||
|
postBuild = ''
|
||||||
|
wrapProgram $out/bin/shlink ${varsStr}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.shlink = {
|
||||||
|
enable = lib.mkEnableOption "shlink";
|
||||||
|
package = lib.mkPackageOption self.packages.${system} "shlink" { };
|
||||||
|
roadrunnerPackage = lib.mkPackageOption pkgs "roadrunner" { };
|
||||||
|
|
||||||
|
environment = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.str;
|
||||||
|
default = { };
|
||||||
|
description = "Environment variables passed to the RoadRunner process";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = (cfg.environment.DB_DRIVER ? "sqlite") != "sqlite";
|
||||||
|
message = "sqlite is not supported. please set DB_DRIVER to one of the other supported values";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
environment.systemPackages = [ wrappedPkg ];
|
||||||
|
|
||||||
|
users = {
|
||||||
|
groups.shlink = { };
|
||||||
|
users.shlink = {
|
||||||
|
isSystemUser = true;
|
||||||
|
group = "shlink";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services."shlink" = {
|
||||||
|
wantedBy = [ "default.target" ];
|
||||||
|
path = [ cfg.package.php ];
|
||||||
|
environment = cfg.environment // {
|
||||||
|
SHLINK_RUNTIME = "nixos"; # writes logs to stderr instead of a file inside the nix store
|
||||||
|
};
|
||||||
|
|
||||||
|
preStart = ''
|
||||||
|
export SHELL_VERBOSITY=3
|
||||||
|
cd ${basePath}
|
||||||
|
php vendor/bin/shlink-installer init --no-interaction --clear-db-cache --skip-download-geolite
|
||||||
|
'';
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "notify";
|
||||||
|
|
||||||
|
ExecStart = "${lib.getExe cfg.roadrunnerPackage} serve -c ${basePath}/config/roadrunner/.rr.yml";
|
||||||
|
|
||||||
|
User = "shlink";
|
||||||
|
Group = "shlink";
|
||||||
|
|
||||||
|
StateDirectory = "shlink";
|
||||||
|
|
||||||
|
KillMode = "mixed";
|
||||||
|
TimeoutStopSec = 30;
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = 30;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -3,5 +3,6 @@ final: prev: {
|
||||||
enigma = prev.callPackage ./enigma.nix { };
|
enigma = prev.callPackage ./enigma.nix { };
|
||||||
jaspersoft-studio-community = prev.callPackage ./jaspersoft-studio-community.nix { };
|
jaspersoft-studio-community = prev.callPackage ./jaspersoft-studio-community.nix { };
|
||||||
openwebstart = prev.callPackage ./openwebstart.nix { };
|
openwebstart = prev.callPackage ./openwebstart.nix { };
|
||||||
|
shlink = prev.callPackage ./shlink/package.nix { };
|
||||||
vineflower = prev.callPackage ./vineflower.nix { };
|
vineflower = prev.callPackage ./vineflower.nix { };
|
||||||
}
|
}
|
||||||
|
|
13173
pkgs/shlink/composer.lock
generated
Normal file
13173
pkgs/shlink/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
61
pkgs/shlink/datadir.patch
Normal file
61
pkgs/shlink/datadir.patch
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php
|
||||||
|
index 0a99d323..c687688a 100644
|
||||||
|
--- a/config/autoload/dependencies.global.php
|
||||||
|
+++ b/config/autoload/dependencies.global.php
|
||||||
|
@@ -35,7 +35,7 @@ return [
|
||||||
|
],
|
||||||
|
|
||||||
|
'lazy_services' => [
|
||||||
|
- 'proxies_target_dir' => 'data/proxies',
|
||||||
|
+ 'proxies_target_dir' => '/var/lib/proxies',
|
||||||
|
'proxies_namespace' => 'ShlinkProxy',
|
||||||
|
'write_proxy_files' => EnvVars::isProdEnv(),
|
||||||
|
],
|
||||||
|
diff --git a/config/autoload/entity-manager.global.php b/config/autoload/entity-manager.global.php
|
||||||
|
index 1bd3db44..d00751e4 100644
|
||||||
|
--- a/config/autoload/entity-manager.global.php
|
||||||
|
+++ b/config/autoload/entity-manager.global.php
|
||||||
|
@@ -46,7 +46,7 @@ return (static function (): array {
|
||||||
|
$connection = match ($driver) {
|
||||||
|
null, 'sqlite' => [
|
||||||
|
'driver' => 'pdo_sqlite',
|
||||||
|
- 'path' => 'data/database.sqlite',
|
||||||
|
+ 'path' => '/var/lib/shlink/database.sqlite',
|
||||||
|
],
|
||||||
|
default => [
|
||||||
|
'driver' => $doctrineDriver,
|
||||||
|
@@ -65,7 +65,7 @@ return (static function (): array {
|
||||||
|
|
||||||
|
'entity_manager' => [
|
||||||
|
'orm' => [
|
||||||
|
- 'proxies_dir' => 'data/proxies',
|
||||||
|
+ 'proxies_dir' => '/var/lib/shlink/proxies',
|
||||||
|
'load_mappings_using_functional_style' => true,
|
||||||
|
'default_repository_classname' => EntitySpecificationRepository::class,
|
||||||
|
'listeners' => [
|
||||||
|
diff --git a/config/autoload/locks.global.php b/config/autoload/locks.global.php
|
||||||
|
index 28426c6a..0d70b20d 100644
|
||||||
|
--- a/config/autoload/locks.global.php
|
||||||
|
+++ b/config/autoload/locks.global.php
|
||||||
|
@@ -14,7 +14,7 @@ use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY;
|
||||||
|
return [
|
||||||
|
|
||||||
|
'locks' => [
|
||||||
|
- 'locks_dir' => __DIR__ . '/../../data/locks',
|
||||||
|
+ 'locks_dir' => '/tmp/shlink-data/locks',
|
||||||
|
],
|
||||||
|
|
||||||
|
'dependencies' => [
|
||||||
|
diff --git a/config/autoload/router.global.php b/config/autoload/router.global.php
|
||||||
|
index 0464ca83..20927475 100644
|
||||||
|
--- a/config/autoload/router.global.php
|
||||||
|
+++ b/config/autoload/router.global.php
|
||||||
|
@@ -14,7 +14,7 @@ return [
|
||||||
|
// Disabling config cache for cli, ensures it's never used for RoadRunner, and also that console
|
||||||
|
// commands don't generate a cache file that's then used by php-fpm web executions
|
||||||
|
FastRouteRouter::CONFIG_CACHE_ENABLED => EnvVars::isProdEnv() && PHP_SAPI !== 'cli',
|
||||||
|
- FastRouteRouter::CONFIG_CACHE_FILE => 'data/cache/fastroute_cached_routes.php',
|
||||||
|
+ FastRouteRouter::CONFIG_CACHE_FILE => '/var/lib/shlink/cache/fastroute_cached_routes.php',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
43
pkgs/shlink/package.nix
Normal file
43
pkgs/shlink/package.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
fetchFromGitHub,
|
||||||
|
makeWrapper,
|
||||||
|
php84,
|
||||||
|
}:
|
||||||
|
php84.buildComposerProject (finalAttrs: {
|
||||||
|
pname = "shlink";
|
||||||
|
version = "4.4.1";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "shlinkio";
|
||||||
|
repo = "shlink";
|
||||||
|
tag = "v${finalAttrs.version}";
|
||||||
|
hash = "sha256-7at90bmeJNQUh8tmIBpspSjMw7zaYqFNOfs8EIxOLUg=";
|
||||||
|
};
|
||||||
|
|
||||||
|
patches = [ ./datadir.patch ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
|
php = php84.withExtensions (
|
||||||
|
{ enabled, all }:
|
||||||
|
enabled
|
||||||
|
++ (with all; [
|
||||||
|
# json
|
||||||
|
curl
|
||||||
|
pdo
|
||||||
|
intl
|
||||||
|
gd
|
||||||
|
gmp
|
||||||
|
sockets
|
||||||
|
bcmath
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
composerLock = ./composer.lock;
|
||||||
|
vendorHash = "sha256-hQi+1JqL0t/SfBZQqrtQbIO46/MHLbfN3z4q06G6hfE=";
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
ln -s $out/share/php/shlink/bin/cli $out/bin/shlink
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue