Cleanup nix flakes + shells

Remove flakes for now.
I will use shells for now to not have a mixed setup.
Add composer v1 for a single customer project as overlay due to usage in
shell instead of flakes.

Adjust folder to not have unnecessary deep structure.

Add shell for reuter monorepo using composer v1.
This commit is contained in:
Daniel Siepmann 2022-04-14 15:46:49 +02:00
parent ee2e7d04e1
commit df46cb05ed
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
15 changed files with 207 additions and 242 deletions

View file

@ -1,50 +0,0 @@
{
description = "Composer v1 for single legacy project.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
phps.url = "github:fossar/nix-phps/master";
};
outputs = {
self,
nixpkgs,
phps
}: {
defaultPackage.x86_64-linux =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
php = phps.packages.x86_64-linux.php73;
version = "1.10.25";
in pkgs.stdenv.mkDerivation {
pname = "composer";
inherit version;
src = pkgs.fetchurl {
url = "https://getcomposer.org/download/${version}/composer.phar";
sha256 = "sha256-awib2LeLAMPBXXsTNT+8vfFqP1JIIDyaPnbxOUjy3pI=";
};
dontUnpack = true;
nativeBuildInputs = [ pkgs.makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -D $src $out/libexec/composer/composer.phar
makeWrapper ${php}/bin/php $out/bin/composer \
--add-flags "$out/libexec/composer/composer.phar" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.unzip ]}
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Dependency Manager for PHP";
license = licenses.mit;
homepage = "https://getcomposer.org/";
changelog = "https://github.com/composer/composer/releases/tag/${version}";
};
};
};
}

View file

@ -1,96 +0,0 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1644472683,
"narHash": "sha256-sP6iM4NksOYO6NFfTJ96cg+ClPnq6cdY30xKA1iYtyU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7adc9c14ec74b27358a8df9b973087e351425a79",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1644486793,
"narHash": "sha256-EeijR4guVHgVv+JpOX3cQO+1XdrkJfGmiJ9XVsVU530=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1882c6b7368fd284ad01b0a5b5601ef136321292",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"phps": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
},
"locked": {
"lastModified": 1644723316,
"narHash": "sha256-puoznqr0U6A/IK92xDi5pzzwCQn6WJs+4p+PJ7D3yGk=",
"owner": "fossar",
"repo": "nix-phps",
"rev": "2f2d11dd2411fd563fc91798b0c66ac7338aafa3",
"type": "github"
},
"original": {
"owner": "fossar",
"ref": "master",
"repo": "nix-phps",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"phps": "phps"
}
},
"utils": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,50 +0,0 @@
{
description = "Composer v2 for single legacy project.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
phps.url = "github:fossar/nix-phps/master";
};
outputs = {
self,
nixpkgs,
phps
}: {
defaultPackage.x86_64-linux =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
php = phps.packages.x86_64-linux.php81;
version = "2.2.6";
in pkgs.stdenv.mkDerivation {
pname = "composer";
inherit version;
src = pkgs.fetchurl {
url = "https://getcomposer.org/download/${version}/composer.phar";
sha256 = "sha256-HVhIa4keWengZMDVS7OFOPdNYBT3VIFULGmthNTpdwQ=";
};
dontUnpack = true;
nativeBuildInputs = [ pkgs.makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -D $src $out/libexec/composer/composer.phar
makeWrapper ${php}/bin/php $out/bin/composer \
--add-flags "$out/libexec/composer/composer.phar" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.unzip ]}
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Dependency Manager for PHP";
license = licenses.mit;
homepage = "https://getcomposer.org/";
changelog = "https://github.com/composer/composer/releases/tag/${version}";
};
};
};
}

View file

@ -1,37 +0,0 @@
{
description = "Flake for TYPO3 Projects specific to customer wm.";
outputs = {
self
}: {
lib = {
compileAssets = { packageJsonPath, nodePkg, pkgs }: pkgs.writeShellApplication {
name = "compileAssets";
runtimeInputs = [
nodePkg
pkgs.nodePackages.npm
];
text = ''
npm ci --prefix=${packageJsonPath}
npm run style --prefix=${packageJsonPath}
npm run js --prefix=${packageJsonPath}
'';
};
watchAssets = { packageJsonPath, compileAssets, nodePkg, pkgs }: pkgs.writeShellApplication {
name = "watchAssets";
runtimeInputs = [
nodePkg
pkgs.nodePackages.npm
];
text = ''
${compileAssets}/bin/compileAssets
npm run watch --prefix=${packageJsonPath}
'';
};
};
defaultTemplate = {
path = ./template;
};
};
}

