flake: add custom lib with initial perl application builder
Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
parent
8b45301ab9
commit
ae13670a64
|
@ -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
31
lib/default.nix
Normal 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;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue