lib: move buildPerlApplication to dedicated build-support module

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2024-08-25 23:01:56 +02:00
parent 6f656dff2f
commit 200355c7ec
Signed by: c8h4
GPG key ID: 6817E9C75C0785D7
3 changed files with 49 additions and 45 deletions

View file

@ -65,13 +65,20 @@
outputs = { self, nixpkgs, home-manager, nixos-hardware
, simple-nixos-mailserver, nixgl, flake-utils, treefmt-nix, nixinate
, sops-nix, lix-module, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
lib = nixpkgs.lib.extend (import ./lib);
overlays = [
(nixpkgs.lib.composeManyExtensions
[ (import ./pkgs/build-support.nix) ])
(_: super: import ./pkgs super)
(_: super: {
vimPlugins = super.vimPlugins
// (import ./pkgs/vim-plugins.nix super);
})
];
in (flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import ./lib) ];
};
inherit (pkgs) lib;
pkgs = import nixpkgs { inherit lib overlays system; };
inherit (flake-utils.lib) mkApp;
treefmt = treefmt-nix.lib.evalModule pkgs {
@ -146,15 +153,7 @@
};
packages = (import ./pkgs) null pkgs;
}) // (let
overlays = [
(nixpkgs.lib.composeManyExtensions [ (import ./lib) ])
(import ./pkgs)
(self: super: {
vimPlugins = super.vimPlugins
// (import ./pkgs/vim-plugins.nix self super);
})
];
})) // (let
machines = {
back = { };
fort = { };
@ -163,10 +162,12 @@
[ nixos-hardware.nixosModules.framework-12th-gen-intel ];
zero = { };
};
mkSystem = name:
{ extraModules ? [ ], system ? "x86_64-linux" }:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit lib; };
modules = [
sops-nix.nixosModules.sops
simple-nixos-mailserver.nixosModules.mailserver

View file

@ -1,31 +1,3 @@
_:
{ 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;
};
}
{ }

31
pkgs/build-support.nix Normal file
View file

@ -0,0 +1,31 @@
_:
{ lib, perl, perlPackages, writeTextFile, ... }:
{
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;
};
}