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 {
|
extraLuaConfig = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
example = ''
|
example = lib.literalExpression ''
|
||||||
vim.opt.nobackup = true
|
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 = ''
|
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)
|
(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)
|
inherit (cfg)
|
||||||
extraPython3Packages
|
extraPython3Packages
|
||||||
withPython3
|
withPython3
|
||||||
@@ -434,34 +443,19 @@ in
|
|||||||
withPerl
|
withPerl
|
||||||
viAlias
|
viAlias
|
||||||
vimAlias
|
vimAlias
|
||||||
|
extraName
|
||||||
|
autowrapRuntimeDeps
|
||||||
|
waylandSupport
|
||||||
;
|
;
|
||||||
withNodeJs = cfg.withNodeJs || cfg.coc.enable;
|
neovimRcContent = cfg.extraConfig;
|
||||||
plugins = map suppressNotVimlConfig pluginsNormalized;
|
wrapperArgs =
|
||||||
customRC = cfg.extraConfig;
|
cfg.extraWrapperArgs ++ extraMakeWrapperArgs ++ extraMakeWrapperLuaCArgs ++ extraMakeWrapperLuaArgs;
|
||||||
|
wrapRc = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
wrappedNeovim' = pkgs.wrapNeovimUnstable cfg.package (
|
|
||||||
neovimConfig
|
|
||||||
// {
|
|
||||||
inherit (cfg)
|
|
||||||
extraName
|
|
||||||
autowrapRuntimeDeps
|
|
||||||
waylandSupport
|
|
||||||
withNodeJs
|
|
||||||
;
|
|
||||||
wrapperArgs =
|
|
||||||
neovimConfig.wrapperArgs
|
|
||||||
++ cfg.extraWrapperArgs
|
|
||||||
++ extraMakeWrapperArgs
|
|
||||||
++ extraMakeWrapperLuaCArgs
|
|
||||||
++ extraMakeWrapperLuaArgs;
|
|
||||||
wrapRc = false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
programs.neovim = {
|
programs.neovim = {
|
||||||
generatedConfigViml = neovimConfig.neovimRcContent;
|
generatedConfigViml = cfg.extraConfig;
|
||||||
|
|
||||||
generatedConfigs =
|
generatedConfigs =
|
||||||
let
|
let
|
||||||
@@ -484,29 +478,28 @@ in
|
|||||||
shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
|
shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.configFile =
|
programs.neovim.extraLuaConfig = lib.mkMerge [
|
||||||
let
|
(lib.mkIf (wrappedNeovim'.initRc != "") (
|
||||||
hasLuaConfig = lib.hasAttr "lua" config.programs.neovim.generatedConfigs;
|
lib.mkBefore "vim.cmd [[source ${pkgs.writeText "nvim-init-home-manager.vim" wrappedNeovim'.initRc}]]"
|
||||||
luaRcContent =
|
))
|
||||||
lib.optionalString (
|
(lib.mkIf (lib.hasAttr "lua" cfg.generatedConfigs) (lib.mkAfter cfg.generatedConfigs.lua))
|
||||||
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 (
|
|
||||||
# writes runtime
|
|
||||||
(map (x: x.runtime) pluginsNormalized)
|
|
||||||
++ [
|
|
||||||
{
|
|
||||||
"nvim/init.lua" = mkIf (luaRcContent != "") { text = luaRcContent; };
|
|
||||||
|
|
||||||
"nvim/coc-settings.json" = mkIf cfg.coc.enable {
|
xdg.configFile = lib.mkMerge (
|
||||||
source = jsonFormat.generate "coc-settings.json" cfg.coc.settings;
|
# writes runtime
|
||||||
};
|
(map (x: x.runtime) pluginsNormalized)
|
||||||
}
|
++ [
|
||||||
]
|
{
|
||||||
);
|
"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;
|
packageVersion = if cfg.package != null then lib.getVersion cfg.package else null;
|
||||||
themeIsToml = lib.versionAtLeast packageVersion "0.15.0";
|
themeIsToml = lib.versionAtLeast packageVersion "0.15.0";
|
||||||
|
versionPost0_17 = lib.versionAtLeast packageVersion "0.17.0";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta.maintainers = [ lib.maintainers.leiserfg ];
|
meta.maintainers = [ lib.maintainers.leiserfg ];
|
||||||
@@ -43,7 +44,12 @@ in
|
|||||||
useLayerShell = lib.mkOption {
|
useLayerShell = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
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 {
|
extensions = lib.mkOption {
|
||||||
@@ -127,7 +133,7 @@ in
|
|||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
inherit (jsonFormat) type;
|
inherit (jsonFormat) type;
|
||||||
default = { };
|
default = { };
|
||||||
description = "Settings written as JSON to `~/.config/vicinae/vicinae.json.";
|
description = "Settings written as JSON to `~/.config/vicinae/settings.json.";
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
{
|
{
|
||||||
faviconService = "twenty";
|
faviconService = "twenty";
|
||||||
@@ -158,6 +164,10 @@ in
|
|||||||
assertion = cfg.systemd.enable -> cfg.package != null;
|
assertion = cfg.systemd.enable -> cfg.package != null;
|
||||||
message = "{option}programs.vicinae.systemd.enable requires non null {option}programs.vicinae.package";
|
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 = (
|
lib.vicinae.mkExtension = (
|
||||||
{
|
{
|
||||||
@@ -223,10 +233,11 @@ in
|
|||||||
source = themeFormat.generate "vicinae-${name}-theme" theme;
|
source = themeFormat.generate "vicinae-${name}-theme" theme;
|
||||||
}
|
}
|
||||||
) cfg.themes;
|
) cfg.themes;
|
||||||
|
settingsPath = if versionPost0_17 then "vicinae/settings.json" else "vicinae/vicinae.json";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
configFile = {
|
configFile = {
|
||||||
"vicinae/vicinae.json" = lib.mkIf (cfg.settings != { }) {
|
"${settingsPath}" = lib.mkIf (cfg.settings != { }) {
|
||||||
source = jsonFormat.generate "vicinae-settings" cfg.settings;
|
source = jsonFormat.generate "vicinae-settings" cfg.settings;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -250,14 +261,16 @@ in
|
|||||||
PartOf = [ cfg.systemd.target ];
|
PartOf = [ cfg.systemd.target ];
|
||||||
};
|
};
|
||||||
Service = {
|
Service = {
|
||||||
EnvironmentFile = pkgs.writeText "vicinae-env" ''
|
|
||||||
USE_LAYER_SHELL=${if cfg.useLayerShell then builtins.toString 1 else builtins.toString 0}
|
|
||||||
'';
|
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${lib.getExe' cfg.package "vicinae"} server";
|
ExecStart = "${lib.getExe' cfg.package "vicinae"} server";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = 5;
|
RestartSec = 5;
|
||||||
KillMode = "process";
|
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 {
|
Install = lib.mkIf cfg.systemd.autoStart {
|
||||||
WantedBy = [ cfg.systemd.target ];
|
WantedBy = [ cfg.systemd.target ];
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{ lib, pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
lib.optionalAttrs (pkgs.stdenv.hostPlatform.isLinux) {
|
lib.optionalAttrs (pkgs.stdenv.hostPlatform.isLinux) {
|
||||||
|
vicinae-pre17-settings = ./pre17-settings.nix;
|
||||||
vicinae-example-settings = ./example-settings.nix;
|
vicinae-example-settings = ./example-settings.nix;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
programs.vicinae = {
|
programs.vicinae = {
|
||||||
enable = true;
|
enable = true;
|
||||||
systemd.enable = true;
|
systemd.enable = true;
|
||||||
|
useLayerShell = false;
|
||||||
settings = {
|
settings = {
|
||||||
faviconService = "twenty";
|
faviconService = "twenty";
|
||||||
font = {
|
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 = ''
|
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/.config/systemd/user/vicinae.service"
|
||||||
assertFileExists "home-files/.local/share/vicinae/themes/catppuccin-mocha.toml"
|
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/gif-search/package.json"
|
||||||
assertFileExists "home-files/.local/share/vicinae/extensions/test-extension/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