mirror of
https://codeberg.org/spire/nix.git
synced 2026-11-30 11:30:45 +01:00
flakelight module
This commit is contained in:
parent
39dd269d01
commit
520cf4e47e
2 changed files with 65 additions and 0 deletions
|
|
@ -123,6 +123,11 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
imports = [flakelight.flakelightModules.extendFlakelight];
|
||||||
|
flakelightModule = {lib, ...}: {
|
||||||
|
imports = [./nix/flakelight-module.nix];
|
||||||
|
};
|
||||||
|
|
||||||
devShells.default = {pkgs, ...}: {
|
devShells.default = {pkgs, ...}: {
|
||||||
packages = with pkgs; [nix-update];
|
packages = with pkgs; [nix-update];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
60
nix/flakelight-module.nix
Normal file
60
nix/flakelight-module.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Copyright (C) 2026 Robin Appelman <robin@icewind.nl>
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
src,
|
||||||
|
config,
|
||||||
|
flakelight,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkMerge mkOption warnIf types filterAttrs readDir hasSuffix attrNames genAttrs mapAttrs removeSuffix map attrValues;
|
||||||
|
inherit (flakelight.types) function;
|
||||||
|
|
||||||
|
includes = pkgs: (config.includes pkgs.sourcepawn.includes) ++ [pkgs.sourcepawn.includes.sourcemod];
|
||||||
|
pluginsFileNames = attrNames (filterAttrs (name: ty: ty == "regular" && hasSuffix ".sp" name) (readDir config.pluginDir));
|
||||||
|
pluginNames = map (removeSuffix ".sp") pluginsFileNames;
|
||||||
|
in
|
||||||
|
warnIf (! builtins ? readFileType) "Unsupported Nix version in use."
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
includes = mkOption {
|
||||||
|
type = function;
|
||||||
|
default = _: [];
|
||||||
|
description = "sourcepawn includes to use";
|
||||||
|
};
|
||||||
|
pluginDir = mkOption {
|
||||||
|
type = with types; path;
|
||||||
|
default = src + "/plugin";
|
||||||
|
description = "directory containing the plugin sources";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkMerge [
|
||||||
|
{
|
||||||
|
withOverlays = [
|
||||||
|
(import ./overlay.nix)
|
||||||
|
];
|
||||||
|
|
||||||
|
packages = let
|
||||||
|
pluginPackages = genAttrs pluginNames (name: pkgs:
|
||||||
|
pkgs.buildSourcePawnScript {
|
||||||
|
inherit name;
|
||||||
|
outPath = "${name}.smx";
|
||||||
|
src = config.pluginDir + "/${name}.sp";
|
||||||
|
});
|
||||||
|
in
|
||||||
|
pluginPackages
|
||||||
|
// {
|
||||||
|
default = pkgs:
|
||||||
|
pkgs.symlinkJoin {
|
||||||
|
name = "plugins";
|
||||||
|
paths = attrValues (mapAttrs (_: plugin: plugin pkgs) pluginPackages);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default.packages = pkgs: [
|
||||||
|
(pkgs.sourcepawn.buildEnv (includes pkgs))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue