Fix flake.nix: node 22, shebang indentation, databaseUrl default, assertion
- Upgrade to nodejs_22 (22.22.2) for better Vite 6 compatibility - Fix wrapper script shebang broken by heredoc indentation - Add preBuild step for svelte-kit sync - Default databaseUrl to "" so environmentFile-only configs don't fail eval - Add assertion ensuring either databaseUrl or environmentFile is set Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
nodejs = pkgs.nodejs_20;
|
||||
nodejs = pkgs.nodejs_22;
|
||||
in
|
||||
{
|
||||
# Development shell: `nix develop`
|
||||
@@ -38,19 +38,26 @@
|
||||
|
||||
src = ./.;
|
||||
|
||||
npmDepsHash = ""; # Run `nix build` once to get the correct hash
|
||||
npmDepsHash = ""; # Run `nix build` once — it will fail and print the correct hash
|
||||
|
||||
nodejs = pkgs.nodejs_22;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.python3 # needed by some native modules
|
||||
pkgs.python3 # needed by sharp native rebuild
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
pkgs.vips # sharp
|
||||
pkgs.vips
|
||||
pkgs.glib
|
||||
pkgs.expat
|
||||
];
|
||||
|
||||
# SvelteKit needs sync before build
|
||||
preBuild = ''
|
||||
npx svelte-kit sync
|
||||
'';
|
||||
|
||||
npmBuildScript = "build";
|
||||
|
||||
installPhase = ''
|
||||
@@ -62,10 +69,10 @@
|
||||
cp package.json $out/lib/buildfor_life_repair/
|
||||
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/buildfor_life_repair <<EOF
|
||||
cat > $out/bin/buildfor_life_repair <<'WRAPPER'
|
||||
#!/usr/bin/env bash
|
||||
exec ${nodejs}/bin/node $out/lib/buildfor_life_repair/index.js "\$@"
|
||||
EOF
|
||||
exec ${pkgs.nodejs_22}/bin/node $out/lib/buildfor_life_repair/index.js "$@"
|
||||
WRAPPER
|
||||
chmod +x $out/bin/buildfor_life_repair
|
||||
|
||||
runHook postInstall
|
||||
@@ -102,14 +109,15 @@
|
||||
|
||||
databaseUrl = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "PostgreSQL connection string";
|
||||
default = "";
|
||||
description = "PostgreSQL connection string. Leave empty if using environmentFile.";
|
||||
example = "postgresql://bflr:password@localhost:5432/buildfor_life_repair";
|
||||
};
|
||||
|
||||
environmentFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
description = "Path to environment file with secrets (DATABASE_URL, etc). Overrides databaseUrl if set.";
|
||||
description = "Path to environment file with secrets (DATABASE_URL, etc). Takes precedence over databaseUrl.";
|
||||
};
|
||||
|
||||
baseUrl = lib.mkOption {
|
||||
@@ -144,6 +152,13 @@
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.databaseUrl != "" || cfg.environmentFile != null;
|
||||
message = "services.buildfor-life-repair: Either databaseUrl or environmentFile must be set.";
|
||||
}
|
||||
];
|
||||
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
@@ -164,7 +179,7 @@
|
||||
HOST = cfg.host;
|
||||
BASE_URL = cfg.baseUrl;
|
||||
UPLOAD_DIR = cfg.uploadDir;
|
||||
} // lib.optionalAttrs (cfg.environmentFile == null) {
|
||||
} // lib.optionalAttrs (cfg.databaseUrl != "") {
|
||||
DATABASE_URL = cfg.databaseUrl;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user