mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
superfile: add pinnded folder and first use option
This commit is contained in:
parent
c39c07bf31
commit
0a5a165aca
3 changed files with 110 additions and 12 deletions
|
|
@ -7,7 +7,10 @@
|
|||
|
||||
let
|
||||
cfg = config.programs.superfile;
|
||||
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
||||
inherit (lib)
|
||||
literalExpression
|
||||
|
|
@ -23,6 +26,29 @@ let
|
|||
types
|
||||
hm
|
||||
;
|
||||
|
||||
pinnedFolderModule = types.submodule {
|
||||
freeformType = jsonFormat.type;
|
||||
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "Nix Store";
|
||||
description = ''
|
||||
Name that will be shown.
|
||||
'';
|
||||
};
|
||||
|
||||
location = mkOption {
|
||||
type = types.path;
|
||||
example = "/nix/store";
|
||||
description = ''
|
||||
Location of the pinned entry.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ hm.maintainers.LucasWagler ];
|
||||
|
|
@ -106,11 +132,38 @@ in
|
|||
};
|
||||
'';
|
||||
};
|
||||
|
||||
firstUseCheck = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Enables the first time use popup.
|
||||
'';
|
||||
};
|
||||
|
||||
pinnedFolders = mkOption {
|
||||
type = types.listOf pinnedFolderModule;
|
||||
default = [ ];
|
||||
example = literalExpression ''
|
||||
[
|
||||
{
|
||||
name = "Nix Store";
|
||||
location = "/nix/store";
|
||||
}
|
||||
];
|
||||
'';
|
||||
description = ''
|
||||
Entries that get added to the pinned panel.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
enableXdgConfig = !isDarwin || config.xdg.enable;
|
||||
baseConfigPath = if enableXdgConfig then "superfile" else "Library/Application Support/superfile";
|
||||
baseDataPath = if enableXdgConfig then "superfile" else "Library/Application Support/superfile";
|
||||
|
||||
themeSetting =
|
||||
if (!(cfg.settings ? theme) && cfg.themes != { }) then
|
||||
{
|
||||
|
|
@ -118,7 +171,6 @@ in
|
|||
}
|
||||
else
|
||||
{ };
|
||||
baseConfigPath = if enableXdgConfig then "superfile" else "Library/Application Support/superfile";
|
||||
configFile = mkIf (cfg.settings != { }) {
|
||||
"${baseConfigPath}/config.toml".source = tomlFormat.generate "superfile-config.toml" (
|
||||
recursiveUpdate themeSetting cfg.settings
|
||||
|
|
@ -139,24 +191,48 @@ in
|
|||
(tomlFormat.generate "superfile-theme-${name}.toml" value);
|
||||
}
|
||||
) cfg.themes;
|
||||
|
||||
firstUseCheckFile = mkIf (!cfg.firstUseCheck) { "${baseDataPath}/firstUseCheck".text = ""; };
|
||||
pinnedFile = mkIf (cfg.pinnedFolders != [ ]) {
|
||||
"${baseDataPath}/pinned.json".source = jsonFormat.generate "pinned.json" cfg.pinnedFolders;
|
||||
};
|
||||
|
||||
files = mkMerge [
|
||||
configFile
|
||||
hotkeysFile
|
||||
themeFiles
|
||||
|
||||
firstUseCheckFile
|
||||
pinnedFile
|
||||
];
|
||||
configFiles = mkMerge [
|
||||
configFile
|
||||
hotkeysFile
|
||||
themeFiles
|
||||
];
|
||||
dataFiles = mkMerge [
|
||||
firstUseCheckFile
|
||||
pinnedFile
|
||||
];
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) (
|
||||
[ cfg.package ]
|
||||
++ optional (
|
||||
cfg.metadataPackage != null && cfg.settings ? metadata && cfg.settings.metadata
|
||||
) cfg.metadataPackage
|
||||
++ optional (
|
||||
cfg.zoxidePackage != null && cfg.settings ? zoxide_support && cfg.settings.zoxide_support
|
||||
) cfg.zoxidePackage
|
||||
);
|
||||
home = {
|
||||
packages = mkIf (cfg.package != null) (
|
||||
[ cfg.package ]
|
||||
++ optional (
|
||||
cfg.metadataPackage != null && cfg.settings ? metadata && cfg.settings.metadata
|
||||
) cfg.metadataPackage
|
||||
++ optional (
|
||||
cfg.zoxidePackage != null && cfg.settings ? zoxide_support && cfg.settings.zoxide_support
|
||||
) cfg.zoxidePackage
|
||||
);
|
||||
|
||||
xdg.configFile = mkIf enableXdgConfig configFiles;
|
||||
home.file = mkIf (!enableXdgConfig) configFiles;
|
||||
file = mkIf (!enableXdgConfig) files;
|
||||
};
|
||||
|
||||
xdg = {
|
||||
configFile = mkIf enableXdgConfig configFiles;
|
||||
dataFile = mkIf enableXdgConfig dataFiles;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
[
|
||||
{
|
||||
"location": "/nix/store",
|
||||
"name": "Nix Store"
|
||||
}
|
||||
]
|
||||
|
|
@ -53,6 +53,13 @@
|
|||
];
|
||||
};
|
||||
};
|
||||
firstUseCheck = false;
|
||||
pinnedFolders = [
|
||||
{
|
||||
name = "Nix Store";
|
||||
location = "/nix/store";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
|
|
@ -60,6 +67,10 @@
|
|||
configSubPath =
|
||||
if !pkgs.stdenv.isDarwin then ".config/superfile" else "Library/Application Support/superfile";
|
||||
configBasePath = "home-files/" + configSubPath;
|
||||
|
||||
dataSubPath =
|
||||
if !pkgs.stdenv.isDarwin then ".local/share/superfile" else "Library/Application Support/superfile";
|
||||
dataBasePath = "home-files/" + dataSubPath;
|
||||
in
|
||||
''
|
||||
assertFileExists "${configBasePath}/config.toml"
|
||||
|
|
@ -82,5 +93,10 @@
|
|||
assertFileContent \
|
||||
"${configBasePath}/theme/test2.toml" \
|
||||
${./example-theme2-expected.toml}
|
||||
assertFileExists "${dataBasePath}/firstUseCheck"
|
||||
assertFileExists "${dataBasePath}/pinned.json"
|
||||
assertFileContent \
|
||||
"${dataBasePath}/pinned.json" \
|
||||
${./example-pinned-folders.json}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue