172 lines
5.2 KiB
Nix
172 lines
5.2 KiB
Nix
{ config, inputs, ... }:
|
|
{
|
|
flake.modules.nixos.walker = {
|
|
home-manager.sharedModules = [ config.flake.modules.homeManager.walker ];
|
|
|
|
nix.settings = {
|
|
extra-substituters = [
|
|
"https://walker.cachix.org"
|
|
"https://walker-git.cachix.org"
|
|
];
|
|
extra-trusted-public-keys = [
|
|
"walker.cachix.org-1:fG8q+uAaMqhsMxWjwvk0IMb4mFPFLqHjuvfwQxE4oJM="
|
|
"walker-git.cachix.org-1:vmC0ocfPWh0S/vRAQGtChuiZBTAe4wiKDeyyXM0/7pM="
|
|
];
|
|
};
|
|
};
|
|
|
|
flake.modules.homeManager.walker =
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
homeDir = config.home.homeDirectory;
|
|
projectRoots = [
|
|
{
|
|
scope = "work";
|
|
path = "${homeDir}/yookr/projects";
|
|
}
|
|
]
|
|
++
|
|
map
|
|
(scope: {
|
|
inherit scope;
|
|
path = "${config.xdg.userDirs.projects}/${scope}";
|
|
})
|
|
[
|
|
"own"
|
|
"ext"
|
|
"forks"
|
|
];
|
|
walkerDefaults = builtins.fromTOML (builtins.readFile "${inputs.walker}/resources/config.toml");
|
|
|
|
launcher = pkgs.writeShellApplication {
|
|
name = "walker-launcher";
|
|
runtimeInputs = [ pkgs.libressl.nc ];
|
|
text = ''
|
|
exec nc -U "$XDG_RUNTIME_DIR/walker/walker.sock"
|
|
'';
|
|
};
|
|
openProject = pkgs.writeShellApplication {
|
|
name = "open-project";
|
|
text = ''
|
|
project_path="''${1:-}"
|
|
if [[ -z "$project_path" ]]; then
|
|
IFS= read -r project_path || [[ -n "$project_path" ]]
|
|
fi
|
|
|
|
exec ${lib.getExe config.xdg.terminal-exec.package} --dir="$project_path" \
|
|
${lib.getExe pkgs.zsh} -lic 'nvim .; exec zsh -l'
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
imports = [ inputs.walker.homeManagerModules.default ];
|
|
|
|
desktop.commands.launcher = [ (lib.getExe launcher) ];
|
|
home.packages = [ openProject ];
|
|
|
|
xdg.configFile."elephant/menus/projects.lua".text = ''
|
|
Name = "projects"
|
|
NamePretty = "Projects"
|
|
Description = "Projects and workspaces"
|
|
Icon = "folder"
|
|
Action = "${lib.getExe openProject}"
|
|
SearchName = true
|
|
RefreshOnChange = {
|
|
${lib.concatMapStringsSep "\n " (root: ''"${root.path}",'') projectRoots}
|
|
}
|
|
|
|
local roots = {
|
|
${lib.concatMapStringsSep "\n " (
|
|
root: ''{ scope = "${root.scope}", path = "${root.path}" },''
|
|
) projectRoots}
|
|
}
|
|
|
|
local function repositories(root)
|
|
return io.popen(
|
|
"${lib.getExe pkgs.findutils} " .. root ..
|
|
" -mindepth 1 \\( -type d \\( -name .archive -o -name .worktrees \\) -prune \\)" ..
|
|
" -o \\( -name .git -print \\) 2>/dev/null"
|
|
)
|
|
end
|
|
|
|
function GetEntries()
|
|
local entries = {
|
|
{
|
|
Text = "Yookr",
|
|
Subtext = "Company workspace",
|
|
Value = "${homeDir}/yookr",
|
|
Keywords = { "work", "company", "workbench" },
|
|
},
|
|
}
|
|
|
|
for _, root in ipairs(roots) do
|
|
local handle = repositories(root.path)
|
|
if handle then
|
|
for git_path in handle:lines() do
|
|
local project = git_path:gsub("/%.git$", "")
|
|
local relative = project:sub(#root.path + 2)
|
|
table.insert(entries, {
|
|
Text = project:match("([^/]+)$"),
|
|
Subtext = root.scope .. " · " .. relative,
|
|
Value = project,
|
|
Keywords = { root.scope, relative, project },
|
|
})
|
|
end
|
|
handle:close()
|
|
end
|
|
end
|
|
|
|
return entries
|
|
end
|
|
'';
|
|
|
|
programs.walker = {
|
|
enable = true;
|
|
runAsService = true;
|
|
|
|
config.theme = "constellation";
|
|
themes.constellation = {
|
|
layouts.layout =
|
|
lib.replaceStrings
|
|
[ ''<property name="height-request">570</property>'' ]
|
|
[ ''<property name="height-request">460</property>'' ]
|
|
(builtins.readFile "${inputs.walker}/resources/themes/default/layout.xml");
|
|
style = lib.mkBefore (
|
|
builtins.readFile "${inputs.walker}/resources/themes/default/style.css"
|
|
+ ''
|
|
.box-wrapper {
|
|
padding: 10px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
|
|
}
|
|
.search-container, .item-box, .preview { border-radius: 6px; }
|
|
.input { padding: 8px 10px; }
|
|
.item-box { padding: 5px 8px; }
|
|
.large-icons { -gtk-icon-size: 24px; }
|
|
.item-image-text { font-size: 24px; }
|
|
.item-subtext { opacity: 0.75; }
|
|
.item-quick-activation { padding: 3px 5px; }
|
|
.keybinds { padding-top: 6px; }
|
|
.keybind-bind { opacity: 0.65; }
|
|
''
|
|
);
|
|
};
|
|
|
|
config.providers = {
|
|
default = walkerDefaults.providers.default ++ [ "menus:projects" ];
|
|
prefixes = walkerDefaults.providers.prefixes ++ [
|
|
{
|
|
provider = "bitwarden";
|
|
prefix = "?";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|