-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fider: init at 0.24.0 #353346
Open
niklaskorz
wants to merge
2
commits into
NixOS:master
Choose a base branch
from
niklaskorz:init/fider
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+355
−0
Open
fider: init at 0.24.0 #353346
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,124 @@ | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
let | ||
cfg = config.services.fider; | ||
fiderCmd = lib.getExe cfg.package; | ||
in | ||
{ | ||
options = { | ||
|
||
services.fider = { | ||
enable = lib.mkEnableOption "the Fider server"; | ||
package = lib.mkPackageOption pkgs "fider" { }; | ||
|
||
dataDir = lib.mkOption { | ||
type = lib.types.str; | ||
default = "/var/lib/fider"; | ||
description = "Default data folder for Fider."; | ||
example = "/mnt/fider"; | ||
}; | ||
|
||
database = { | ||
url = lib.mkOption { | ||
type = lib.types.str; | ||
default = "local"; | ||
description = '' | ||
URI to use for the main PostgreSQL database. If this needs to include | ||
credentials that shouldn't be world-readable in the Nix store, set an | ||
environment file on the systemd service and override the | ||
`DATABASE_URL` entry. Pass the string | ||
`local` to setup a database on the local server. | ||
''; | ||
}; | ||
}; | ||
|
||
environment = lib.mkOption { | ||
type = lib.types.attrsOf lib.types.str; | ||
default = { }; | ||
example = { | ||
PORT = "31213"; | ||
BASE_URL = "https://fider.example.com"; | ||
EMAIL = "smtp"; | ||
EMAIL_NOREPLY = "[email protected]"; | ||
EMAIL_SMTP_USERNAME = "[email protected]"; | ||
EMAIL_SMTP_HOST = "mail.example.com"; | ||
EMAIL_SMTP_PORT = "587"; | ||
BLOB_STORAGE = "fs"; | ||
}; | ||
description = '' | ||
Environment variables to set for the service. Secrets should be | ||
specified using {option}`environmentFiles`. | ||
Refer to <https://github.com/getfider/fider/blob/stable/.example.env> | ||
and <https://github.com/getfider/fider/blob/stable/app/pkg/env/env.go> | ||
for available options. | ||
''; | ||
}; | ||
|
||
environmentFiles = lib.mkOption { | ||
type = lib.types.listOf lib.types.path; | ||
default = [ ]; | ||
example = "/run/secrets/fider.env"; | ||
description = '' | ||
Files to load environment variables from. Loaded variables override | ||
values set in {option}`environment`. | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
services.postgresql = lib.mkIf (cfg.database.url == "local") { | ||
enable = true; | ||
ensureUsers = [ | ||
{ | ||
name = "fider"; | ||
ensureDBOwnership = true; | ||
} | ||
]; | ||
ensureDatabases = [ "fider" ]; | ||
}; | ||
|
||
systemd.services.fider = { | ||
description = "Fider server"; | ||
wantedBy = [ "multi-user.target" ]; | ||
after = [ | ||
"network.target" | ||
] ++ lib.optionals (cfg.database.url == "local") [ "postgresql.service" ]; | ||
requires = lib.optionals (cfg.database.url == "local") [ "postgresql.service" ]; | ||
environment = | ||
let | ||
localPostgresqlUrl = "postgres:///fider?host=/run/postgresql"; | ||
in | ||
{ | ||
DATABASE_URL = if (cfg.database.url == "local") then localPostgresqlUrl else cfg.database.url; | ||
BLOB_STORAGE_FS_PATH = "${cfg.dataDir}"; | ||
} | ||
// cfg.environment; | ||
serviceConfig = { | ||
ExecStartPre = "${fiderCmd} migrate"; | ||
ExecStart = fiderCmd; | ||
StateDirectory = "fider"; | ||
DynamicUser = true; | ||
PrivateTmp = "yes"; | ||
Restart = "on-failure"; | ||
RuntimeDirectory = "fider"; | ||
RuntimeDirectoryPreserve = true; | ||
CacheDirectory = "fider"; | ||
WorkingDirectory = "${cfg.package}"; | ||
EnvironmentFile = cfg.environmentFiles; | ||
}; | ||
}; | ||
}; | ||
|
||
meta = { | ||
maintainers = with lib.maintainers; [ | ||
drupol | ||
niklaskorz | ||
]; | ||
# doc = ./fider.md; | ||
}; | ||
} |
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,33 @@ | ||
{ lib, ... }: | ||
|
||
{ | ||
name = "fider-server"; | ||
|
||
nodes = { | ||
machine = | ||
{ pkgs, ... }: | ||
{ | ||
services.fider = { | ||
enable = true; | ||
environment = { | ||
JWT_SECRET = "not_so_secret"; | ||
BASE_URL = "/"; | ||
EMAIL_NOREPLY = "[email protected]"; | ||
EMAIL_SMTP_HOST = "mailhog"; | ||
EMAIL_SMTP_PORT = "1025"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
machine.start() | ||
machine.wait_for_unit("fider.service") | ||
machine.wait_for_open_port(3000) | ||
''; | ||
|
||
meta.maintainers = with lib.maintainers; [ | ||
drupol | ||
niklaskorz | ||
]; | ||
} |
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,12 @@ | ||
diff --git a/app/cmd/server.go b/app/cmd/server.go | ||
index fcfbeec2..71f01c9d 100644 | ||
--- a/app/cmd/server.go | ||
+++ b/app/cmd/server.go | ||
@@ -46,7 +46,6 @@ func RunServer() int { | ||
}) | ||
} | ||
|
||
- copyEtcFiles(ctx) | ||
startJobs(ctx) | ||
|
||
e := routes(web.New()) |
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,42 @@ | ||
{ | ||
lib, | ||
esbuild, | ||
buildNpmPackage, | ||
|
||
pname, | ||
version, | ||
src, | ||
npmDepsHash, | ||
}: | ||
|
||
buildNpmPackage { | ||
inherit version src npmDepsHash; | ||
pname = "${pname}-frontend"; | ||
|
||
nativeBuildInputs = [ esbuild ]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
|
||
npx lingui extract public/ | ||
npx lingui compile | ||
NODE_ENV=production node esbuild.config.js | ||
NODE_ENV=production npx webpack-cli | ||
|
||
runHook postBuild | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
|
||
mkdir -p $out | ||
cp -r dist ssr.js favicon.png robots.txt $out/ | ||
|
||
runHook postInstall | ||
''; | ||
|
||
env = { | ||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1; | ||
ESBUILD_BINARY_PATH = lib.getExe esbuild; | ||
}; | ||
} |
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,110 @@ | ||
{ | ||
lib, | ||
stdenvNoCC, | ||
fetchFromGitHub, | ||
callPackage, | ||
esbuild, | ||
buildGoModule, | ||
nixosTests, | ||
nix-update-script, | ||
}: | ||
|
||
stdenvNoCC.mkDerivation (finalAttrs: { | ||
pname = "fider"; | ||
version = "0.24.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "getfider"; | ||
repo = "fider"; | ||
tag = "v${finalAttrs.version}"; | ||
hash = "sha256-nzOplwsE0ppmxbTrNAgePnIQIAD/5Uu4gXlebFKWGfc="; | ||
}; | ||
|
||
dontConfigure = true; | ||
dontBuild = true; | ||
|
||
# Allow easier version overrides, e.g.: | ||
# pkgs.fider.overrideAttrs (prev: { | ||
# version = "..."; | ||
# src = prev.src.override { | ||
# hash = "..."; | ||
# }; | ||
# vendorHash = "..."; | ||
# npmDepsHash = "..."; | ||
# }) | ||
vendorHash = "sha256-CfopU72fpXiTaBtdf9A57Wb+flDu2XEtTISxImeJLL0="; | ||
npmDepsHash = "sha256-gnboT5WQzftOCZ2Ouuza7bqpxJf+Zs7OWC8OHMZNHvw="; | ||
|
||
server = callPackage ./server.nix { | ||
inherit (finalAttrs) | ||
pname | ||
version | ||
src | ||
vendorHash | ||
; | ||
}; | ||
frontend = callPackage ./frontend.nix { | ||
inherit (finalAttrs) | ||
pname | ||
version | ||
src | ||
npmDepsHash | ||
; | ||
# We specify the esbuild override here instead of in frontend.nix so end users can | ||
# again easily override it if necessary, for example when changing to an unreleased | ||
# version of fider requiring a newer esbuild than specified here: | ||
# pkgs.fider.overrideAttrs (prev: { | ||
# frontend = prev.frontend.override { | ||
# esbuild = ...; | ||
# }; | ||
# }) | ||
esbuild = esbuild.override { | ||
buildGoModule = | ||
args: | ||
buildGoModule ( | ||
args | ||
// rec { | ||
version = "0.14.38"; | ||
src = fetchFromGitHub { | ||
owner = "evanw"; | ||
repo = "esbuild"; | ||
tag = "v${version}"; | ||
hash = "sha256-rvMi1oC7qGidvi4zrm9KCMMntu6LJGVOGN6VmU2ivQE="; | ||
}; | ||
vendorHash = "sha256-QPkBR+FscUc3jOvH7olcGUhM6OW4vxawmNJuRQxPuGs="; | ||
} | ||
); | ||
}; | ||
}; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
|
||
mkdir -p $out/etc | ||
cp -r locale views migrations $out/ | ||
cp -r etc/*.md $out/etc/ | ||
ln -s ${finalAttrs.server}/* $out/ | ||
ln -s ${finalAttrs.frontend}/* $out/ | ||
|
||
runHook postInstall | ||
''; | ||
|
||
passthru = { | ||
tests = { | ||
inherit (nixosTests) fider; | ||
}; | ||
updateScript = nix-update-script { }; | ||
}; | ||
|
||
meta = { | ||
description = "Open platform to collect and prioritize feedback"; | ||
homepage = "https://github.com/getfider/fider"; | ||
changelog = "https://github.com/getfider/fider/releases/tag/${finalAttrs.src.tag}"; | ||
license = lib.licenses.agpl3Only; | ||
mainProgram = "fider"; | ||
maintainers = with lib.maintainers; [ | ||
drupol | ||
niklaskorz | ||
]; | ||
}; | ||
}) |
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,30 @@ | ||
{ | ||
buildGoModule, | ||
|
||
pname, | ||
version, | ||
src, | ||
vendorHash, | ||
}: | ||
|
||
buildGoModule { | ||
inherit version src vendorHash; | ||
pname = "${pname}-server"; | ||
|
||
patches = [ | ||
./0001-disable-etc-copy.patch | ||
]; | ||
|
||
ldflags = [ | ||
"-s" | ||
"-w" | ||
]; | ||
|
||
doCheck = false; # requires a running PostgreSQL database | ||
|
||
# preCheck = '' | ||
# set -o allexport | ||
# source ./.test.env | ||
# set +o allexport | ||
# ''; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should add a comment explaining why the patch is needed, plus a link to the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually let me have another look at the copy mechanism, I went through the code again just now and wonder if there is a better solution than disabling it... (will report back later)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I’ll follow it.