2024-02-02 10:51:31 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
fetchFromGitHub,
|
|
|
|
git,
|
2024-04-17 14:47:51 +02:00
|
|
|
bun,
|
2024-02-02 10:51:31 +01:00
|
|
|
nodejs,
|
|
|
|
ruby_3_2,
|
|
|
|
bundlerEnv,
|
|
|
|
logDir ? "/var/log/ds-fr",
|
|
|
|
dataDir ? "/var/lib/ds-fr",
|
|
|
|
initialDeploymentDate ? "17941030",
|
|
|
|
}:
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
let
|
2024-02-10 20:36:16 +01:00
|
|
|
inherit (lib) getExe;
|
|
|
|
|
|
|
|
# Head of the DGNum repo
|
2024-04-17 14:47:51 +02:00
|
|
|
dgn-id = "1b6a2a23331398f46f3c292cd9631c163390916b";
|
2024-02-10 20:36:16 +01:00
|
|
|
|
2023-09-24 13:16:22 +02:00
|
|
|
pname = "ds-fr";
|
2023-11-16 09:21:34 +01:00
|
|
|
meta = import ./meta.nix;
|
|
|
|
|
|
|
|
inherit (meta) version;
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "demarches-simplifiees";
|
|
|
|
repo = "demarches-simplifiees.fr";
|
2023-10-02 21:20:01 +02:00
|
|
|
rev = version;
|
2023-11-16 09:21:34 +01:00
|
|
|
hash = meta.src-hash;
|
2023-09-24 13:16:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
rubyEnv = bundlerEnv {
|
|
|
|
name = "env-${pname}";
|
|
|
|
gemdir = ./rubyEnv;
|
|
|
|
ruby = ruby_3_2;
|
|
|
|
gemset = (import ./rubyEnv/gemset.nix) // {
|
|
|
|
bundler = {
|
|
|
|
groups = [ "default" ];
|
|
|
|
platforms = [ ];
|
|
|
|
source = {
|
|
|
|
remotes = [ "https://rubygems.org" ];
|
|
|
|
sha256 = "deeQ3fNwcSiGSO/yeB2yoTniRq2gHW8WueprXoPX6Jk=";
|
|
|
|
type = "gem";
|
|
|
|
};
|
|
|
|
version = "2.3.11";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-17 14:47:51 +02:00
|
|
|
node_modules = stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-node_modules";
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
|
|
|
|
"GIT_PROXY_COMMAND"
|
|
|
|
"SOCKS_SERVER"
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ bun ];
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
buildPhase = ''
|
2024-04-17 17:06:28 +02:00
|
|
|
bun install --no-progress --frozen-lockfile --ignore-scripts
|
|
|
|
rm -r node_modules/.cache
|
2024-04-17 14:47:51 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mv node_modules $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontFixup = true;
|
|
|
|
|
|
|
|
outputHash = meta.deps-hash or lib.fakeHash;
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
};
|
|
|
|
|
2023-09-24 13:16:22 +02:00
|
|
|
dsModules = stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-modules";
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
buildInputs = [ rubyEnv ];
|
2024-02-02 10:51:31 +01:00
|
|
|
nativeBuildInputs = [
|
2024-04-17 14:47:51 +02:00
|
|
|
bun
|
2024-02-02 10:51:31 +01:00
|
|
|
nodejs
|
|
|
|
rubyEnv.wrappedRuby
|
|
|
|
];
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
RAILS_ENV = "production";
|
|
|
|
NODE_ENV = "dev";
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Disable functionnalities as we only precompile assets
|
|
|
|
./patches/build.patch
|
2023-11-30 19:59:19 +01:00
|
|
|
];
|
|
|
|
|
2024-02-10 20:36:16 +01:00
|
|
|
postPatch = ''
|
|
|
|
${getExe git} apply -p1 < ${builtins.fetchurl "https://git.dgnum.eu/DGNum/demarches-normaliennes/commit/${dgn-id}.patch"}
|
|
|
|
'';
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
OTP_SECRET_KEY = "precompile_placeholder";
|
|
|
|
SECRET_KEY_BASE = "precompile_placeholder";
|
|
|
|
APP_HOST = "precompile_placeholder";
|
|
|
|
|
|
|
|
buildPhase = ''
|
2024-04-17 14:47:51 +02:00
|
|
|
cp -R ${node_modules} node_modules
|
|
|
|
chmod u+w -R node_modules
|
2023-09-24 13:16:22 +02:00
|
|
|
|
2024-04-17 14:47:51 +02:00
|
|
|
patchShebangs node_modules
|
2023-09-24 13:16:22 +02:00
|
|
|
patchShebangs bin/
|
|
|
|
|
|
|
|
bin/rake assets:precompile
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/public
|
|
|
|
cp -r public/* $out/public
|
|
|
|
'';
|
|
|
|
};
|
2024-02-02 10:51:31 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
2023-09-24 13:16:22 +02:00
|
|
|
name = "demarches-simplifiees.fr-${version}";
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
buildInputs = [ rubyEnv ];
|
|
|
|
propagatedBuildInputs = [ rubyEnv.wrappedRuby ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./patches/replay_routing_engine_for_a_cloned_procedure.patch
|
|
|
|
./patches/smtp_settings.patch
|
|
|
|
./patches/garage.patch
|
2023-11-30 19:59:19 +01:00
|
|
|
];
|
|
|
|
|
2024-02-10 20:36:16 +01:00
|
|
|
postPatch = ''
|
|
|
|
${getExe git} apply -p1 < ${builtins.fetchurl "https://git.dgnum.eu/DGNum/demarches-normaliennes/commit/${dgn-id}.patch"}
|
|
|
|
'';
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
rm -rf public
|
|
|
|
ln -s ${dsModules}/public/ public
|
|
|
|
|
|
|
|
patchShebangs bin/
|
|
|
|
|
2023-09-26 20:46:38 +02:00
|
|
|
rm -rf log storage
|
2023-09-24 13:16:22 +02:00
|
|
|
ln -s ${logDir} log
|
|
|
|
ln -s ${dataDir}/tmp tmp
|
2023-09-26 20:46:38 +02:00
|
|
|
ln -s ${dataDir}/storage storage
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
for f in $(ls lib/tasks/deployment/); do
|
|
|
|
[[ ! ${initialDeploymentDate} < $f ]] \
|
|
|
|
&& rm lib/tasks/deployment/$f;
|
|
|
|
done;
|
|
|
|
|
|
|
|
echo "Removed unused data migrations"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r * $out/
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit rubyEnv;
|
|
|
|
ruby = rubyEnv.wrappedRuby;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Dématérialiser et simplifier les démarches administratives";
|
2024-02-02 10:51:31 +01:00
|
|
|
homepage = "https://github.com/demarches-simplifiees/demarches-simplifiees.fr";
|
2023-09-24 13:16:22 +02:00
|
|
|
license = licenses.agpl3Only;
|
|
|
|
maintainers = with maintainers; [ thubrecht ];
|
|
|
|
};
|
|
|
|
}
|