flake: add custom lib with initial perl application builder

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2024-08-22 20:49:43 +02:00
parent 8b45301ab9
commit ae13670a64
Signed by: c8h4
GPG key ID: 6817E9C75C0785D7
2 changed files with 36 additions and 1 deletions

View file

@ -67,7 +67,10 @@
, sops-nix, lix-module, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = import nixpkgs {
inherit system;
overlays = [ (import ./lib) ];
};
inherit (pkgs) lib;
inherit (flake-utils.lib) mkApp;
@ -145,6 +148,7 @@
packages = (import ./pkgs) null pkgs;
}) // (let
overlays = [
(nixpkgs.lib.composeManyExtensions [ (import ./lib) ])
(import ./pkgs)
(self: super: {
vimPlugins = super.vimPlugins

31
lib/default.nix Normal file
View file

@ -0,0 +1,31 @@
_:
{ lib, writeTextFile, perl, perlPackages, ... }:
{
c8h4.buildPerlApplication = { name, text, perlInputs ? (_: [ ])
, runtimeInputs ? [ ], derivationArgs ? { } }:
writeTextFile {
inherit name derivationArgs;
executable = true;
destination = "/bin/${name}";
checkPhase = ''
runHook preCheck
${lib.getExe perlPackages.PerlCritic} $target
runHook postCheck
'';
text = ''
#!${lib.getExe (perl.withPackages perlInputs)}
use strict;
use warnings;
$ENV{PATH} = "${lib.makeBinPath runtimeInputs}:$ENV{PATH}";
${text}
'';
meta.mainProgram = name;
};
}