Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions nixos/modules/services/web-apps/outline.nix
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ in

# Create an outline-sequalize wrapper (a wrapper around the wrapper) that
# has the config file's path baked in. This is necessary because there is
# at least one occurrence of outline calling this from its own code.
# at least two occurrences of outline calling this from its own code.
sequelize = pkgs.writeShellScriptBin "outline-sequelize" ''
exec ${cfg.package}/bin/outline-sequelize \
--config $RUNTIME_DIRECTORY/database.json \
Expand Down Expand Up @@ -687,21 +687,18 @@ in
openssl rand -hex 32 > ${lib.escapeShellArg cfg.utilsSecretFile}
fi

# The config file is required for the CLI, the DATABASE_URL environment
# variable is read by the app.
# The config file is required for the sequelize CLI.
${if (cfg.databaseUrl == "local") then ''
cat <<EOF > $RUNTIME_DIRECTORY/database.json
{
"production": {
"dialect": "postgres",
"production-ssl-disabled": {
"host": "/run/postgresql",
"username": null,
"password": null
"password": null,
"dialect": "postgres"
}
}
EOF
export DATABASE_URL=${lib.escapeShellArg localPostgresqlUrl}
export PGSSLMODE=disable
'' else ''
cat <<EOF > $RUNTIME_DIRECTORY/database.json
{
Expand All @@ -720,11 +717,7 @@ in
}
}
EOF
export DATABASE_URL=${lib.escapeShellArg cfg.databaseUrl}
''}

cd $RUNTIME_DIRECTORY
${sequelize}/bin/outline-sequelize db:migrate
'';

script = ''
Expand Down Expand Up @@ -781,7 +774,7 @@ in
RuntimeDirectoryMode = "0750";
# This working directory is required to find stuff like the set of
# onboarding files:
WorkingDirectory = "${cfg.package}/share/outline/build";
WorkingDirectory = "${cfg.package}/share/outline";
};
};
};
Expand Down
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ in {
openstack-image-userdata = (handleTestOn ["x86_64-linux"] ./openstack-image.nix {}).userdata or {};
opentabletdriver = handleTest ./opentabletdriver.nix {};
owncast = handleTest ./owncast.nix {};
outline = handleTest ./outline.nix {};
image-contents = handleTest ./image-contents.nix {};
openvscode-server = handleTest ./openvscode-server.nix {};
orangefs = handleTest ./orangefs.nix {};
Expand Down
54 changes: 54 additions & 0 deletions nixos/tests/outline.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
let
accessKey = "BKIKJAA5BMMU2RHO6IBB";
secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
secretKeyFile = pkgs.writeText "outline-secret-key" ''
${secretKey}
'';
rootCredentialsFile = pkgs.writeText "minio-credentials-full" ''
MINIO_ROOT_USER=${accessKey}
MINIO_ROOT_PASSWORD=${secretKey}
'';
in
{
name = "outline";

meta.maintainers = with lib.maintainers; [ xanderio ];

nodes = {
outline = { pkgs, config, ... }: {
nixpkgs.config.allowUnfree = true;
environment.systemPackages = [ pkgs.minio-client ];
services.outline = {
enable = true;
forceHttps = false;
storage = {
inherit accessKey secretKeyFile;
uploadBucketUrl = "http://localhost:9000";
uploadBucketName = "outline";
region = config.services.minio.region;
};
};
services.minio = {
enable = true;
inherit rootCredentialsFile;
};
};
};

testScript =
''
machine.wait_for_unit("minio.service")
machine.wait_for_open_port(9000)

# Create a test bucket on the server
machine.succeed(
"mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
)
machine.succeed("mc mb minio/outline")

outline.wait_for_unit("outline.service")
outline.wait_for_open_port(3000)
outline.succeed("curl --fail http://localhost:3000/")
'';
})
36 changes: 17 additions & 19 deletions pkgs/servers/web-apps/outline/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
, nodejs
, yarn
, yarn2nix-moretea
, nixosTests
}:

