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:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
nodejs = pkgs.nodejs_20;
|
nodejs = pkgs.nodejs_22;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Development shell: `nix develop`
|
# Development shell: `nix develop`
|
||||||
@@ -38,19 +38,26 @@
|
|||||||
|
|
||||||
src = ./.;
|
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 = [
|
nativeBuildInputs = [
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
pkgs.python3 # needed by some native modules
|
pkgs.python3 # needed by sharp native rebuild
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.vips # sharp
|
pkgs.vips
|
||||||
pkgs.glib
|
pkgs.glib
|
||||||
pkgs.expat
|
pkgs.expat
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# SvelteKit needs sync before build
|
||||||
|
preBuild = ''
|
||||||
|
npx svelte-kit sync
|
||||||
|
'';
|
||||||
|
|
||||||
npmBuildScript = "build";
|
npmBuildScript = "build";
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
@@ -62,10 +69,10 @@
|
|||||||
cp package.json $out/lib/buildfor_life_repair/
|
cp package.json $out/lib/buildfor_life_repair/
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cat > $out/bin/buildfor_life_repair <<EOF
|
cat > $out/bin/buildfor_life_repair <<'WRAPPER'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
exec ${nodejs}/bin/node $out/lib/buildfor_life_repair/index.js "\$@"
|
exec ${pkgs.nodejs_22}/bin/node $out/lib/buildfor_life_repair/index.js "$@"
|
||||||
EOF
|
WRAPPER
|
||||||
chmod +x $out/bin/buildfor_life_repair
|
chmod +x $out/bin/buildfor_life_repair
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
@@ -102,14 +109,15 @@
|
|||||||
|
|
||||||
databaseUrl = lib.mkOption {
|
databaseUrl = lib.mkOption {
|
||||||
type = lib.types.str;
|
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";
|
example = "postgresql://bflr:password@localhost:5432/buildfor_life_repair";
|
||||||
};
|
};
|
||||||
|
|
||||||
environmentFile = lib.mkOption {
|
environmentFile = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.path;
|
type = lib.types.nullOr lib.types.path;
|
||||||
default = null;
|
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 {
|
baseUrl = lib.mkOption {
|
||||||
@@ -144,6 +152,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
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} = {
|
users.users.${cfg.user} = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
@@ -164,7 +179,7 @@
|
|||||||
HOST = cfg.host;
|
HOST = cfg.host;
|
||||||
BASE_URL = cfg.baseUrl;
|
BASE_URL = cfg.baseUrl;
|
||||||
UPLOAD_DIR = cfg.uploadDir;
|
UPLOAD_DIR = cfg.uploadDir;
|
||||||
} // lib.optionalAttrs (cfg.environmentFile == null) {
|
} // lib.optionalAttrs (cfg.databaseUrl != "") {
|
||||||
DATABASE_URL = cfg.databaseUrl;
|
DATABASE_URL = cfg.databaseUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user