View file

@ -124,6 +124,7 @@
};
home.file = {
".nix-channels".source = ./home/files/nix-channels;
".profile".source = ./home/files/profile;
".myclirc".source = ./home/files/myclirc;
".agignore".source = ./home/files/agignore;

3
home/files/nix-channels Normal file
View file

@ -0,0 +1,3 @@
https://nixos.org/channels/nixpkgs-unstable nixpkgs
https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
https://github.com/fossar/nix-phps/archive/master.tar.gz phps

View file

@ -48,6 +48,8 @@
"*.~lock.*#"
# As I'm using Makefiles in many projects for my own confidence
"Makefile"
# As I'm using nix-shell in many projects for my own confidence
"shell.nix"
# Some generics which occur in some projects
"build/"

View file

@ -0,0 +1,34 @@
{ stdenv, fetchurl, makeWrapper, unzip, lib, php }:
let
pname = "composer";
version = "1.10.26";
in stdenv.mkDerivation {
inherit pname version;
src = fetchurl {
url = "https://getcomposer.org/download/${version}/composer.phar";
sha256 = "sha256-y/4fhSdsV6vkZNk0UD2TWqITSUrChidcjfq/qR49vcQ=";
};
dontUnpack = true;
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -D $src $out/libexec/composer/composer.phar
makeWrapper ${php}/bin/php $out/bin/composer \
--add-flags "$out/libexec/composer/composer.phar" \
--prefix PATH : ${lib.makeBinPath [ unzip ]}
runHook postInstall
'';
meta = with lib; {
description = "Dependency Manager for PHP";
license = licenses.mit;
homepage = "https://getcomposer.org/";
changelog = "https://github.com/composer/composer/releases/tag/${version}";
maintainers = with maintainers; [ offline ] ++ teams.php.members;
};
}

View file

@ -0,0 +1,3 @@
self: super: {
composer1 = self.callPackage ./composer.nix { };
}

View file

@ -58,9 +58,11 @@ It has the following sub folder:
Each file corresponds to a single service.
Each file is loaded within `home.nix`.
`flakes/`
Holds structure with specific flakes.
Those should provide libraries and template.
`shells/`
Holds shells for customer projects.
The customers are not aware of Nix and I don't want to stress them.
I use this folder to have them in version control and symlink them into the
project.
Update
------

View file

@ -0,0 +1,38 @@
{
pkgs ? import <nixpkgs> { },
phpsChannel ? import <phps>
}:
let
phps = phpsChannel.packages.x86_64-linux;
php = phps.php73.buildEnv {
# We are in CLI Context and need other defaults
extraConfig = "memory_limit = 5G";
};
composer = pkgs.composer1.override {
inherit php;
};
in pkgs.mkShell {
name = "TYPO3";
buildInputs = [
php
composer
];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
export PS1="\033[0;32m\]\W >\[\033[0m\] "
export typo3DatabaseName=testing
export typo3DatabaseHost=localhost
export typo3DatabaseUsername=testing
export typo3DatabasePassword=testing
export TYPO3_CONTEXT=Development/dsiepmann
export TYPO3_DATABASE=emoto2_reuter
export TYPO3_BASE=https://reuter.emoto2.localhost/
export TYPO3_ADDITIONAL_CONFIGURATION=/home/daniels/.local/share/typo3-configuration/AdditionalConfiguration.inc.php
'';
}

56
shells/sac/shell.nix Normal file
View file

@ -0,0 +1,56 @@
{ pkgs ? import <nixpkgs> { } }:
let
php = pkgs.php74.buildEnv {
# We are in CLI Context and need other defaults
extraConfig = "memory_limit = 5G";
};
projectCsFixer = pkgs.writeShellApplication {
name = "projectCsFixer";
runtimeInputs = [
php
];
text = ''
rm -f "$PROJECT_ROOT/.php_cs.cache"
"$PROJECT_ROOT/vendor/bin/php-cs-fixer" fix --config "$PROJECT_ROOT/.php_cs.php"
git s;
'';
};
projectPhpStan = pkgs.writeShellApplication {
name = "projectPhpStan";
runtimeInputs = [
php
];
text = ''
rm -rf "$TMP/phpstan/"
"$PROJECT_ROOT/vendor/bin/codecept" build
"$PROJECT_ROOT/vendor/bin/phpstan"
'';
};
in pkgs.mkShell {
name = "TYPO3";
buildInputs = [
php
pkgs.php74Packages.composer
projectCsFixer
projectPhpStan
];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
export PS1="\033[0;32m\]\W >\[\033[0m\] "
export typo3DatabaseName=testing
export typo3DatabaseHost=localhost
export typo3DatabaseUsername=testing
export typo3DatabasePassword=testing
export TYPO3_CONTEXT=Development/dsiepmann
export TYPO3_DATABASE=sac_sac
export TYPO3_BASE=https://www.sac-cas.ch.local/
export TYPO3_ADDITIONAL_CONFIGURATION=/home/daniels/.local/share/typo3-configuration/AdditionalConfiguration.inc.php
'';
}

View file

@ -0,0 +1,30 @@
{ pkgs ? import <nixpkgs> { } }:
let
compileAssets = pkgs.writeShellApplication {
name = "compileAssets";
runtimeInputs = [
pkgs.nodejs-12_x
pkgs.nodePackages.npm
];
text = ''
rm -rf "$PROJECT_ROOT/packages/sitepackage/Resources/Public/Stylesheets"
rm -rf "$PROJECT_ROOT/packages/sitepackage/Resources/Public/JavaScripts"
rm -rf "$PROJECT_ROOT/packages/sitepackage/Build/node_modules/"
npm ci --prefix="$PROJECT_ROOT/packages/sitepackage/Build/"
npm run style --prefix="$PROJECT_ROOT/packages/sitepackage/Build/"
npm run js --prefix="$PROJECT_ROOT/packages/sitepackage/Build/"
'';
};
in pkgs.mkShell {
name = "TYPO3Website";
buildInputs = [
compileAssets
pkgs.nodejs-12_x
];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
'';
}

View file

@ -1,10 +1,10 @@
{
description = "Concrete Flake for TYPO3 project.";
description = "First example for soziopolis";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
flake-utils.url = "github:numtide/flake-utils";
typo3.url = "git+https://gitea.daniel-siepmann.de/danielsiepmann/nixpkgs?ref=main&dir=flakes/projects/web/typo3/wm-specific";
typo3.url = "/home/daniels/.config/nixpkgs/flakes/projects/web/typo3";
};
outputs = {
@ -16,15 +16,16 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
packageJsonPath = "packages/sitepackage/Build/";
nodePkg = pkgs.nodejs-14_x;
packageJsonPath = "packages/soziopolis/Build/";
in rec {
apps = rec {
compileAssets = typo3.lib.compileAssets {
inherit pkgs packageJsonPath nodePkg;
inherit pkgs packageJsonPath;
nodePkg = pkgs.nodejs-14_x;
};
watchAssets = typo3.lib.watchAssets {
inherit pkgs compileAssets packageJsonPath nodePkg;
inherit pkgs compileAssets packageJsonPath;
nodePkg = pkgs.nodejs-14_x;
};
};

View file

@ -0,0 +1,28 @@
{ pkgs ? import <nixpkgs> { } }:
let
compileAssets = pkgs.writeShellApplication {
name = "compileAssets";
runtimeInputs = [
pkgs.nodejs-14_x
pkgs.nodePackages.npm
];
text = ''
rm -rf "$PROJECT_ROOT/packages/soziopolis/Build/node_modules/"
npm ci --prefix="$PROJECT_ROOT/packages/soziopolis/Build/"
npm run style --prefix="$PROJECT_ROOT/packages/soziopolis/Build/"
npm run js --prefix="$PROJECT_ROOT/packages/soziopolis/Build/"
'';
};
in pkgs.mkShell {
name = "TYPO3Website";
buildInputs = [
compileAssets
pkgs.nodejs-14_x
];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
'';
}