mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
Compare commits
4 Commits
3613abcbd7
...
9d32c214db
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d32c214db | ||
|
|
87785ddbc7 | ||
|
|
113b155fe8 | ||
|
|
398bc87bc8 |
@@ -213,11 +213,17 @@ in
|
||||
extraLuaConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
example = ''
|
||||
vim.opt.nobackup = true
|
||||
example = lib.literalExpression ''
|
||||
let
|
||||
nvimEarlyInit = lib.mkOrder 500 "set rtp+=vim.opt.rtp:prepend('/home/user/myplugin')";
|
||||
nvimLateInit = lib.mkAfter 1000 "vim.opt.signcolumn = 'auto:1-3'";
|
||||
in
|
||||
lib.mkMerge [ nvimEarlyInit nvimLateInit ];
|
||||
'';
|
||||
description = ''
|
||||
Custom lua lines.
|
||||
Content to be added to {file}`init.lua`.
|
||||
|
||||
To specify the order, use `lib.mkOrder`, `lib.mkBefore`, `lib.mkAfter`.
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -426,7 +432,10 @@ in
|
||||
(concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages)
|
||||
];
|
||||
|
||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
|
||||
wrappedNeovim' = pkgs.wrapNeovimUnstable cfg.package {
|
||||
withNodeJs = cfg.withNodeJs || cfg.coc.enable;
|
||||
plugins = map suppressNotVimlConfig pluginsNormalized;
|
||||
|
||||
inherit (cfg)
|
||||
extraPython3Packages
|
||||
withPython3
|
||||
@@ -434,34 +443,19 @@ in
|
||||
withPerl
|
||||
viAlias
|
||||
vimAlias
|
||||
;
|
||||
withNodeJs = cfg.withNodeJs || cfg.coc.enable;
|
||||
plugins = map suppressNotVimlConfig pluginsNormalized;
|
||||
customRC = cfg.extraConfig;
|
||||
};
|
||||
|
||||
wrappedNeovim' = pkgs.wrapNeovimUnstable cfg.package (
|
||||
neovimConfig
|
||||
// {
|
||||
inherit (cfg)
|
||||
extraName
|
||||
autowrapRuntimeDeps
|
||||
waylandSupport
|
||||
withNodeJs
|
||||
;
|
||||
neovimRcContent = cfg.extraConfig;
|
||||
wrapperArgs =
|
||||
neovimConfig.wrapperArgs
|
||||
++ cfg.extraWrapperArgs
|
||||
++ extraMakeWrapperArgs
|
||||
++ extraMakeWrapperLuaCArgs
|
||||
++ extraMakeWrapperLuaArgs;
|
||||
cfg.extraWrapperArgs ++ extraMakeWrapperArgs ++ extraMakeWrapperLuaCArgs ++ extraMakeWrapperLuaArgs;
|
||||
wrapRc = false;
|
||||
}
|
||||
);
|
||||
};
|
||||
in
|
||||
{
|
||||
programs.neovim = {
|
||||
generatedConfigViml = neovimConfig.neovimRcContent;
|
||||
generatedConfigViml = cfg.extraConfig;
|
||||
|
||||
generatedConfigs =
|
||||
let
|
||||
@@ -484,22 +478,21 @@ in
|
||||
shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
|
||||
};
|
||||
|
||||
xdg.configFile =
|
||||
let
|
||||
hasLuaConfig = lib.hasAttr "lua" config.programs.neovim.generatedConfigs;
|
||||
luaRcContent =
|
||||
lib.optionalString (
|
||||
wrappedNeovim'.initRc != ""
|
||||
) "vim.cmd [[source ${pkgs.writeText "nvim-init-home-manager.vim" wrappedNeovim'.initRc}]]\n"
|
||||
+ config.programs.neovim.extraLuaConfig
|
||||
+ lib.optionalString hasLuaConfig config.programs.neovim.generatedConfigs.lua;
|
||||
in
|
||||
lib.mkMerge (
|
||||
programs.neovim.extraLuaConfig = lib.mkMerge [
|
||||
(lib.mkIf (wrappedNeovim'.initRc != "") (
|
||||
lib.mkBefore "vim.cmd [[source ${pkgs.writeText "nvim-init-home-manager.vim" wrappedNeovim'.initRc}]]"
|
||||
))
|
||||
(lib.mkIf (lib.hasAttr "lua" cfg.generatedConfigs) (lib.mkAfter cfg.generatedConfigs.lua))
|
||||
];
|
||||
|
||||
xdg.configFile = lib.mkMerge (
|
||||
# writes runtime
|
||||
(map (x: x.runtime) pluginsNormalized)
|
||||
++ [
|
||||
{
|
||||
"nvim/init.lua" = mkIf (luaRcContent != "") { text = luaRcContent; };
|
||||
"nvim/init.lua" = mkIf (cfg.extraLuaConfig != "") {
|
||||
text = cfg.extraLuaConfig;
|
||||
};
|
||||
|
||||
"nvim/coc-settings.json" = mkIf cfg.coc.enable {
|
||||
source = jsonFormat.generate "coc-settings.json" cfg.coc.settings;
|
||||
|
||||
@@ -12,6 +12,7 @@ let
|
||||
|
||||
packageVersion = if cfg.package != null then lib.getVersion cfg.package else null;
|
||||
themeIsToml = lib.versionAtLeast packageVersion "0.15.0";
|
||||
versionPost0_17 = lib.versionAtLeast packageVersion "0.17.0";
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.leiserfg ];
|
||||
@@ -43,7 +44,12 @@ in
|
||||
useLayerShell = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "If vicinae should use the layer shell";
|
||||
description = ''
|
||||
Whether vicinae should use the layer shell.
|
||||
If you are using version 0.17 or newer, you should use
|
||||
{option}.programs.vicinae.settings.launcher_window.layer_shell.enabled = false
|
||||
instead.
|
||||
'';
|
||||
};
|
||||
|
||||
extensions = lib.mkOption {
|
||||
@@ -127,7 +133,7 @@ in
|
||||
settings = lib.mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
description = "Settings written as JSON to `~/.config/vicinae/vicinae.json.";
|
||||
description = "Settings written as JSON to `~/.config/vicinae/settings.json.";
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
faviconService = "twenty";
|
||||
@@ -158,6 +164,10 @@ in
|
||||
assertion = cfg.systemd.enable -> cfg.package != null;
|
||||
message = "{option}programs.vicinae.systemd.enable requires non null {option}programs.vicinae.package";
|
||||
}
|
||||
{
|
||||
assertion = !cfg.useLayerShell -> !versionPost0_17;
|
||||
message = ''After version 0.17, if you want to explicitly disable the use of layer shell, you need to set {option}.programs.vicinae.settings.launcher_window.layer_shell.enabled = false.'';
|
||||
}
|
||||
];
|
||||
lib.vicinae.mkExtension = (
|
||||
{
|
||||
@@ -223,10 +233,11 @@ in
|
||||
source = themeFormat.generate "vicinae-${name}-theme" theme;
|
||||
}
|
||||
) cfg.themes;
|
||||
settingsPath = if versionPost0_17 then "vicinae/settings.json" else "vicinae/vicinae.json";
|
||||
in
|
||||
{
|
||||
configFile = {
|
||||
"vicinae/vicinae.json" = lib.mkIf (cfg.settings != { }) {
|
||||
"${settingsPath}" = lib.mkIf (cfg.settings != { }) {
|
||||
source = jsonFormat.generate "vicinae-settings" cfg.settings;
|
||||
};
|
||||
}
|
||||
@@ -250,14 +261,16 @@ in
|
||||
PartOf = [ cfg.systemd.target ];
|
||||
};
|
||||
Service = {
|
||||
EnvironmentFile = pkgs.writeText "vicinae-env" ''
|
||||
USE_LAYER_SHELL=${if cfg.useLayerShell then builtins.toString 1 else builtins.toString 0}
|
||||
'';
|
||||
Type = "simple";
|
||||
ExecStart = "${lib.getExe' cfg.package "vicinae"} server";
|
||||
Restart = "always";
|
||||
RestartSec = 5;
|
||||
KillMode = "process";
|
||||
EnvironmentFile = lib.mkIf (!versionPost0_17) (
|
||||
pkgs.writeText "vicinae-env" ''
|
||||
USE_LAYER_SHELL=${if cfg.useLayerShell then builtins.toString 1 else builtins.toString 0}
|
||||
''
|
||||
);
|
||||
};
|
||||
Install = lib.mkIf cfg.systemd.autoStart {
|
||||
WantedBy = [ cfg.systemd.target ];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{ lib, pkgs, ... }:
|
||||
lib.optionalAttrs (pkgs.stdenv.hostPlatform.isLinux) {
|
||||
vicinae-pre17-settings = ./pre17-settings.nix;
|
||||
vicinae-example-settings = ./example-settings.nix;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
programs.vicinae = {
|
||||
enable = true;
|
||||
systemd.enable = true;
|
||||
|
||||
useLayerShell = false;
|
||||
settings = {
|
||||
faviconService = "twenty";
|
||||
font = {
|
||||
@@ -80,11 +80,16 @@
|
||||
];
|
||||
};
|
||||
|
||||
test.asserts.assertions.expected = [
|
||||
''After version 0.17, if you want to explicitly disable the use of layer shell, you need to set {option}.programs.vicinae.settings.launcher_window.layer_shell.enabled = false.''
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists "home-files/.config/vicinae/vicinae.json"
|
||||
assertFileExists "home-files/.config/vicinae/settings.json"
|
||||
assertFileExists "home-files/.config/systemd/user/vicinae.service"
|
||||
assertFileExists "home-files/.local/share/vicinae/themes/catppuccin-mocha.toml"
|
||||
assertFileExists "home-files/.local/share/vicinae/extensions/gif-search/package.json"
|
||||
assertFileExists "home-files/.local/share/vicinae/extensions/test-extension/package.json"
|
||||
assertFileContent "home-files/.config/systemd/user/vicinae.service" ${./service.service}
|
||||
'';
|
||||
}
|
||||
|
||||
46
tests/modules/programs/vicinae/pre17-settings.nix
Normal file
46
tests/modules/programs/vicinae/pre17-settings.nix
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.vicinae = {
|
||||
enable = true;
|
||||
systemd.enable = true;
|
||||
package = pkgs.stdenv.mkDerivation {
|
||||
pname = "fake-vicinae";
|
||||
version = "0.10.0";
|
||||
src = pkgs.emptyFile;
|
||||
buildCommand = "mkdir -p $out";
|
||||
meta = {
|
||||
mainProgram = "vicinae";
|
||||
};
|
||||
};
|
||||
|
||||
settings = {
|
||||
faviconService = "twenty";
|
||||
font = {
|
||||
size = 10;
|
||||
};
|
||||
popToRootOnClose = false;
|
||||
rootSearch = {
|
||||
searchFiles = false;
|
||||
};
|
||||
theme = {
|
||||
name = "vicinae-dark";
|
||||
};
|
||||
window = {
|
||||
csd = true;
|
||||
opacity = 0.95;
|
||||
rounding = 10;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists "home-files/.config/vicinae/vicinae.json"
|
||||
assertFileExists "home-files/.config/systemd/user/vicinae.service"
|
||||
assertFileContains "home-files/.config/systemd/user/vicinae.service" "EnvironmentFile"
|
||||
'';
|
||||
}
|
||||
15
tests/modules/programs/vicinae/service.service
Normal file
15
tests/modules/programs/vicinae/service.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@vicinae@/bin/vicinae server
|
||||
KillMode=process
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Type=simple
|
||||
|
||||
[Unit]
|
||||
After=graphical-session.target
|
||||
Description=Vicinae server daemon
|
||||
Documentation=https://docs.vicinae.com
|
||||
PartOf=graphical-session.target
|
||||
Reference in New Issue
Block a user