feat: move to umport for automatic module import
This commit is contained in:
17
flake.nix
17
flake.nix
@@ -77,11 +77,10 @@
|
||||
}) (builtins.attrNames (builtins.readDir ./config/hosts))
|
||||
);
|
||||
|
||||
lib = nixpkgs.lib.extend (
|
||||
lib = (import ./lib/stdlib-extended.nix nixpkgs.lib).extend (
|
||||
final: prev: {
|
||||
inherit (inputs.home-manager.lib) hm;
|
||||
inherit infuse;
|
||||
my = import ./lib { lib = final; };
|
||||
}
|
||||
);
|
||||
infuse = (import inputs.infuse { inherit (nixpkgs) lib; }).v1.infuse;
|
||||
@@ -168,11 +167,19 @@
|
||||
outputs
|
||||
hostname
|
||||
;
|
||||
|
||||
sopsRoot = ./secrets;
|
||||
} // vars;
|
||||
modules = [
|
||||
./modules
|
||||
modules =
|
||||
(lib.umport {
|
||||
paths = [ ./modules ];
|
||||
exclude = [
|
||||
./modules/virt/types
|
||||
./modules/desktop/wm/niri/waybar
|
||||
];
|
||||
recursive = true;
|
||||
})
|
||||
++ [
|
||||
(lib.mkAliasOptionModule [ "my" "home" ] [ "home-manager" "users" vars.username ])
|
||||
./config/base.nix
|
||||
./config/hosts/${hostname}
|
||||
inputs.chaotic.nixosModules.default
|
||||
|
||||
@@ -9,5 +9,6 @@ in
|
||||
stdlib.extend (
|
||||
self: super: {
|
||||
my = mkMyLib { lib = self; };
|
||||
umport = import ./umport.nix { lib = self; };
|
||||
}
|
||||
)
|
||||
|
||||
48
lib/umport.nix
Normal file
48
lib/umport.nix
Normal file
@@ -0,0 +1,48 @@
|
||||
# This function is modified from:
|
||||
# https://github.com/yunfachi/nypkgs/blob/master/lib/umport.nix
|
||||
#
|
||||
# !!! REMOVING THIS NOTICE VIOLATES THE MIT LICENSE OF THE UMPORT PROJECT !!!
|
||||
# This notice must be retained in all copies of this function, including modified versions!
|
||||
# The MIT License can be found here:
|
||||
# https://github.com/yunfachi/nypkgs/blob/master/LICENSE
|
||||
{ lib, ... }:
|
||||
let
|
||||
umport =
|
||||
{
|
||||
path ? null,
|
||||
paths ? [ ],
|
||||
include ? [ ],
|
||||
exclude ? [ ],
|
||||
recursive ? true,
|
||||
}:
|
||||
with lib;
|
||||
with fileset;
|
||||
let
|
||||
excludedFiles = filter (path: pathIsRegularFile path) exclude;
|
||||
excludedDirs = filter (path: pathIsDirectory path) exclude;
|
||||
isExcluded =
|
||||
path:
|
||||
if elem path excludedFiles then
|
||||
true
|
||||
else
|
||||
(filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ];
|
||||
in
|
||||
unique (
|
||||
(filter
|
||||
(file: pathIsRegularFile file && hasSuffix ".nix" (builtins.toString file) && !isExcluded file)
|
||||
(
|
||||
concatMap (
|
||||
_path:
|
||||
if recursive then
|
||||
toList _path
|
||||
else
|
||||
mapAttrsToList (
|
||||
name: type: _path + (if type == "directory" then "/${name}/default.nix" else "/${name}")
|
||||
) (builtins.readDir _path)
|
||||
) (unique (if path == null then paths else [ path ] ++ paths))
|
||||
)
|
||||
)
|
||||
++ (if recursive then concatMap (path: toList path) (unique include) else unique include)
|
||||
);
|
||||
in
|
||||
umport
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./media
|
||||
./misc
|
||||
./monitor
|
||||
./shell
|
||||
];
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./ffmpeg.nix
|
||||
./mpd
|
||||
./cava
|
||||
./go-musicfox
|
||||
];
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./btop
|
||||
];
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./zsh.nix
|
||||
];
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./misc.nix
|
||||
./langs
|
||||
./editor
|
||||
];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./neovim
|
||||
./vscode
|
||||
];
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./c.nix
|
||||
./go.nix
|
||||
./js.nix
|
||||
./rust.nix
|
||||
./python.nix
|
||||
./lua.nix
|
||||
];
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./cli
|
||||
./coding
|
||||
./virt
|
||||
./desktop
|
||||
./i18n
|
||||
./nix.nix
|
||||
./sops.nix
|
||||
./gpg.nix
|
||||
./time.nix
|
||||
./user.nix
|
||||
./xdg.nix
|
||||
./persist.nix
|
||||
./getty-autologin.nix
|
||||
|
||||
(lib.mkAliasOptionModule [ "my" "home" ] [ "home-manager" "users" username ])
|
||||
];
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./firefox.nix
|
||||
./librewolf.nix
|
||||
./chromium.nix
|
||||
./zen.nix
|
||||
];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./browser
|
||||
./gaming
|
||||
./media
|
||||
./notify
|
||||
./screencast
|
||||
./terminal
|
||||
./wm
|
||||
./style
|
||||
./quickshell
|
||||
];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./minecraft.nix
|
||||
./steam.nix
|
||||
];
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./mpv.nix
|
||||
./shotwell.nix
|
||||
./thunderbird.nix
|
||||
./vlc.nix
|
||||
./spotify.nix
|
||||
./spotube.nix
|
||||
];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./dunst
|
||||
./swaync
|
||||
];
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./obs-studio.nix
|
||||
];
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./alacritty
|
||||
./foot
|
||||
./kitty
|
||||
./ghostty
|
||||
];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./all.nix
|
||||
./cage.nix
|
||||
./niri
|
||||
];
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
...
|
||||
}:
|
||||
{
|
||||
config = lib.mkIf config.my.desktop.wm.niri.enable {
|
||||
my.home.programs.niri.settings = {
|
||||
input = {
|
||||
focus-follows-mouse = {
|
||||
@@ -256,4 +257,5 @@
|
||||
}) (lib.range 0 9)
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ in
|
||||
enable = lib.mkEnableOption "Niri";
|
||||
};
|
||||
|
||||
imports = [
|
||||
(lib.mkIf cfg.enable (import ./config.nix args))
|
||||
];
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
security.pam.services.login.enableGnomeKeyring = true;
|
||||
my.persist.homeDirs = [
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./fcitx5.nix
|
||||
./locale.nix
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user