Closed jalbstmeijer closed 1 year ago
Got it to work. Maybe it should be easier to add a new input?
flake.nix: phps.url = "github:fossar/nix-phps";
flake.nix: outputs = { nixpkgs, self, ... }@inputs:
flake.nix: specialArgs = { inherit inputs; };
flake.nix: examples = import ./examples { inherit inputs nixpkgs; inherit (self) nglib; };
examples/default.nix:{ nglib, nixpkgs, inputs }:
examples/default.nix: nixpkgs.lib.mapAttrs (_: v: import v { inherit nixpkgs nglib inputs; }) examples
examples/php-fpm/default.nix:{ nglib, nixpkgs, inputs }:
examples/php-fpm/default.nix: config = ({ pkgs, config, phps, ... }:
examples/php-fpm/default.nix: package = inputs.phps.packages.x86_64-linux.php70;
Hey sorry, I was away from all tech, I'll reopen and provide you with a example of how to do what you desire :)
Hey sorry, I was away from all tech, I'll reopen and provide you with a example of how to do what you desire :)
Well it woks now, but if you see a cleaner way.. yes please.
Currently trying to overrule these attributes in examples/php-fpm/default.nix, but no luck yet.
nglib.makeSystem.name nglib.config.services.php-fpm.pools.main.package
{ nglib, nixpkgs, inputs }:
let
examples =
{
"php-fpm" = ./php-fpm;
"php-fpm-74" = ./php-fpm // { nglib.makeSystem.name = "php-fpm-74"; };
};
in
nixpkgs.lib.mapAttrs (_: v: import v { inherit nixpkgs nglib inputs; }) examples
{
inputs = {
nixpkgs.url = "nixpkgs";
nixng.url = "github:nix-community/NixNG";
phps.url = "github:fossar/nix-phps";
};
outputs =
{ self, nixpkgs, nixng, phps }:
{
nixngConfigurations.php-example =
nixng.nglib.makeSystem {
inherit nixpkgs;
system = "x86_64-linux";
name = "nixng-php-fpm";
config = ({ pkgs, config, ... }:
{
config = {
dumb-init = {
enable = true;
type.services = { };
};
init.services.apache2 = {
shutdownOnExit = true;
ensureSomething.create."documentRoot" = {
src = ./documentRoot;
dst = "/var/www";
};
};
services.php-fpm = {
pools = {
main = {
package = phps.packages.x86_64-linux.php70;
createUserGroup = false;
fpmSettings = {
"pm" = "dynamic";
"pm.max_children" = 75;
"pm.start_servers" = 10;
"pm.min_spare_servers" = 5;
"pm.max_spare_servers" = 20;
"pm.max_requests" = 500;
};
};
};
};
services.apache2 = {
enable = true;
envsubst = true;
configuration = [
{
LoadModule = [
[ "mpm_event_module" "modules/mod_mpm_event.so" ]
[ "log_config_module" "modules/mod_log_config.so" ]
[ "unixd_module" "modules/mod_unixd.so" ]
[ "authz_core_module" "modules/mod_authz_core.so" ]
[ "dir_module" "modules/mod_dir.so" ]
[ "mime_module" "modules/mod_mime.so" ]
[ "proxy_module" "modules/mod_proxy.so" ]
[ "proxy_fcgi_module" "modules/mod_proxy_fcgi.so" ]
];
}
{
Listen = "0.0.0.0:80";
ServerRoot = "/var/www";
ServerName = "blowhole";
PidFile = "/httpd.pid";
DocumentRoot = "/var/www";
User = "www-data";
Group = "www-data";
}
{
ErrorLog = "/dev/stderr";
TransferLog = "/dev/stdout";
LogLevel = "info";
}
{
AddType = [
[ "image/svg+xml" "svg" "svgz" ]
];
AddEncoding = [ "gzip" "svgz" ];
TypesConfig = "${pkgs.apacheHttpd}/conf/mime.types";
}
{
Directory = {
"/" = {
Require = [ "all" "denied" ];
Options = "SymlinksIfOwnerMatch";
};
};
VirtualHost = {
"*:80" = {
ProxyPassMatch =
[
"^/(.*\.php(/.*)?)$"
"unix:${config.services.php-fpm.pools.main.socket}|fcgi://localhost/var/www/"
];
Directory = {
"/var/www" = {
Require = [ "all" "granted" ];
Options = [ "-Indexes" "+FollowSymlinks" ];
DirectoryIndex = "\${DIRECTORY_INDEX:-index.html}";
};
};
};
};
}
];
};
};
});
};
};
}
thats a flake which does what you want, youre not meant to consume the examples directly, theyre examples. make a flake which depends on nixng like i showed above
Thank you very much!
you re not meant to consume the examples directly, they re examples.
Understand, just made it easier for now to show the hurdles encountered.
So would it be possible to reuse the flake by passing the image 'name' and' package' on build?
Which flake? you mean this one? just edit the example i gave you just now
probably a stupid question, but how do I build to a docker image from this flake?
nix build .#nixngConfigurations.php-example.config.system.build.ociImage.build
Hi,
Still very new at Nix syntax, just following examples and playing around.
Currently customizing the php-fpm example from your repo. Trying to get nix-phps packages to work with it.
Played around before with nix-phps on NixOS. There I would add nix-phps as input in flake.nix and pass it to imported nix files through specialArgs.
I don't seem to get that working with this php-fpm NixNG example.
Any suggestion?
Gr, J