mirror of
https://github.com/foo-dogsquared/nix-module-wrapper-manager-fds.git
synced 2025-01-30 22:57:58 +00:00
wrapper-manager-fds/modules: init module for home-manager and NixOS integration
This commit is contained in:
parent
605f336349
commit
6a3e1a494d
88
modules/env/common.nix
vendored
Normal file
88
modules/env/common.nix
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.wrapper-manager;
|
||||
|
||||
wrapperManagerModule = lib.types.submoduleWith {
|
||||
description = "wrapper-manager module";
|
||||
class = "wrapperManager";
|
||||
specialArgs = cfg.extraSpecialArgs // {
|
||||
modulesPath = builtins.toString ../wrapper-manager;
|
||||
};
|
||||
modules = [
|
||||
({ lib, name, ... }: {
|
||||
imports = [ ../wrapper-manager ];
|
||||
config.executableName = lib.mkDefault name;
|
||||
})
|
||||
] ++ cfg.sharedModules;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.wrapper-manager = {
|
||||
sharedModules = lib.mkOption {
|
||||
type = with lib.types; listOf deferredModule;
|
||||
default = [ ];
|
||||
example = lib.literalExpression ''
|
||||
[
|
||||
{
|
||||
config.build = {
|
||||
variant = "package";
|
||||
isBinary = true;
|
||||
};
|
||||
}
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
Extra modules to be added to all of the wrappers.
|
||||
'';
|
||||
};
|
||||
|
||||
wrappers = lib.mkOption {
|
||||
type = lib.types.attrsOf wrapperManagerModule;
|
||||
description = ''
|
||||
A set of wrappers to be added into the environment configuration.
|
||||
'';
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
neofetch = {
|
||||
arg0 = lib.getExe' pkgs.neofetch "neofetch";
|
||||
appendArgs = [
|
||||
"--ascii-distro" "guix"
|
||||
"--config" ./config/neofetch/config
|
||||
];
|
||||
};
|
||||
|
||||
yt-dlp-audio = {
|
||||
arg0 = lib.getExe' pkgs.yt-dlp "yt-dlp";
|
||||
prependArgs = [
|
||||
"--config-location" ./config/yt-dlp/audio.conf
|
||||
];
|
||||
};
|
||||
|
||||
asciidoctor-fds = {
|
||||
arg = lib.getExe' pkgs.asciidoctor-with-extensions "asciidoctor";
|
||||
executableName = "asciidoctor";
|
||||
prependArgs =
|
||||
builtins.map (v: "-r ''${v}") [
|
||||
"asciidoctor-diagram"
|
||||
"asciidoctor-bibtex"
|
||||
];
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
extraSpecialArgs = lib.mkOption {
|
||||
type = with lib.types; attrsOf anything;
|
||||
default = { };
|
||||
description = ''
|
||||
Additional set of module arguments to be passed to `specialArgs` of
|
||||
the wrapper module evaluation.
|
||||
'';
|
||||
example = {
|
||||
yourMomName = "Joe Mama";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
21
modules/env/home-manager/default.nix
vendored
Normal file
21
modules/env/home-manager/default.nix
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.wrapper-manager;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../common.nix
|
||||
];
|
||||
|
||||
options.wrapper-manager.wrappers = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
specialArgs.hmConfig = config;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.wrappers != {}) {
|
||||
home.packages =
|
||||
lib.mapAttrsToList (_: wrapper: wrapper.config.build.toplevel) cfg.wrappers;
|
||||
};
|
||||
}
|
21
modules/env/nixos/default.nix
vendored
Normal file
21
modules/env/nixos/default.nix
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.wrapper-manager;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../common.nix
|
||||
];
|
||||
|
||||
options.wrapper-manager.wrappers = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
specialArgs.nixosConfig = config;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.wrappers != {}) {
|
||||
environment.systemPackages =
|
||||
lib.mapAttrsToList (_: wrapper: wrapper.config.build.toplevel) cfg.wrappers;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user