stdenv.mkDerivation rec {
pname = "outline";
version = "0.68.1";
version = "0.69.2";

src = fetchFromGitHub {
owner = "outline";
repo = "outline";
rev = "v${version}";
sha256 = "sha256-pln3cdozZPEodfXeUtTbBvhHb5yqE4uu0VKA95Zv6ro=";
hash = "sha256-XevrCUvPmAbPTysJ/o7i2xAZTQ+UFYtVal/aZKvt+Ls=";
};

nativeBuildInputs = [ makeWrapper yarn2nix-moretea.fixup_yarn_lock ];
buildInputs = [ yarn nodejs ];

# Replace the inline call to yarn with our sequalize wrapper. This should be
# the only occurrence:
# Replace the inline calls to yarn with our sequalize wrapper. These should be
# the two occurrences:
# https://github.com/outline/outline/search?l=TypeScript&q=yarn
patches = [ ./sequelize-command.patch ];

Expand All @@ -43,29 +44,22 @@ stdenv.mkDerivation rec {
--frozen-lockfile \
--ignore-engines --ignore-scripts
patchShebangs node_modules/
# apply upstream patches with `patch-package`
yarn run postinstall
yarn build

pushd server
cp -r config migrations onboarding ../build/server/
popd

runHook postBuild
'';

installPhase = ''
runHook preInstall

mkdir -p $out/bin $out/share/outline
mv public node_modules build $out/share/outline/
mv build server public node_modules $out/share/outline/

node_modules=$out/share/outline/node_modules
build=$out/share/outline/build

# On NixOS the WorkingDirectory is set to the build directory, as
# this contains files needed in the onboarding process. This folder
# must also contain the `public` folder for mail notifications to
# work, as it contains the mail templates.
ln -s $out/share/outline/public $build/public
server=$out/share/outline/server

makeWrapper ${nodejs}/bin/node $out/bin/outline-server \
--add-flags $build/server/index.js \
Expand All @@ -74,21 +68,25 @@ stdenv.mkDerivation rec {

makeWrapper ${nodejs}/bin/node $out/bin/outline-sequelize \
--add-flags $node_modules/.bin/sequelize \
--add-flags "--migrations-path $build/server/migrations" \
--add-flags "--models-path $build/server/models" \
--add-flags "--seeders-path $build/server/models/fixtures" \
--add-flags "--migrations-path $server/migrations" \
--add-flags "--models-path $server/models" \
--add-flags "--seeders-path $server/models/fixtures" \
--set NODE_ENV production \
--set NODE_PATH $node_modules

runHook postInstall
'';

passthru.tests = {
basic-functionality = nixosTests.outline;
};

meta = with lib; {
description = "The fastest wiki and knowledge base for growing teams. Beautiful, feature rich, and markdown compatible";
homepage = "https://www.getoutline.com/";
changelog = "https://github.com/outline/outline/releases";
license = licenses.bsl11;
maintainers = with maintainers; [ cab404 yrd ];
maintainers = with maintainers; [ cab404 yrd xanderio ];
platforms = platforms.linux;
};
}
31 changes: 19 additions & 12 deletions pkgs/servers/web-apps/outline/sequelize-command.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
diff --git a/server/utils/startup.ts b/server/utils/startup.ts
index 7554b854..6641f805 100644
index 444de475..b883f71a 100644
--- a/server/utils/startup.ts
+++ b/server/utils/startup.ts
@@ -8,9 +8,7 @@ import Team from "@server/models/Team";
export function checkPendingMigrations() {
try {
const commandResult = execSync(
- `yarn sequelize db:migrate:status${
- env.PGSSLMODE === "disable" ? " --env=production-ssl-disabled" : ""
- }`
+ "outline-sequelize db:migrate:status"
);
const commandResultArray = Buffer.from(commandResult)
.toString("utf-8")
@@ -8,7 +8,7 @@ import Team from "@server/models/Team";

function getPendingMigrations() {
const commandResult = execSync(
- `yarn sequelize db:migrate:status${
+ `outline-sequelize db:migrate:status${
env.PGSSLMODE === "disable" ? " --env=production-ssl-disabled" : ""
}`
);
@@ -26,7 +26,7 @@ function getPendingMigrations() {
function runMigrations() {
Logger.info("database", "Running migrations...");
const cmdResult = execSync(
- `yarn db:migrate${
+ `outline-sequelize db:migrate${
env.PGSSLMODE === "disable" ? " --env=production-ssl-disabled" : ""
}`
);
Loading