fixxxxxxxxxxxxxx
This commit is contained in:
@@ -24,11 +24,6 @@ example:
|
|||||||
# httpPort = 8080;
|
# httpPort = 8080;
|
||||||
# httpsPort = null;
|
# httpsPort = null;
|
||||||
|
|
||||||
bun2nix = {
|
|
||||||
enable = true;
|
|
||||||
outputFile = "bun.nix";
|
|
||||||
};
|
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
DOMAIN_NAME = "wafrn.example.com";
|
DOMAIN_NAME = "wafrn.example.com";
|
||||||
CACHE_DOMAIN = "cache.wafrn.example.com";
|
CACHE_DOMAIN = "cache.wafrn.example.com";
|
||||||
|
|||||||
109
flake.lock
generated
109
flake.lock
generated
@@ -1,62 +1,5 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"bun2nix": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-parts": "flake-parts",
|
|
||||||
"import-tree": "import-tree",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"systems": "systems",
|
|
||||||
"treefmt-nix": "treefmt-nix"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1770895533,
|
|
||||||
"narHash": "sha256-v3QaK9ugy9bN9RXDnjw0i2OifKmz2NnKM82agtqm/UY=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "bun2nix",
|
|
||||||
"rev": "c843f477b15f51151f8c6bcc886954699440a6e1",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "bun2nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-parts": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1769996383,
|
|
||||||
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
|
|
||||||
"owner": "hercules-ci",
|
|
||||||
"repo": "flake-parts",
|
|
||||||
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "hercules-ci",
|
|
||||||
"repo": "flake-parts",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"import-tree": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1763762820,
|
|
||||||
"narHash": "sha256-ZvYKbFib3AEwiNMLsejb/CWs/OL/srFQ8AogkebEPF0=",
|
|
||||||
"owner": "vic",
|
|
||||||
"repo": "import-tree",
|
|
||||||
"rev": "3c23749d8013ec6daa1d7255057590e9ca726646",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "vic",
|
|
||||||
"repo": "import-tree",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771419570,
|
"lastModified": 1771419570,
|
||||||
@@ -73,62 +16,10 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1769909678,
|
|
||||||
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "nixpkgs.lib",
|
|
||||||
"rev": "72716169fe93074c333e8d0173151350670b824c",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "nixpkgs.lib",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"bun2nix": "bun2nix",
|
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"treefmt-nix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"bun2nix",
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1770228511,
|
|
||||||
"narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt-nix",
|
|
||||||
"rev": "337a4fe074be1042a35086f15481d763b8ddc0e7",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt-nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|||||||
@@ -3,16 +3,11 @@
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||||
bun2nix.url = "github:nix-community/bun2nix";
|
|
||||||
bun2nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, bun2nix, ... }: {
|
outputs = { self, ... }: {
|
||||||
nixosModules = {
|
nixosModules = {
|
||||||
wafrn = { ... }: {
|
wafrn = import ./modules/wafrn.nix;
|
||||||
imports = [ ./modules/wafrn.nix ];
|
|
||||||
_module.args.bun2nixFlake = bun2nix;
|
|
||||||
};
|
|
||||||
default = self.nixosModules.wafrn;
|
default = self.nixosModules.wafrn;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ config, lib, pkgs, bun2nixFlake ? null, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
concatStringsSep
|
concatStringsSep
|
||||||
@@ -105,14 +105,15 @@ let
|
|||||||
|
|
||||||
serviceEnvFile = "${cfg.stateDir}/.env";
|
serviceEnvFile = "${cfg.stateDir}/.env";
|
||||||
composeFile = "${cfg.stateDir}/docker-compose.yml";
|
composeFile = "${cfg.stateDir}/docker-compose.yml";
|
||||||
bunNixFile = "${cfg.stateDir}/${cfg.bun2nix.outputFile}";
|
|
||||||
sourcePath = cfg.source;
|
sourcePath = cfg.source;
|
||||||
|
|
||||||
bun2nixCli =
|
publishedPorts =
|
||||||
if bun2nixFlake != null then
|
lib.optionals (cfg.httpPort != null) [ "${toString cfg.httpPort}:80" ]
|
||||||
"${bun2nixFlake.packages.${pkgs.system}.default}/bin/bun2nix"
|
++ lib.optionals (cfg.httpsPort != null) [ "${toString cfg.httpsPort}:443" ];
|
||||||
else
|
|
||||||
"${pkgs.bun}/bin/bunx bun2nix";
|
firewallPorts =
|
||||||
|
lib.optionals (cfg.httpPort != null) [ cfg.httpPort ]
|
||||||
|
++ lib.optionals (cfg.httpsPort != null) [ cfg.httpsPort ];
|
||||||
|
|
||||||
serviceCommon = {
|
serviceCommon = {
|
||||||
restart = "unless-stopped";
|
restart = "unless-stopped";
|
||||||
@@ -315,32 +316,6 @@ in
|
|||||||
description = "Enable Adminer container.";
|
description = "Enable Adminer container.";
|
||||||
};
|
};
|
||||||
|
|
||||||
bun2nix = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Generate a bun2nix expression from the Wafrn bun lock file before starting.";
|
|
||||||
};
|
|
||||||
|
|
||||||
lockFile = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "bun.lock";
|
|
||||||
description = "Lock file path relative to services.wafrn.source.";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputFile = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "bun.nix";
|
|
||||||
description = "Generated bun2nix expression filename under services.wafrn.stateDir.";
|
|
||||||
};
|
|
||||||
|
|
||||||
copyPrefix = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "./";
|
|
||||||
description = "Value passed to bun2nix --copy-prefix for workspace/file dependencies.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
bluesky = {
|
bluesky = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@@ -372,10 +347,6 @@ in
|
|||||||
assertion = cfg.httpPort != null || cfg.httpsPort != null;
|
assertion = cfg.httpPort != null || cfg.httpsPort != null;
|
||||||
message = "services.wafrn requires at least one published port (httpPort or httpsPort).";
|
message = "services.wafrn requires at least one published port (httpPort or httpsPort).";
|
||||||
}
|
}
|
||||||
{
|
|
||||||
assertion = (!cfg.bun2nix.enable) || (bun2nixFlake != null);
|
|
||||||
message = "services.wafrn.bun2nix.enable requires using this module from the flake output so bun2nix is available.";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
@@ -402,17 +373,6 @@ in
|
|||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
};
|
};
|
||||||
script = ''
|
script = ''
|
||||||
${optionalString cfg.bun2nix.enable ''
|
|
||||||
if [ ! -f "${cfg.source}/${cfg.bun2nix.lockFile}" ]; then
|
|
||||||
echo "missing lockfile: ${cfg.source}/${cfg.bun2nix.lockFile}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
${bun2nixCli} \
|
|
||||||
--lock-file "${cfg.source}/${cfg.bun2nix.lockFile}" \
|
|
||||||
--output-file "${bunNixFile}" \
|
|
||||||
--copy-prefix "${cfg.bun2nix.copyPrefix}"
|
|
||||||
''}
|
|
||||||
|
|
||||||
install -m 0600 ${envTemplate} ${serviceEnvFile}
|
install -m 0600 ${envTemplate} ${serviceEnvFile}
|
||||||
${optionalString (cfg.secretsFile != null) ''
|
${optionalString (cfg.secretsFile != null) ''
|
||||||
cat "${cfg.secretsFile}" >> ${serviceEnvFile}
|
cat "${cfg.secretsFile}" >> ${serviceEnvFile}
|
||||||
@@ -448,10 +408,3 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
publishedPorts =
|
|
||||||
lib.optionals (cfg.httpPort != null) [ "${toString cfg.httpPort}:80" ]
|
|
||||||
++ lib.optionals (cfg.httpsPort != null) [ "${toString cfg.httpsPort}:443" ];
|
|
||||||
|
|
||||||
firewallPorts =
|
|
||||||
lib.optionals (cfg.httpPort != null) [ cfg.httpPort ]
|
|
||||||
++ lib.optionals (cfg.httpsPort != null) [ cfg.httpsPort ];
|
|
||||||
|
|||||||
Reference in New Issue
Block a user