-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Including service options. Closes #341665.
- Loading branch information
Showing
7 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
config, | ||
lib, | ||
options, | ||
pkgs, | ||
... | ||
}: | ||
{ | ||
options.services.linkding = { | ||
dataDir = lib.mkOption { | ||
type = lib.types.str; | ||
default = "/etc/linkding/data"; | ||
description = "The directory where linkding stores its data files."; | ||
}; | ||
|
||
enable = lib.mkEnableOption "linkding service"; | ||
|
||
package = lib.mkPackageOption pkgs "linkding" { }; | ||
|
||
port = lib.mkOption { | ||
default = 9090; | ||
description = "Port on which linkding will listen for connections."; | ||
type = lib.types.port; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf config.services.linkding.enable { | ||
systemd.services.linkding = { | ||
description = "linkding"; | ||
|
||
environment = { | ||
LD_HOST_DATA_DIR = config.services.linkding.dataDir; | ||
LD_HOST_PORT = builtins.toString config.services.linkding.port; | ||
}; | ||
|
||
serviceConfig.ExecStart = "${config.services.linkding.package}/bin/linkding"; | ||
}; | ||
}; | ||
|
||
meta.maintainers = [ lib.maintainers.l0b0 ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ handleTest }: | ||
{ | ||
defaults = handleTest ./defaults.nix { }; | ||
overrides = handleTest ./overrides.nix { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import ../../make-test-python.nix ( | ||
{ lib, ... }: | ||
let | ||
nodeName = "server"; | ||
in | ||
{ | ||
name = "linkding-defaults"; | ||
|
||
nodes."${nodeName}" = { | ||
services.linkding.enable = true; | ||
}; | ||
|
||
testScript = '' | ||
${nodeName}.wait_for_unit("linkding.service") | ||
''; | ||
|
||
meta.maintainers = [ lib.maintainers.l0b0 ]; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ../../make-test-python.nix ( | ||
{ lib, ... }: | ||
let | ||
nodeName = "server"; | ||
in | ||
{ | ||
name = "linkding-overrides"; | ||
|
||
nodes."${nodeName}" = | ||
{ | ||
options, | ||
pkgs, | ||
... | ||
}: | ||
{ | ||
services.linkding = { | ||
dataDir = "/tmp/linkding"; | ||
enable = true; | ||
package = pkgs.linkding.overrideAttrs (_old: { | ||
name = "custom-linkding"; | ||
}); | ||
port = options.services.linkding.port.default + 1; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
${nodeName}.wait_for_unit("linkding.service") | ||
''; | ||
|
||
meta.maintainers = [ lib.maintainers.l0b0 ]; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
fetchFromGitHub, | ||
fetchNpmDeps, | ||
lib, | ||
nix-update-script, | ||
nixosTests, | ||
nodejs, | ||
npmHooks, | ||
pkgs, | ||
python3Packages, | ||
}: | ||
let | ||
pname = "linkding"; | ||
version = "1.36.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "sissbruecker"; | ||
repo = "linkding"; | ||
rev = "v${version}"; | ||
hash = "sha256-AePxd7uc1DvMwzhWluYIzXnFDlH/kiWNjBMzj/p68Mk="; | ||
}; | ||
in | ||
python3Packages.buildPythonApplication { | ||
inherit pname src version; | ||
|
||
npmDeps = fetchNpmDeps { | ||
inherit src; | ||
name = "${pname}-npm-deps"; | ||
hash = "sha256-BA7PurUcB5glgaBIpuZLPRSg3GDdi4CLniUjoa/32yc="; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
nodejs | ||
npmHooks.npmConfigHook | ||
python3Packages.beautifulsoup4 | ||
python3Packages.bleach-allowlist | ||
python3Packages.django-widget-tweaks | ||
python3Packages.djangorestframework | ||
python3Packages.huey | ||
python3Packages.markdown | ||
python3Packages.mozilla-django-oidc | ||
python3Packages.python-dateutil | ||
python3Packages.waybackpy | ||
]; | ||
|
||
build-system = [ | ||
python3Packages.setuptools | ||
]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
mkdir --parents data/{favicons,previews} dist | ||
npm run build | ||
python manage.py collectstatic | ||
runHook postBuild | ||
''; | ||
|
||
nativeCheckInputs = [ | ||
python3Packages.django-debug-toolbar | ||
python3Packages.playwright | ||
]; | ||
|
||
checkPhase = '' | ||
python manage.py test bookmarks.tests | ||
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers} | ||
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true | ||
python manage.py test bookmarks.e2e --pattern="e2e_test_*.py" | ||
''; | ||
|
||
passthru = { | ||
tests = { | ||
nixos = nixosTests.linkding; | ||
}; | ||
updateScript = nix-update-script { }; | ||
}; | ||
|
||
meta = with lib; { | ||
description = "Self-hosted bookmark manager"; | ||
homepage = "https://github.com/sissbruecker/linkding"; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [ l0b0 ]; | ||
}; | ||
} |