Skip to content

Commit

Permalink
feat(pops/homeProfiles/presets/navi): add __profiles__.navi-tldr-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Nov 15, 2023
1 parent 3e58a11 commit 1aaf979
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 33 deletions.
17 changes: 17 additions & 0 deletions local/lock/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions local/lock/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
nix-fast-build.url = "github:Mic92/nix-fast-build";
nix-fast-build.inputs.nixpkgs.follows = "nixpkgs";
nix-fast-build.inputs.treefmt-nix.follows = "";

navi-tldr-pages.url = "github:denisidoro/navi-tldr-pages";
navi-tldr-pages.flake = false;
};
outputs = _: { };
}
35 changes: 18 additions & 17 deletions src/pops/_exportsOmnibusProfiles.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{ lib }:
self:
(self.addLoadExtender {
load = {
transformer = [
(
cursor: mod:
let
trace = x: lib.trace x x;
toplevel = cursor == [ ];
in
if toplevel then
lib.mapAttrs (n: v: (if lib.isAttrs v then v else v { })) mod
else
mod
)
];
};
}).exports.default
lib.mapAttrs (n: v: (if lib.isAttrs v then v else v { })) self
# (self.addLoadExtender {
# load = {
# transformer = [
# (
# cursor: mod:
# let
# trace = x: lib.trace x x;
# toplevel = cursor == [ ];
# in
# if toplevel then
# lib.mapAttrs (n: v: (if lib.isAttrs v then v else v { })) mod
# else
# mod
# )
# ];
# };
# }).exports.default
4 changes: 2 additions & 2 deletions src/pops/homeProfiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
}).addExporters
[
(POP.extendPop flops.haumea.pops.exporter (
_self: _super: {
selfPop: _super: {
exports = {
omnibus = super.exportsOmnibusProfiles self;
omnibus = super.exportsOmnibusProfiles selfPop.layouts.default;
};
}
))
Expand Down
2 changes: 1 addition & 1 deletion tests/nixos/__fixture/pops/homeProfiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ in
homeModules = super.homeModules.layouts.nixosModules;
};
inputs = {
inherit (omnibus.flake.inputs) nur;
inherit (omnibus.flake.inputs) nur nix-filter navi-tldr-pages;
};
};
}).addExporters
Expand Down
8 changes: 4 additions & 4 deletions tests/nixos/expr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ in
homeConfiguration =
(out.nixosConfiguration [
out.outputs.nixosProfiles.default.presets.boot
# (extraHomeModule [
# out.outputs.homeProfiles.customProfiles.presets.hyprland.default
# out.outputs.homeProfiles.default.presets.firefox
# ])
(extraHomeModule [
out.outputs.homeProfiles.customProfiles.presets.hyprland.default
out.outputs.homeProfiles.default.presets.firefox
])
]).config.home-manager.users.admin;
}
28 changes: 26 additions & 2 deletions units/nixos/homeModules/programs/navi.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
{ lib }:
{
lib,
inputs,
cfg,
}:
{
options = with lib; {
__profiles__ = {
navi-tldr-pages = {
enable = mkEnableOption (mdDoc "navi-tldr-pages");
package = pkgs.tldr;
src = mkOption {
type = types.str;
default = inputs.navi-tldr-pages;
description = "The paths to use for navi-tldr-pages";
};
paths = mkOption {
default =
(src: (map (x: src + "/${x}") (lib.attrNames (builtins.readDir src))))
cfg.__profiles__.navi-tldr-pages.src;
};
};
};
};
config =
with lib;
mkMerge [
{
settings = {
cheats = {
paths = config.programs.navi.__profiles__.navi-tldr-pages.paths;
};
};
}
];
}
53 changes: 46 additions & 7 deletions units/nixos/homeProfiles/presets/navi.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
{ config, lib, ... }:
{
config,
lib,
omnibus,
inputs,
pkgs,
}:
let
inherit (pkgs.stdenv) isLinux isDarwin;
inherit
(omnibus.errors.requiredInputs inputs "omnibus.pops.homeProfiles" [ "nur" ])
navi-tldr-pages
nix-filter
;

navi-tldr-pages-filtered =
with nix-filter.lib;
filter {
root = navi-tldr-pages + "/pages";
exclude =
[
"android"
"windows"
"sunos"
(if isLinux then "osx" else "linux")
(
root: path: type:
if
(builtins.match "[^/]*(rpm|yum|apt).*.cheat" (builtins.baseNameOf path)) == null
then
false
else
true
)
]
++ lib.optionals isDarwin
[
# (root: path: type: if (l.match "[^/]*brew.*\.cheat" (l.baseNameOf path)) == null then false else true)
];
};
in
{
imports = [ omnibus.homeModules.programs.navi ];
programs.navi = {
enable = true;
enableZshIntegration = lib.mkIf config.programs.zsh.enable true;
settings = {
cheats = {
# paths =
# [];
# (src: (map (x: src + "/${x}") (l.attrNames (l.readDir src))))
# inputs.cells.nixos.data.navi-tldr-pages;
__profiles__ = {
navi-tldr-pages = {
enable = true;
src = navi-tldr-pages-filtered;
};
};
};
Expand Down
1 change: 1 addition & 0 deletions units/nixos/homeProfiles/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ with presets; {
atuin
carapace
fzf
navi
starship.default
dircolors.default
];
Expand Down

0 comments on commit 1aaf979

Please sign in to comment.