Skip to content

Commit

Permalink
chore: re-organize files and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Apr 29, 2024
1 parent 0999bd0 commit 3e2cb19
Show file tree
Hide file tree
Showing 12 changed files with 489 additions and 366 deletions.
1 change: 1 addition & 0 deletions .user.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory_limit=-1
22 changes: 9 additions & 13 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).defaultNix
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).defaultNix
151 changes: 90 additions & 61 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,104 @@
systems.url = "github:nix-systems/default";
};

outputs = inputs @ { self, flake-parts, systems, ... }: flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
outputs =
inputs@{
self,
flake-parts,
systems,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;

flake = {
templates = {
basic = {
path = ./templates/basic;
description = "A basic template for getting started with PHP development";
welcomeText = builtins.readFile ./templates/basic/README.md;
};
};
imports = [
./src/imports/formatter.nix
./src/imports/overlay.nix
./src/imports/templates.nix
];

overlays.default = import ./src/overlay inputs;
};
flake = {
overlays.default = import ./src/overlay inputs;
};

perSystem = { self', inputs', config, pkgs, system, lib, ... }:
let
buildPhpFromComposer = pkgs.callPackage ./src/build-support/build-php-from-composer.nix { };
perSystem =
{
self',
inputs',
config,
pkgs,
system,
lib,
...
}:
let
buildPhpFromComposer = pkgs.callPackage ./src/build-support/build-php-from-composer.nix { };

phps = lib.mapAttrs
# To fix: Why using this while it is already in use in the overlay?
(name: value: buildPhpFromComposer { php = value; src = self; })
(lib.filterAttrs (k: v: lib.isDerivation v) (inputs.self.overlays.default null pkgs));
phps =
lib.mapAttrs
# To fix: Why using this while it is already in use in the overlay?
(
name: value:
buildPhpFromComposer {
php = value;
src = self;
}
)
(lib.filterAttrs (k: v: lib.isDerivation v) (inputs.self.overlays.default null pkgs));

envPackages = [
pkgs.symfony-cli
pkgs.sqlite
];
envPackages = [
pkgs.symfony-cli
pkgs.sqlite
];

packages = lib.foldlAttrs
(
carry: name: php:
carry // {
"${name}" = php;
"env-${name}" = pkgs.buildEnv { name = "env-${name}"; paths = [ php php.packages.composer ] ++ envPackages; };
packages =
lib.foldlAttrs
(
carry: name: php:
carry
// {
"${name}" = php;
"env-${name}" = pkgs.buildEnv {
name = "env-${name}";
paths = [
php
php.packages.composer
] ++ envPackages;
};
}
)
{
"default" = self'.packages.env-php81;
"env-default" = self'.packages.env-php81;
}
)
{
"default" = self'.packages.env-php81;
"env-default" = self'.packages.env-php81;
}
phps;
phps;

devShells = lib.foldlAttrs
(
carry: name: php:
devShells =
lib.foldlAttrs
(
carry: name: php:
{
"${name}" = pkgs.mkShellNoCC {
name = "${name}";
buildInputs = [
php
php.packages.composer
];
};
"env-${name}" = self'.devShells."${name}".overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ envPackages;
});
}
// carry
)
{
"${name}" = pkgs.mkShellNoCC { name = "${name}"; buildInputs = [ php php.packages.composer ]; };
"env-${name}" = self'.devShells."${name}".overrideAttrs (oldAttrs: { buildInputs = oldAttrs.buildInputs ++ envPackages; });
} // carry
)
{
"default" = self'.devShells.env-php81;
"env-default" = self'.devShells.env-php81;
}
phps;
in
{
_module.args.pkgs = import self.inputs.nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
config.allowUnfree = true;
"default" = self'.devShells.env-php81;
"env-default" = self'.devShells.env-php81;
}
phps;
in
{
inherit packages devShells;
};

formatter = pkgs.nixpkgs-fmt;

inherit packages devShells;
};
};
};
}
22 changes: 9 additions & 13 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).shellNix
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).shellNix
Loading

0 comments on commit 3e2cb19

Please sign in to comment.