Merge pull request #31 from ryan4yin/modular

feat: refactoring configuration with `options` to make it more modular
This commit is contained in:
Ryan Yin authored and GitHub committed 2023-12-23 21:36:09 +08:00
commit e61116140d
106 files changed
+289 -279

No files matched your search

+2 -5
View File
@@ -1,6 +1,3 @@
{...}: {
imports = [
./container.nix
./kubernetes.nix
];
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
+2 -15
View File
@@ -1,16 +1,3 @@
{...}: {
imports = [
../server
./cloud
./container
./neovim
./terminal
./development.nix
./helix.nix
./media.nix
./shell.nix
./yazi.nix
];
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
+4 -1
View File
@@ -11,7 +11,10 @@
{
xdg.configFile = {
# astronvim's config
"nvim".source = astronvim;
"nvim" = {
source = astronvim;
force = true;
};
# my custom astronvim config, astronvim will load it after base config
# https://github.com/AstroNvim/AstroNvim/blob/v3.32.0/lua/astronvim/bootstrap.lua#L15-L16
+2 -6
View File
@@ -1,7 +1,3 @@
{...}: {
imports = [
./alacritty.nix
./kitty.nix
./wezterm.nix
];
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
+2 -12
View File
@@ -1,13 +1,3 @@
{...}: {
imports = [
./shells
./tmux
./zellij
./bat.nix
./btop.nix
./core.nix
./git.nix
./starship.nix
];
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
+7 -10
View File
@@ -1,11 +1,8 @@
{username, ...}: {
imports = [
../base/desktop
../base/core.nix
./proxychains
./core.nix
./rime-squirrel.nix
./shell.nix
];
{mylib, ...}: {
imports =
(mylib.scanPaths ./.)
// [
../base/desktop
../base/core.nix
];
}
+2 -5
View File
@@ -1,6 +1,3 @@
{
imports = [
./shell.nix
./system-tools.nix
];
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
+1 -5
View File
@@ -1,8 +1,4 @@
{
config,
nushell-scripts,
...
}: let
{config, ...}: let
d = config.xdg.dataHome;
c = config.xdg.configHome;
cache = config.xdg.cacheHome;
+1 -1
View File
@@ -1,10 +1,10 @@
{
imports = [
../base/server
../base/desktop
../base/core.nix
./base
./fcitx5
./desktop
];
}
File renamed without changes.
+3
View File
@@ -0,0 +1,3 @@
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+30
View File
@@ -0,0 +1,30 @@
{
pkgs,
...
}: {
home.packages = with pkgs; [
# GUI apps
# e-book viewer(.epub/.mobi/...)
# do not support .pdf
foliate
# instant messaging
telegram-desktop
discord
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
# remote desktop(rdp connect)
remmina
freerdp # required by remmina
# misc
flameshot
ventoy # multi-boot usb creator
];
# GitHub CLI tool
programs.gh = {
enable = true;
};
}
File renamed without changes.
File renamed without changes.
+2 -37
View File
@@ -1,38 +1,3 @@
{pkgs, ...}: {
imports = [
./wallpaper
./creative.nix
./gtk.nix
./immutable-file.nix
./media.nix
./ssh.nix
./xdg.nix
./eye-protection.nix
];
home.packages = with pkgs; [
# GUI apps
# e-book viewer(.epub/.mobi/...)
# do not support .pdf
foliate
# instant messaging
telegram-desktop
discord
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
# remote desktop(rdp connect)
remmina
freerdp # required by remmina
# misc
flameshot
ventoy # multi-boot usb creator
];
# GitHub CLI tool
programs.gh = {
enable = true;
};
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
@@ -3,10 +3,6 @@
anyrun,
...
}: {
imports = [
anyrun.homeManagerModules.default
];
programs.anyrun = {
enable = true;
config = {
+30
View File
@@ -0,0 +1,30 @@
{
pkgs,
config,
lib,
anyrun,
...
} @ args:
with lib; let
cfg = config.modules.desktop.hyprland;
in {
imports = [
anyrun.homeManagerModules.default
];
options.modules.desktop.hyprland = {
enable = mkEnableOption "hyprland compositor";
};
config = mkIf cfg.enable (
mkMerge
(map
(path: import path args)
[
./hyprland.nix
./packages.nix
./anyrun.nix
./wayland-apps.nix
])
);
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

@@ -1,16 +1,10 @@
{
lib,
pkgs,
lib,
hyprland,
nur-ryan4yin,
...
}: {
imports = [
./anyrun.nix
./wayland-apps.nix
./packages.nix
];
# NOTE:
# We have to enable hyprland/i3's systemd user service in home-manager,
# so that gammastep/wallpaper-switcher's user service can be start correctly!
File renamed without changes.
File renamed without changes.
@@ -8,7 +8,7 @@
commandLineArgs = [
# make it use GTK_IM_MODULE if it runs with Gtk4, so fcitx5 can work with it.
# (only supported by chromium/chrome at this time, not electron)
"--gtk-version=5"
"--gtk-version=4"
"--enable-features=UseOzonePlatform"
"--ozone-platform=wayland"
# make it use text-input-v1, which works for kwin 5.27 and weston
File renamed without changes.
File renamed without changes.
+24
View File
@@ -0,0 +1,24 @@
{
pkgs,
config,
lib,
...
} @ args:
with lib; let
cfg = config.modules.desktop.i3;
in {
options.modules.desktop.i3 = {
enable = mkEnableOption "i3 window manager";
};
config = mkIf cfg.enable (
mkMerge
(map
(path: import path args)
[
./i3.nix
./packages.nix
./x11-apps.nix
])
);
}
File renamed without changes.
@@ -1,11 +1,6 @@
_: {
# i3 window manager's config, based on https://github.com/endeavouros-team/endeavouros-i3wm-setup
imports = [
./packages.nix
./x11-apps.nix
];
# NOTE:
# We have to enable hyprland/i3's systemd user service in home-manager,
# so that gammastep/wallpaper-switcher's user service can be start correctly!
@@ -14,7 +9,7 @@ _: {
enable = true;
windowManager.i3 = {
enable = true;
extraConfig = builtins.readFile ./config;
extraConfig = builtins.readFile ./i3-config;
};
# Path, relative to HOME, where Home Manager should write the X session script.
# and NixOS will use it to start xorg session when system boot up
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+5 -6
View File
@@ -1,6 +1,4 @@
{ lib, ... }:
rec {
{lib, ...}: {
# Generate an attribute set from a list.
#
# lib.genAttrs [ "foo" "bar" ] (name: "x_" + name)
@@ -8,7 +6,7 @@ rec {
listToAttrs = lib.genAttrs;
# Update only the values of the given attribute set.
#
#
# mapAttrs
# (name: value: ("bar-" + value))
# { x = "a"; y = "b"; }
@@ -16,7 +14,7 @@ rec {
mapAttrs = lib.attrsets.mapAttrs;
# Update both the names and values of the given attribute set.
#
#
# mapAttrs'
# (name: value: nameValuePair ("foo_" + name) ("bar-" + value))
# { x = "a"; y = "b"; }
@@ -24,6 +22,7 @@ rec {
mapAttrs' = lib.attrsets.mapAttrs';
# Merge a list of attribute sets into one. smilar to the operator `a // b`, but for a list of attribute sets.
# NOTE: the later attribute set overrides the former one!
#
# mergeAttrsList
# [ { x = "a"; y = "b"; } { x = "c"; z = "d"; } { g = "e"; } ]
@@ -31,7 +30,7 @@ rec {
mergeAttrsList = lib.attrsets.mergeAttrsList;
# Generate a string from an attribute set.
#
#
# attrsets.foldlAttrs
# (acc: name: value: acc + "\nexport ${name}=${value}")
# "# A shell script"
+18
View File
@@ -0,0 +1,18 @@
{lib, ...}: {
colmenaSystem = import ./colmenaSystem.nix;
macosSystem = import ./macosSystem.nix;
nixosSystem = import ./nixosSystem.nix;
attrs = import ./attrs.nix {inherit lib;};
scanPaths = path:
builtins.map
(f: (path + "/${f}"))
(builtins.filter # find all overlay files in the current directory
(
f:
f
!= "default.nix" # ignore default.nix
&& f != "README.md" # ignore README.md
)
(builtins.attrNames (builtins.readDir path)));
}
-3
View File
@@ -32,7 +32,4 @@
];
builders-use-substitutes = true;
};
# Allow unfree packages
nixpkgs.config.allowUnfree = lib.mkDefault false;
}
+3
View File
@@ -0,0 +1,3 @@
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}
+1 -1
View File
@@ -11,7 +11,7 @@
###################################################################################
# to install chrome, you need to enable unfree packages
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfree = lib.mkForce true;
# for nix server, we do not need to keep too much generations
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
+103
View File
@@ -0,0 +1,103 @@
{
pkgs,
config,
lib,
username,
...
}:
with lib; let
cfgWayland = config.modules.desktop.wayland;
cfgXorg = config.modules.desktop.xorg;
in {
imports = [
./base
../base.nix
./desktop
];
options.modules.desktop = {
wayland = {
enable = mkEnableOption "Wayland Display Server";
};
xorg = {
enable = mkEnableOption "Xorg Display Server";
};
};
config = mkMerge [
(mkIf cfgWayland.enable {
####################################################################
# NixOS's Configuration for Wayland based Window Manager
####################################################################
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
];
};
services = {
xserver.enable = false; # disable xorg server
# https://wiki.archlinux.org/title/Greetd
greetd = {
enable = true;
settings = {
default_session = {
# Wayland Desktop Manager is installed only for user ryan via home-manager!
user = username;
# .wayland-session is a script generated by home-manager, which links to the current wayland compositor(sway/hyprland or others).
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config here.
command = "$HOME/.wayland-session"; # start a wayland session directly without a login manager
# command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd $HOME/.wayland-session"; # start wayland session with a TUI login manager
};
};
};
};
# fix https://github.com/ryan4yin/nix-config/issues/10
security.pam.services.swaylock = {};
})
(mkIf cfgXorg.enable {
####################################################################
# NixOS's Configuration for Xorg Server
####################################################################
services = {
gvfs.enable = true; # Mount, trash, and other functionalities
tumbler.enable = true; # Thumbnail support for images
xserver = {
enable = true;
displayManager = {
lightdm.enable = true;
autoLogin = {
enable = true;
user = username;
};
# use a fake session to skip desktop manager
# and let Home Manager take care of the X session
defaultSession = "hm-session";
};
desktopManager = {
runXdgAutostartIfNone = true;
session = [
{
name = "hm-session";
manage = "window";
start = ''
${pkgs.runtimeShell} $HOME/.xsession &
waitPID=$!
'';
}
];
};
# Configure keymap in X11
xkb.layout = "us";
};
};
})
];
}
+1 -7
View File
@@ -1,12 +1,6 @@
{
imports = [
./base/i18n.nix
./base/misc.nix
./base/networking.nix
./base/remote-building.nix
./base/user-group.nix
./base/visualisation.nix
./base
../base.nix
];
}
-50
View File
@@ -1,50 +0,0 @@
{pkgs, ...}: {
##########################################################################################################
#
# NixOS's Configuration for Wayland based Window Manager
#
# hyprland: project starts from 2022, support Wayland, envolving fast, good looking, support Nvidia GPU.
#
##########################################################################################################
imports = [
./base/i18n.nix
./base/misc.nix
./base/networking.nix
./base/remote-building.nix
./base/user-group.nix
./base/visualisation.nix
./desktop
../base.nix
];
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
];
};
services = {
xserver.enable = false; # disable xorg server
# https://wiki.archlinux.org/title/Greetd
greetd = {
enable = true;
settings = {
default_session = {
# Wayland Desktop Manager is installed only for user ryan via home-manager!
user = "ryan";
# .wayland-session is a script generated by home-manager, which links to the current wayland compositor(sway/hyprland or others).
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config here.
command = "$HOME/.wayland-session"; # start a wayland session directly without a login manager
# command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd $HOME/.wayland-session"; # start wayland session with a TUI login manager
};
};
};
};
# fix https://github.com/ryan4yin/nix-config/issues/10
security.pam.services.swaylock = {};
}
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff. Show more