Hello,
Still learning how to build my dev stack in order to move from docker containers to a nix config.
Today I’m trying to install old php versions. But as I’m not using flakes for the moment, I was not able to use this repo GitHub - fossar/nix-phps: Repository of Nix expressions for old PHP versions
I tried something (without much hope) with fetchFromGitHub, but I’ve following error:
error: The option `_type' does not exist. Definition values:
- In `/nix/store/fhvx74k3dphdw26qd8gj70xdb8fvvmh2-source': "flake"
… while evaluating the attribute 'config'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:346:9:
345| options = checked options;
346| config = checked (removeAttrs config [ "_module" ]);
| ^
347| _module = checked (config._module);
My configuration
{ pkgs, config, lib, ... }:
let
# using pkgs2 to avoid recursive loop with fetchFromGitHub
# see https://stackoverflow.com/questions/73097604/nixos-how-to-import-some-configuration-from-gitlab-infinite-recursion-encounte
pkgs2 = (import <nixpkgs> { });
nix-phps = pkgs2.fetchFromGitHub {
owner = "fossar";
repo = "nix-phps";
rev = "ac2bb3d416a10fc66d0148dddc63a19c6c5a907c";
hash = "sha256-74kQIFf3Cu1aeOsohCiLuA1aXNGYt2U9tTUP0yvm4EA=";
};
in
{
imports = [ "${nix-phps}" ];
.....
Question : is there a way to install theses old php versions without using flakes ?
Thx
NobbZ
February 22, 2023, 6:16pm
2
You can use one of the following:
Use builtins.getFlake
if your nix is new enough
Use GitHub - edolstra/flake-compat
fetchFromGitHub
the repository and mimic what the flake does to create its packages
outputs. This will have several down sides though, IFD is one of them, random breakage another, as the file layout within the repository is usually not considered “part of the contract”.
tejing
February 22, 2023, 6:38pm
3
The IFD part can be avoided by using a builtin fetcher, such as builtins.fetchTarball { url = "https://github.com/owner/repo/archive/rev.tar.gz"; hash = ""; }
jtojnar
February 22, 2023, 6:53pm
4
imports
is for NixOS modules. nix-phps
does not contain any.
Without flakes, you will want to follow the niv example , just replace import sources.nix-phps
with import nix-phps
(as you defined it).
While it uses flakes undearneath, using devenv
you can avoid all that boilerplate:
{ pkgs, config, ... }:
{
languages.php = {
enable = true;
version = "8.1";
ini = ''
memory_limit = 256M
'';
fpm.pools.web = {
settings = {
"pm" = "dynamic";
"pm.max_children" = 5;
"pm.start_servers" = 2;
"pm.min_spare_servers" = 1;
"pm.max_spare_servers" = 5;
1 Like
Thx jtojnar, it works !
For example, phpfpm with php 5.6
{ pkgs, config, lib, ... }:
let
# using pkgs2 to avoid recursive loop with fetchFromGitHub
# see https://stackoverflow.com/questions/73097604/nixos-how-to-import-some-configuration-from-gitlab-infinite-recursion-encounte
pkgs2 = (import <nixpkgs> { });
nix-phps = pkgs2.fetchFromGitHub {
owner = "fossar";
repo = "nix-phps";
rev = "ac2bb3d416a10fc66d0148dddc63a19c6c5a907c";
hash = "sha256-74kQIFf3Cu1aeOsohCiLuA1aXNGYt2U9tTUP0yvm4EA=";
};
phps = import nix-phps;
in
{
services.phpfpm.pools = {
"php56" = {
user = config.services.caddy.user;
group = config.services.caddy.group;
phpPackage = phps.packages.${builtins.currentSystem}.php56;
settings = {
"listen.owner" = config.services.caddy.user;
"pm" = "dynamic";
"pm.max_children" = 75;
"pm.start_servers" = 10;
"pm.min_spare_servers" = 5;
"pm.max_spare_servers" = 20;
"pm.max_requests" = 500;
};
}
}
Thx for devenv link, I’ll look into it.