1
Fork 0
satellite/modules/common/lua-lib.nix
Matei Adriel b737d4e7ab
Clean up neovim modules
Additionally, hack my way around smos issues
2024-01-12 01:01:22 +01:00

31 lines
923 B
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ config, lib, pkgs, ... }:
{
options.satellite.lib.lua = {
writeFile = lib.mkOption {
type = with lib.types; functionTo (functionTo (functionTo path));
description = "Format and write a lua file to disk";
};
};
options.satellite.lua.styluaConfig = lib.mkOption {
type = lib.types.path;
description = "Config to use for formatting lua modules";
};
config.satellite.lib.lua = {
writeFile = path: name: text:
let
destination = "${path}/${name}.lua";
unformatted = pkgs.writeText "raw-lua-${name}" ''
-- I was generated using nix ^~^
${text}
'';
in
pkgs.runCommand "formatted-lua-${name}" { } ''
mkdir -p $out/${path}
cp --no-preserve=mode ${unformatted} $out/${destination}
${lib.getExe pkgs.stylua} --config-path ${config.satellite.lua.styluaConfig} $out/${destination}
'';
};
}