Add first basic flake to be used as flake.nix in projects

The flake is very basic and encapsulates frontend compilation via node
for customer projects.
The flake is intended to be used by other flake.nix within the projects,
which will use the defined packages to build apps outputs.
They should use the packages like `writeShellApplication` itself,
call it with necessary argument set in order to receive a
out of the box working solution.

A template is also provided which can be used like:

    nix flake init -t <path to this flake>

`defaultTemplate` is defined in output and will be used.
This commit is contained in:
Daniel Siepmann 2022-02-10 19:04:33 +01:00
parent 2ba1a01f2c
commit de06dbcd13
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
3 changed files with 79 additions and 3 deletions

View file

@ -0,0 +1,37 @@
{
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

@ -0,0 +1,34 @@
{
description = "Concrete Flake for TYPO3 project.";
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";
};
outputs = {
self,
nixpkgs,
flake-utils,
typo3
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
packageJsonPath = "packages/sitepackage/Build/";
nodePkg = pkgs.nodejs-14_x;
in rec {
apps = rec {
compileAssets = typo3.lib.compileAssets {
inherit pkgs packageJsonPath nodePkg;
};
watchAssets = typo3.lib.watchAssets {
inherit pkgs compileAssets packageJsonPath nodePkg;
};
};
defaultApp = apps.compileAssets;
}
);
}

View file

@ -58,6 +58,10 @@ 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 for development projects.
Update
------
@ -98,9 +102,10 @@ Todos
* Migrate firefox (with geckodriver), thunderbird, ungoogled chromium
* Begin migrating local development to execute php. On a per customer project.
Use flakes?
Most are more or less the same, maybe provide a general flake inside this repo which can be used by projects?
Also include psysh
* I make use of https://github.com/fossar/nix-phps
* `flake.nix` and `flake.lock` need to be checked into a repo … How to handle that if customer doesn't want the file?
Maybe symlinks will work, so I've a dedicated repo with the project flakes and link them into project repos?
* Maybe PR upstream: `./home/modules/programs/languagetool.nix`.