feat: massive refactor

This commit is contained in:
2025-12-20 12:57:47 +08:00
parent f4c1b313ce
commit 454ad5885d
97 changed files with 1023 additions and 960 deletions

View File

@@ -22,6 +22,9 @@ forever. If someone else shares their configuration, anyone else can just use it
As for Flakes, refer to As for Flakes, refer to
[Introduction to Flakes - NixOS & Nix Flakes Book](https://nixos-and-flakes.thiscute.world/nixos-with-flakes/introduction-to-flakes) [Introduction to Flakes - NixOS & Nix Flakes Book](https://nixos-and-flakes.thiscute.world/nixos-with-flakes/introduction-to-flakes)
This configuration uses [flake-parts](https://flake.parts/) for better flake organization and modularity,
enabling declarative host definitions and cleaner separation of concerns.
## Components ## Components
| | NixOS(Wayland) | | | NixOS(Wayland) |
@@ -42,8 +45,19 @@ And more...
## Folder Structure ## Folder Structure
- `modules/` - custom NixOS modules - `modules/` - custom NixOS modules
- `config/base.nix` - generic configs - `modules/core/` - core system modules (nix, persistence, time, user, xdg)
- `config/hosts/<name>/` - hosts-specific configs - `modules/cli/` - command-line tools and utilities
- `modules/coding/` - development environments and editors
- `modules/desktop/` - desktop applications and window managers
- `modules/virt/` - virtualization configurations
- `profiles/` - system configuration profiles
- `profiles/base.nix` - base configuration for all hosts
- `profiles/desktop.nix` - desktop environment configuration
- `profiles/server.nix` - server-specific configuration
- `profiles/wsl.nix` - WSL-specific configuration
- `config/hosts/<name>/` - host-specific configs
- `flake/` - flake-parts modules
- `flake/hosts.nix` - declarative host definitions
- `lib/` - custom nix library - `lib/` - custom nix library
- `pkgs/` - custom packages - `pkgs/` - custom packages
- `overlays/` - nixpkgs overlays - `overlays/` - nixpkgs overlays

View File

@@ -1,42 +0,0 @@
{
config,
hostname,
...
}:
{
# I prefer this to the default issue text
# ported from ArchLinux IIRC
environment.etc.issue.text = "\\e{lightcyan}\\S\\e{reset} Login (\\l)\n\n";
networking.hostName = hostname;
# don't change this unless you know what you are doing!
# for further information, see wiki.nixos.org
system.stateVersion = "24.11";
# disable this since we already have machine-id persisted
systemd.services."systemd-machine-id-commit".enable = !config.my.persist.enable;
my = {
hm = {
# nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
home.stateVersion = "24.11";
};
xdg.enable = true;
persist = {
nixosDirs = [
"/root"
"/var"
"/etc/ssh"
];
nixosFiles = [
"/etc/machine-id"
];
homeDirs = [
{
directory = ".ssh";
mode = "0700";
}
];
};
};
}

View File

@@ -175,8 +175,8 @@
config.sops.secrets.frp-env.path config.sops.secrets.frp-env.path
]; ];
services.frp = { services.frp = {
enable = true;
instances."" = { instances."" = {
enable = true;
role = "client"; role = "client";
settings = { settings = {
serverAddr = "{{ .Envs.FRP_SERVER_ADDR }}"; serverAddr = "{{ .Envs.FRP_SERVER_ADDR }}";
@@ -384,7 +384,6 @@
customDomains = [ "memo.imxyy.top" ]; customDomains = [ "memo.imxyy.top" ];
} }
{ {
name = "efl-matrix-http"; name = "efl-matrix-http";
type = "http"; type = "http";

View File

@@ -6,24 +6,6 @@
... ...
}: }:
{ {
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 10;
};
grub.enable = false;
timeout = 0;
};
systemd.services.nix-daemon = {
environment.TMPDIR = "/var/cache/nix";
serviceConfig.CacheDirectory = "nix";
};
environment.variables.NIX_REMOTE = "daemon";
my.audio.enable = false;
sops.secrets.imxyy-nix-server-hashed-password = { sops.secrets.imxyy-nix-server-hashed-password = {
sopsFile = secrets.imxyy-nix-server-hashed-password; sopsFile = secrets.imxyy-nix-server-hashed-password;
format = "binary"; format = "binary";

View File

@@ -9,6 +9,7 @@
"biosdevname=0" "biosdevname=0"
"net.ifnames=0" "net.ifnames=0"
]; ];
my.persist.nixosDirs = [ "/etc/NetworkManager/system-connections" ];
networking = { networking = {
networkmanager.enable = true; networkmanager.enable = true;
firewall.enable = false; firewall.enable = false;

View File

@@ -6,40 +6,10 @@
... ...
}: }:
{ {
security.pam.loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "524288";
}
];
boot.kernelParams = [ boot.kernelParams = [
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter) "usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
]; ];
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 10;
};
grub.enable = false;
timeout = 0;
};
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
systemd.services.nix-daemon = {
environment.TMPDIR = "/var/cache/nix";
serviceConfig.CacheDirectory = "nix";
};
environment.variables.NIX_REMOTE = "daemon";
services.printing.enable = true;
services.upower.enable = true; services.upower.enable = true;
services.power-profiles-daemon.enable = true; services.power-profiles-daemon.enable = true;
@@ -59,8 +29,6 @@
}; };
}; };
services.gvfs.enable = true;
services.openssh = { services.openssh = {
enable = true; enable = true;
settings = { settings = {
@@ -96,6 +64,4 @@
]; ];
}; };
}; };
my.persist.nixosDirs = [ "/etc/NetworkManager/system-connections" ];
} }

View File

@@ -160,6 +160,9 @@
".claude" ".claude"
".claude-code-router" ".claude-code-router"
]; ];
homeFiles = [
".claude.json"
];
}; };
}; };
} }

View File

@@ -25,46 +25,17 @@ let
''; '';
in in
{ {
security.pam.loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "524288";
}
];
systemd.services.btreset = { systemd.services.btreset = {
script = lib.getExe btreset; script = lib.getExe btreset;
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
}; };
boot.kernelParams = [ boot.kernelParams = [
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter) "usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
"fsck.mode=skip" "fsck.mode=skip"
]; ];
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 10;
};
grub.enable = false;
timeout = 0;
};
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
systemd.services.nix-daemon = {
environment.TMPDIR = "/var/cache/nix";
serviceConfig.CacheDirectory = "nix";
};
environment.variables.NIX_REMOTE = "daemon";
services.printing.enable = true;
services.keyd = { services.keyd = {
enable = true; enable = true;
keyboards = { keyboards = {
@@ -87,8 +58,6 @@ in
}; };
}; };
services.gvfs.enable = true;
programs.wireshark.enable = true; programs.wireshark.enable = true;
programs.wireshark.package = pkgs.wireshark; programs.wireshark.package = pkgs.wireshark;
users.users.${username}.extraGroups = [ "wireshark" ]; users.users.${username}.extraGroups = [ "wireshark" ];

View File

@@ -107,14 +107,34 @@
}; };
} }
{ {
systems = [ systems = [ "x86_64-linux" ];
"x86_64-linux"
];
imports = [ imports = [
./nixos.nix ./flake/hosts.nix
./treefmt.nix ./treefmt.nix
./pkgs ./pkgs
./overlays ./overlays
]; ];
nixosHosts = {
imxyy-nix = {
profiles = [ "desktop" ];
};
imxyy-nix-server = {
profiles = [ "server" ];
};
imxyy-nix-wsl = {
profiles = [ "wsl" ];
modules = [
inputs.nixos-wsl.nixosModules.default
];
};
imxyy-nix-x16 = {
profiles = [ "desktop" ];
};
};
}; };
} }

142
flake/hosts.nix Normal file
View File

@@ -0,0 +1,142 @@
{
self,
lib,
inputs,
withSystem,
config,
pkgsParams,
...
}:
let
vars = import ../vars.nix;
pkgsModule = {
nixpkgs = pkgsParams // {
inherit (config.nixpkgs.hostPlatform) system;
};
};
hmModule = {
home-manager = {
sharedModules = [
inputs.sops-nix.homeManagerModules.sops
inputs.impermanence.nixosModules.home-manager.impermanence
inputs.stylix.homeModules.stylix
inputs.noctalia.homeModules.default
inputs.zen.homeModules.beta
{
nixpkgs = lib.mkForce { };
}
];
useGlobalPkgs = true;
};
};
in
{
options.nixosHosts = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule (
{ name, ... }:
{
options = {
system = lib.mkOption {
type = lib.types.str;
default = "x86_64-linux";
description = "System architecture";
};
profiles = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "List of profile names (e.g., 'desktop', 'server', 'wsl')";
};
modules = lib.mkOption {
type = lib.types.listOf lib.types.deferredModule;
default = (
lib.umport {
paths = [ ../config/hosts/${name} ];
extraExcludePredicate = path: lib.hasInfix "/_" (toString path);
recursive = true;
}
);
description = "Additional NixOS modules specific to this host";
};
extraSpecialArgs = lib.mkOption {
type = lib.types.attrs;
default = { };
description = "Extra special arguments to pass to modules";
};
};
}
)
);
default = { };
description = "Declarative host definitions";
};
config = {
# Generate nixosConfigurations from declarative host definitions
flake.nixosConfigurations = lib.mapAttrs (
hostname: hostConfig:
withSystem hostConfig.system (
{ ... }:
lib.nixosSystem {
inherit (hostConfig) system;
specialArgs = {
inherit
inputs
self
hostname
;
assets =
with lib.haumea;
load {
src = ../assets;
loader = [ (matchers.always loaders.path) ];
};
secrets =
with lib.haumea;
load {
src = ../secrets;
loader = [ (matchers.always loaders.path) ];
};
}
// vars
// hostConfig.extraSpecialArgs;
modules =
# Automatically import all feature modules
(lib.umport {
paths = [ ../modules ];
extraExcludePredicate = path: lib.hasInfix "/_" (toString path);
recursive = true;
})
++ [
# Base profile (always included)
../profiles/base.nix
]
# Add requested profiles
++ (map (profile: ../profiles/${profile}.nix) hostConfig.profiles)
# Add host-specific modules
++ hostConfig.modules
++ [
(lib.mkAliasOptionModule [ "my" "hm" ] [ "home-manager" "users" vars.username ])
# Upstream modules
inputs.sops-nix.nixosModules.sops
inputs.impermanence.nixosModules.impermanence
inputs.home-manager.nixosModules.default
inputs.niri.nixosModules.niri
inputs.catppuccin.nixosModules.catppuccin
inputs.angrr.nixosModules.angrr
# pkgs and home-manager configuration
pkgsModule
hmModule
];
}
)
) config.nixosHosts;
};
}

View File

@@ -1,7 +1,6 @@
{ lib, inputs }: { lib, inputs }:
lib.extend ( lib.extend (
self: super: { self: super: {
my = import ./my.nix { lib = self; };
umport = import ./umport.nix { lib = self; }; umport = import ./umport.nix { lib = self; };
inherit (inputs.home-manager.lib) hm; inherit (inputs.home-manager.lib) hm;
haumea = inputs.haumea.lib; haumea = inputs.haumea.lib;

View File

@@ -1,102 +0,0 @@
{ lib }:
{
makeSwitch =
{
default ? false,
config,
optionPath,
optionName,
config',
}:
let
cfg = lib.getAttrFromPath optionPath config.my;
in
{
options.my = lib.setAttrByPath optionPath {
enable = (lib.mkEnableOption optionName) // {
inherit default;
};
};
config = lib.mkIf cfg.enable config';
};
makeHomePackageConfig =
{
config,
pkgs,
packageName,
packagePath,
optionPath,
extraConfig ? { },
}:
lib.my.makeSwitch {
inherit config optionPath;
optionName = packageName;
config' = lib.mkMerge [
{
my.hm.home.packages = [ (lib.getAttrFromPath packagePath pkgs) ];
}
extraConfig
];
};
makeHomeProgramConfig =
{
config,
programName,
optionPath,
extraConfig ? { },
}:
lib.my.makeSwitch {
inherit config optionPath;
optionName = programName;
config' = lib.mkMerge [
{
my.hm.programs = lib.setAttrByPath [ programName "enable" ] true;
}
extraConfig
];
};
makeNixosPackageConfig =
{
config,
pkgs,
packageName,
packagePath,
optionPath,
extraConfig ? { },
}:
lib.my.makeSwitch {
inherit config optionPath;
optionName = packageName;
config' = lib.mkMerge [
{
environment.systemPackages = [ (lib.getAttrFromPath packagePath pkgs) ];
}
extraConfig
];
};
makeNixosProgramConfig =
{
config,
programName,
optionPath,
extraConfig ? { },
}:
lib.my.makeSwitch {
inherit config optionPath;
optionName = programName;
config' = lib.mkMerge [
{
programs = lib.setAttrByPath [ programName "enable" ] true;
}
extraConfig
];
};
}

View File

@@ -13,6 +13,7 @@ let
paths ? [ ], paths ? [ ],
include ? [ ], include ? [ ],
exclude ? [ ], exclude ? [ ],
extraExcludePredicate ? _: true,
recursive ? true, recursive ? true,
}: }:
with lib; with lib;
@@ -22,23 +23,22 @@ let
excludedDirs = filter (path: pathIsDirectory path) exclude; excludedDirs = filter (path: pathIsDirectory path) exclude;
isExcluded = isExcluded =
path: path:
if elem path excludedFiles then (elem path excludedFiles)
true || ((filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ])
else || extraExcludePredicate path;
(filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ];
in in
unique ( unique (
(filter (filter
(file: pathIsRegularFile file && hasSuffix ".nix" (builtins.toString file) && !isExcluded file) (file: pathIsRegularFile file && hasSuffix ".nix" (builtins.toString file) && !isExcluded file)
( (
concatMap ( concatMap (
_path: path:
if recursive then if recursive then
toList _path toList path
else else
mapAttrsToList ( mapAttrsToList (
name: type: _path + (if type == "directory" then "/${name}/default.nix" else "/${name}") name: type: path + (if type == "directory" then "/${name}/default.nix" else "/${name}")
) (builtins.readDir _path) ) (builtins.readDir path)
) (unique (if path == null then paths else [ path ] ++ paths)) ) (unique (if path == null then paths else [ path ] ++ paths))
) )
) )

View File

@@ -5,12 +5,15 @@
username, username,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.audio;
default = true; in
optionName = "default audio settings"; {
optionPath = [ "audio" ]; options.my.audio = {
config' = { enable = lib.mkEnableOption "default audio settings";
};
config = lib.mkIf cfg.enable {
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
enable = true; enable = true;

View File

@@ -1,10 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.bluetooth;
default = true; in
optionName = "default bluetooth settings"; {
optionPath = [ "bluetooth" ]; options.my.bluetooth = {
config' = { enable = lib.mkEnableOption "default bluetooth settings";
};
config = lib.mkIf cfg.enable {
hardware.bluetooth = { hardware.bluetooth = {
enable = true; enable = true;
powerOnBoot = true; powerOnBoot = true;

View File

@@ -1,12 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.all;
optionName = "all command line tools"; in
optionPath = [ {
"cli" options.my.cli.all = {
"all" enable = lib.mkEnableOption "all command line tools";
]; };
config' = {
config = lib.mkIf cfg.enable {
my.cli = { my.cli = {
media.all.enable = true; media.all.enable = true;
misc.enable = true; misc.enable = true;

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.media.all;
optionName = "all command line media tools"; in
optionPath = [ {
"cli" options.my.cli.media.all = {
"media" enable = lib.mkEnableOption "all command line media tools";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.cli.media = { my.cli.media = {
go-musicfox.enable = true; go-musicfox.enable = true;
ffmpeg.enable = true; ffmpeg.enable = true;

View File

@@ -4,13 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.cli.media.ffmpeg;
packageName = "ffmpeg"; in
packagePath = [ "ffmpeg" ]; {
optionPath = [ options.my.cli.media.ffmpeg = {
"cli" enable = lib.mkEnableOption "ffmpeg";
"media" };
"ffmpeg"
]; config = lib.mkIf cfg.enable {
my.hm.home.packages = [ pkgs.ffmpeg ];
};
} }

View File

@@ -5,15 +5,15 @@
secrets, secrets,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.media.go-musicfox;
optionName = "go-musicfox"; in
optionPath = [ {
"cli" options.my.cli.media.go-musicfox = {
"media" enable = lib.mkEnableOption "go-musicfox";
"go-musicfox" };
];
config' = { config = lib.mkIf cfg.enable {
my = { my = {
hm = { hm = {
home.packages = with pkgs; [ home.packages = with pkgs; [

View File

@@ -4,15 +4,19 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.misc;
in
{
options.my.cli.misc = {
enable = lib.mkOption {
type = lib.types.bool;
default = true; default = true;
optionName = "misc command line tools"; description = "Enable misc command line tools";
optionPath = [ };
"cli" };
"misc"
]; config = lib.mkIf cfg.enable {
config' = {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
vim vim
wget wget

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.monitor.all;
optionName = "all command line monitor tools"; in
optionPath = [ {
"cli" options.my.cli.monitor.all = {
"monitor" enable = lib.mkEnableOption "all command line monitor tools";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.cli.monitor = { my.cli.monitor = {
btop.enable = true; btop.enable = true;
}; };

View File

@@ -4,16 +4,16 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.cli.monitor.btop;
packageName = "btop"; in
packagePath = [ "btop" ]; {
optionPath = [ options.my.cli.monitor.btop = {
"cli" enable = lib.mkEnableOption "btop";
"monitor" };
"btop"
]; config = lib.mkIf cfg.enable {
extraConfig = { my.hm.home.packages = [ pkgs.btop ];
my.hm.xdg.configFile."btop" = { my.hm.xdg.configFile."btop" = {
source = ./config; source = ./config;
recursive = true; recursive = true;

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.shell.all;
optionName = "all shells"; in
optionPath = [ {
"cli" options.my.cli.shell.all = {
"shell" enable = lib.mkEnableOption "all shells";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.cli.shell = { my.cli.shell = {
zsh.enable = true; zsh.enable = true;
fish.enable = true; fish.enable = true;

View File

@@ -4,16 +4,19 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.shell.fish;
in
{
options.my.cli.shell.fish = {
enable = lib.mkOption {
type = lib.types.bool;
default = true; default = true;
optionName = "default fish settings"; description = "Enable default fish settings";
optionPath = [ };
"cli" };
"shell"
"fish" config = lib.mkIf cfg.enable {
];
config' = {
my.persist.homeDirs = [ my.persist.homeDirs = [
".local/share/fish" ".local/share/fish"
]; ];

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.shell.starship;
optionName = "starship prompt"; in
optionPath = [ {
"cli" options.my.cli.shell.starship = {
"shell" enable = lib.mkEnableOption "starship prompt";
"starship" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
programs.starship = { programs.starship = {
enable = true; enable = true;

View File

@@ -4,16 +4,19 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.shell.zsh;
in
{
options.my.cli.shell.zsh = {
enable = lib.mkOption {
type = lib.types.bool;
default = true; default = true;
optionName = "default zsh settings"; description = "Enable default zsh settings";
optionPath = [ };
"cli" };
"shell"
"zsh" config = lib.mkIf cfg.enable {
];
config' = {
my.hm = { my.hm = {
home.packages = with pkgs; [ home.packages = with pkgs; [
fzf fzf

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.cli.vcs.all;
optionName = "all command line tools"; in
optionPath = [ {
"cli" options.my.cli.vcs.all = {
"vcs" enable = lib.mkEnableOption "all command line tools";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.cli.vcs = { my.cli.vcs = {
git.enable = true; git.enable = true;
jj.enable = true; jj.enable = true;

View File

@@ -7,15 +7,16 @@
useremail, useremail,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.cli.vcs.git;
programName = "git"; in
optionPath = [ {
"cli" options.my.cli.vcs.git = {
"vcs" enable = lib.mkEnableOption "git";
"git" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.git.enable = true;
my.hm = { my.hm = {
programs.git = { programs.git = {
settings = { settings = {

View File

@@ -7,15 +7,16 @@
useremail, useremail,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.cli.vcs.jj;
programName = "jujutsu"; in
optionPath = [ {
"cli" options.my.cli.vcs.jj = {
"vcs" enable = lib.mkEnableOption "jujutsu";
"jj" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.jujutsu.enable = true;
my.hm = { my.hm = {
programs.jujutsu = { programs.jujutsu = {
settings = { settings = {

View File

@@ -1,12 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.all;
optionName = "all coding tools"; in
optionPath = [ {
"coding" options.my.coding.all = {
"all" enable = lib.mkEnableOption "all coding tools";
]; };
config' = {
config = lib.mkIf cfg.enable {
my.coding = { my.coding = {
editor.all.enable = true; editor.all.enable = true;
langs.all.enable = true; langs.all.enable = true;

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.editor.all;
optionName = "all coding editors"; in
optionPath = [ {
"coding" options.my.coding.editor.all = {
"editor" enable = lib.mkEnableOption "all coding editors";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.coding.editor = { my.coding.editor = {
neovim.enable = true; neovim.enable = true;
vscode.enable = true; vscode.enable = true;

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.coding.editor.neovim;
programName = "neovim"; in
optionPath = [ {
"coding" options.my.coding.editor.neovim = {
"editor" enable = lib.mkEnableOption "neovim";
"neovim" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
xdg.configFile."nvim/init.lua".source = ./nvim/init.lua; xdg.configFile."nvim/init.lua".source = ./nvim/init.lua;
xdg.configFile."nvim/lua" = { xdg.configFile."nvim/lua" = {

View File

@@ -4,15 +4,16 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.coding.editor.vscode;
programName = "vscode"; in
optionPath = [ {
"coding" options.my.coding.editor.vscode = {
"editor" enable = lib.mkEnableOption "vscode";
"vscode" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.vscode.enable = true;
my.hm = { my.hm = {
programs.vscode = { programs.vscode = {
package = pkgs.vscodium; package = pkgs.vscodium;

View File

@@ -3,15 +3,16 @@
lib, lib,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.coding.editor.zed;
programName = "zed-editor"; in
optionPath = [ {
"coding" options.my.coding.editor.zed = {
"editor" enable = lib.mkEnableOption "zed-editor";
"zed" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.zed-editor.enable = true;
my.persist.homeDirs = [ my.persist.homeDirs = [
".config/zed" ".config/zed"
".local/share/zed" ".local/share/zed"

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.all;
optionName = "all coding langs"; in
optionPath = [ {
"coding" options.my.coding.langs.all = {
"langs" enable = lib.mkEnableOption "all coding langs";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.coding.langs = { my.coding.langs = {
c.enable = true; c.enable = true;
go.enable = true; go.enable = true;

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.c;
optionName = "c"; in
optionPath = [ {
"coding" options.my.coding.langs.c = {
"langs" enable = lib.mkEnableOption "c";
"c" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
gcc gcc
(lib.hiPrio clang) (lib.hiPrio clang)

View File

@@ -4,17 +4,17 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.coding.langs.go;
packageName = "go"; in
packagePath = [ "go" ]; {
optionPath = [ options.my.coding.langs.go = {
"coding" enable = lib.mkEnableOption "go";
"langs" };
"go"
]; config = lib.mkIf cfg.enable {
extraConfig = {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
go
gotools gotools
gopls gopls
]; ];

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.java;
optionName = "java"; in
optionPath = [ {
"coding" options.my.coding.langs.java = {
"langs" enable = lib.mkEnableOption "java";
"java" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
openjdk25 openjdk25
java-language-server java-language-server

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.js;
optionName = "js"; in
optionPath = [ {
"coding" options.my.coding.langs.js = {
"langs" enable = lib.mkEnableOption "js";
"js" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
home.packages = with pkgs; [ home.packages = with pkgs; [
nodejs nodejs

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.lua;
optionName = "lua"; in
optionPath = [ {
"coding" options.my.coding.langs.lua = {
"langs" enable = lib.mkEnableOption "lua";
"lua" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
luajit luajit
stylua stylua

View File

@@ -4,17 +4,17 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.coding.langs.python;
packageName = "python3"; in
packagePath = [ "python3" ]; {
optionPath = [ options.my.coding.langs.python = {
"coding" enable = lib.mkEnableOption "python3";
"langs" };
"python"
]; config = lib.mkIf cfg.enable {
extraConfig = {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
python3
uv uv
pyright pyright
]; ];

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.qml;
optionName = "QML"; in
optionPath = [ {
"coding" options.my.coding.langs.qml = {
"langs" enable = lib.mkEnableOption "QML";
"qml" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
kdePackages.qtdeclarative kdePackages.qtdeclarative
]; ];

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.rust;
optionName = "rust"; in
optionPath = [ {
"coding" options.my.coding.langs.rust = {
"langs" enable = lib.mkEnableOption "rust";
"rust" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
home.packages = with pkgs; [ home.packages = with pkgs; [
(fenix.stable.withComponents [ (fenix.stable.withComponents [

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.langs.typst;
optionName = "Typst"; in
optionPath = [ {
"coding" options.my.coding.langs.typst = {
"langs" enable = lib.mkEnableOption "Typst";
"typst" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
typst typst
tinymist tinymist

View File

@@ -4,14 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.coding.misc;
optionName = "misc"; in
optionPath = [ {
"coding" options.my.coding.misc = {
"misc" enable = lib.mkEnableOption "misc";
]; };
config' = {
config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
home.packages = with pkgs; [ home.packages = with pkgs; [
gnumake gnumake

View File

@@ -8,12 +8,15 @@
username, username,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.nix;
default = true; in
optionName = "default nix settings"; {
optionPath = [ "nix" ]; options.my.nix = {
config' = { enable = lib.mkEnableOption "default nix settings";
};
config = lib.mkIf cfg.enable {
# This will add each flake input as a registry # This will add each flake input as a registry
# To make nix3 commands consistent with your flake # To make nix3 commands consistent with your flake
nix.registry = (lib.mapAttrs (_: flake: { inherit flake; })) ( nix.registry = (lib.mapAttrs (_: flake: { inherit flake; })) (
@@ -58,15 +61,25 @@ lib.my.makeSwitch {
group = "users"; group = "users";
mode = "0400"; mode = "0400";
}; };
my.hm.nix.extraOptions = ''
my.hm = {
nix.extraOptions = ''
!include ${config.sops.secrets.nix-github-token.path} !include ${config.sops.secrets.nix-github-token.path}
''; '';
my.hm.home.packages = with pkgs; [ home.packages = with pkgs; [
nixd nixd
nixfmt nixfmt
]; ];
xdg.configFile."direnv/lib/angrr.sh".source =
"${config.services.angrr.package}/share/direnv/lib/angrr.sh";
programs.direnv.stdlib = ''
use angrr
'';
};
# uncomment to enable auto gc # uncomment to enable auto gc
/* /*
nix.gc = { nix.gc = {
@@ -82,10 +95,5 @@ lib.my.makeSwitch {
period = "1month"; period = "1month";
}; };
}; };
my.hm.xdg.configFile."direnv/lib/angrr.sh".source =
"${config.services.angrr.package}/share/direnv/lib/angrr.sh";
my.hm.programs.direnv.stdlib = ''
use angrr
'';
}; };
} }

View File

@@ -12,6 +12,7 @@ in
enable = lib.mkEnableOption "persist"; enable = lib.mkEnableOption "persist";
location = lib.mkOption { location = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/nix/persist";
example = lib.literalExpression '' example = lib.literalExpression ''
"/persistent" "/persistent"
''; '';

View File

@@ -1,10 +1,15 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.time;
in
{
options.my.time = {
enable = lib.mkEnableOption "default time settings" // {
default = true; default = true;
optionName = "default time settings"; };
optionPath = [ "time" ]; };
config' = {
config = lib.mkIf cfg.enable {
time.timeZone = "Asia/Shanghai"; time.timeZone = "Asia/Shanghai";
networking.timeServers = [ networking.timeServers = [
"0.cn.pool.ntp.org" "0.cn.pool.ntp.org"

View File

@@ -7,12 +7,17 @@
secrets, secrets,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.user;
in
{
options.my.user = {
enable = lib.mkEnableOption "default user settings" // {
default = true; default = true;
optionName = "default user settings"; };
optionPath = [ "user" ]; };
config' = {
config = lib.mkIf cfg.enable {
programs.zsh.enable = true; programs.zsh.enable = true;
sops.secrets.imxyy-nix-hashed-password = { sops.secrets.imxyy-nix-hashed-password = {

View File

@@ -2,6 +2,7 @@
lib, lib,
config, config,
pkgs, pkgs,
username,
... ...
}: }:
let let

View File

@@ -1,12 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.all;
optionName = "all desktop things"; in
optionPath = [ {
"desktop" options.my.desktop.all = {
"all" enable = lib.mkEnableOption "all desktop things";
]; };
config' = {
config = lib.mkIf cfg.enable {
my.desktop = { my.desktop = {
browser.all.enable = true; browser.all.enable = true;
gaming.all.enable = true; gaming.all.enable = true;

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.browser.all;
optionName = "all desktop browsers"; in
optionPath = [ {
"desktop" options.my.desktop.browser.all = {
"browser" enable = lib.mkEnableOption "all desktop browsers";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.desktop.browser = { my.desktop.browser = {
firefox.enable = true; firefox.enable = true;
chromium.enable = true; chromium.enable = true;

View File

@@ -4,15 +4,16 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.browser.chromium;
programName = "chromium"; in
optionPath = [ {
"desktop" options.my.desktop.browser.chromium = {
"browser" enable = lib.mkEnableOption "chromium";
"chromium" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.chromium.enable = true;
my.hm.programs.chromium = { my.hm.programs.chromium = {
package = pkgs.ungoogled-chromium; package = pkgs.ungoogled-chromium;
extensions = [ extensions = [

View File

@@ -1,13 +1,14 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.browser.firefox;
programName = "firefox"; in
optionPath = [ {
"desktop" options.my.desktop.browser.firefox = {
"browser" enable = lib.mkEnableOption "firefox";
"firefox" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.firefox.enable = true;
my.persist.homeDirs = [ my.persist.homeDirs = [
".mozilla" ".mozilla"
]; ];

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.browser.zen;
programName = "zen-browser"; in
optionPath = [ {
"desktop" options.my.desktop.browser.zen = {
"browser" enable = lib.mkEnableOption "zen-browser";
"zen" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.zen-browser = { my.hm.programs.zen-browser = {
enable = true; enable = true;
nativeMessagingHosts = [ pkgs.firefoxpwa ]; nativeMessagingHosts = [ pkgs.firefoxpwa ];

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.gaming.all;
optionName = "all desktop gaming things"; in
optionPath = [ {
"desktop" options.my.desktop.gaming.all = {
"gaming" enable = lib.mkEnableOption "all desktop gaming things";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.desktop.gaming = { my.desktop.gaming = {
minecraft.enable = true; minecraft.enable = true;
steam.enable = true; steam.enable = true;

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.gaming.minecraft;
optionName = "minecraft"; in
optionPath = [ {
"desktop" options.my.desktop.gaming.minecraft = {
"gaming" enable = lib.mkEnableOption "minecraft";
"minecraft" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = [ my.hm.home.packages = [
(pkgs.hmcl.overrideAttrs { (pkgs.hmcl.overrideAttrs {
postFixup = '' postFixup = ''

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.gaming.steam;
optionName = "steam"; in
optionPath = [ {
"desktop" options.my.desktop.gaming.steam = {
"gaming" enable = lib.mkEnableOption "steam";
"steam" };
];
config' = { config = lib.mkIf cfg.enable {
programs.steam = { programs.steam = {
enable = true; enable = true;
package = pkgs.steam; package = pkgs.steam;

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.media.all;
optionName = "all desktop media things"; in
optionPath = [ {
"desktop" options.my.desktop.media.all = {
"media" enable = lib.mkEnableOption "all desktop media things";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.desktop.media = { my.desktop.media = {
mpv.enable = true; mpv.enable = true;
shotwell.enable = true; shotwell.enable = true;

View File

@@ -4,13 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.media.mpv;
packageName = "mpv"; in
packagePath = [ "mpv" ]; {
optionPath = [ options.my.desktop.media.mpv = {
"desktop" enable = lib.mkEnableOption "mpv";
"media" };
"mpv"
]; config = lib.mkIf cfg.enable {
my.hm.home.packages = [ pkgs.mpv ];
};
} }

View File

@@ -4,13 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.media.shotwell;
packageName = "shotwell"; in
packagePath = [ "shotwell" ]; {
optionPath = [ options.my.desktop.media.shotwell = {
"desktop" enable = lib.mkEnableOption "shotwell";
"media" };
"shotwell"
]; config = lib.mkIf cfg.enable {
my.hm.home.packages = [ pkgs.shotwell ];
};
} }

View File

@@ -4,13 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.media.spotify;
packageName = "spotify"; in
packagePath = [ "spotify" ]; {
optionPath = [ options.my.desktop.media.spotify = {
"desktop" enable = lib.mkEnableOption "spotify";
"media" };
"spotify"
]; config = lib.mkIf cfg.enable {
my.hm.home.packages = [ pkgs.spotify ];
};
} }

View File

@@ -4,16 +4,16 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.media.spotube;
packageName = "spotube"; in
packagePath = [ "spotube" ]; {
optionPath = [ options.my.desktop.media.spotube = {
"desktop" enable = lib.mkEnableOption "spotube";
"media" };
"spotube"
]; config = lib.mkIf cfg.enable {
extraConfig = { my.hm.home.packages = [ pkgs.spotube ];
my.persist.homeDirs = [ my.persist.homeDirs = [
".local/share/oss.krtirtho.spotube" ".local/share/oss.krtirtho.spotube"
]; ];

View File

@@ -4,16 +4,16 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.media.thunderbird;
packageName = "thunderbird"; in
packagePath = [ "thunderbird" ]; {
optionPath = [ options.my.desktop.media.thunderbird = {
"desktop" enable = lib.mkEnableOption "thunderbird";
"media" };
"thunderbird"
]; config = lib.mkIf cfg.enable {
extraConfig = { my.hm.home.packages = [ pkgs.thunderbird ];
my.persist.homeDirs = [ my.persist.homeDirs = [
".thunderbird" ".thunderbird"
]; ];

View File

@@ -4,13 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.media.vlc;
packageName = "vlc"; in
packagePath = [ "vlc" ]; {
optionPath = [ options.my.desktop.media.vlc = {
"desktop" enable = lib.mkEnableOption "vlc";
"media" };
"vlc"
]; config = lib.mkIf cfg.enable {
my.hm.home.packages = [ pkgs.vlc ];
};
} }

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.screencast.all;
optionName = "all screencast tools"; in
optionPath = [ {
"desktop" options.my.desktop.screencast.all = {
"screencast" enable = lib.mkEnableOption "all screencast tools";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.desktop.screencast = { my.desktop.screencast = {
obs-studio.enable = true; obs-studio.enable = true;
}; };

View File

@@ -4,15 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.screencast.obs-studio;
optionName = "obs-studio"; in
optionPath = [ {
"desktop" options.my.desktop.screencast.obs-studio = {
"screencast" enable = lib.mkEnableOption "obs-studio";
"obs-studio" };
];
config' = { config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
(pkgs.wrapOBS { (pkgs.wrapOBS {
plugins = with pkgs.obs-studio-plugins; [ plugins = with pkgs.obs-studio-plugins; [

View File

@@ -4,14 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.style;
optionName = "style"; in
optionPath = [ {
"desktop" options.my.desktop.style = {
"style" enable = lib.mkEnableOption "style";
]; };
config' = {
config = lib.mkIf cfg.enable {
catppuccin.sddm = { catppuccin.sddm = {
enable = true; enable = true;
font = "Jetbrains Mono"; font = "Jetbrains Mono";

View File

@@ -1,13 +1,14 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.terminal.alacritty;
programName = "alacritty"; in
optionPath = [ {
"desktop" options.my.desktop.terminal.alacritty = {
"terminal" enable = lib.mkEnableOption "alacritty";
"alacritty" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.alacritty.enable = true;
my.hm.programs.alacritty.settings = { my.hm.programs.alacritty.settings = {
general.import = [ ./tokyonight-storm.toml ]; general.import = [ ./tokyonight-storm.toml ];
cursor.style = { cursor.style = {

View File

@@ -1,13 +1,13 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.terminal.all;
optionName = "all terminals"; in
optionPath = [ {
"desktop" options.my.desktop.terminal.all = {
"terminal" enable = lib.mkEnableOption "all terminals";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.desktop.terminal = { my.desktop.terminal = {
alacritty.enable = true; alacritty.enable = true;
foot.enable = true; foot.enable = true;

View File

@@ -1,13 +1,14 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.terminal.foot;
programName = "foot"; in
optionPath = [ {
"desktop" options.my.desktop.terminal.foot = {
"terminal" enable = lib.mkEnableOption "foot";
"foot" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.foot.enable = true;
my.hm.programs.foot = { my.hm.programs.foot = {
server.enable = true; server.enable = true;
settings = { settings = {

View File

@@ -1,13 +1,14 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.terminal.ghostty;
programName = "ghostty"; in
optionPath = [ {
"desktop" options.my.desktop.terminal.ghostty = {
"terminal" enable = lib.mkEnableOption "ghostty";
"ghostty" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.ghostty.enable = true;
my.hm.programs.ghostty = { my.hm.programs.ghostty = {
enableBashIntegration = true; enableBashIntegration = true;
enableZshIntegration = true; enableZshIntegration = true;

View File

@@ -1,13 +1,14 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.desktop.terminal.kitty;
programName = "kitty"; in
optionPath = [ {
"desktop" options.my.desktop.terminal.kitty = {
"terminal" enable = lib.mkEnableOption "kitty";
"kitty" };
];
extraConfig = { config = lib.mkIf cfg.enable {
my.hm.programs.kitty.enable = true;
my.hm.programs.kitty = { my.hm.programs.kitty = {
settings = { settings = {
cursor_blink_interval = 0; cursor_blink_interval = 0;

View File

@@ -4,14 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.wine;
optionName = "wine"; in
optionPath = [ {
"desktop" options.my.desktop.wine = {
"wine" enable = lib.mkEnableOption "wine";
]; };
config' = {
config = lib.mkIf cfg.enable {
my.hm.home.packages = with pkgs; [ my.hm.home.packages = with pkgs; [
wine-wayland wine-wayland
bottles bottles

View File

@@ -3,15 +3,15 @@
lib, lib,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.desktop.wm.all;
optionName = "all window managers"; in
optionPath = [ {
"desktop" options.my.desktop.wm.all = {
"wm" enable = lib.mkEnableOption "all window managers";
"all" };
];
config' = { config = lib.mkIf cfg.enable {
my.desktop.wm = { my.desktop.wm = {
cage.enable = true; cage.enable = true;
niri.enable = true; niri.enable = true;

View File

@@ -4,13 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeHomePackageConfig { let
inherit config pkgs; cfg = config.my.desktop.wm.cage;
packageName = "cage"; in
packagePath = [ "cage" ]; {
optionPath = [ options.my.desktop.wm.cage = {
"desktop" enable = lib.mkEnableOption "cage";
"wm" };
"cage"
]; config = lib.mkIf cfg.enable {
my.hm.home.packages = [ pkgs.cage ];
};
} }

View File

@@ -4,12 +4,17 @@
lib, lib,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.fonts;
in
{
options.my.fonts = {
enable = lib.mkEnableOption "default font settings" // {
default = true; default = true;
optionName = "default font settings"; };
optionPath = [ "fonts" ]; };
config' = {
config = lib.mkIf cfg.enable {
fonts = { fonts = {
enableDefaultPackages = false; enableDefaultPackages = false;
fontDir.enable = true; fontDir.enable = true;

View File

@@ -2,18 +2,26 @@
config, config,
lib, lib,
pkgs, pkgs,
username,
... ...
}: }:
lib.my.makeHomeProgramConfig { let
inherit config; cfg = config.my.gpg;
programName = "gpg"; in
optionPath = [ "gpg" ]; {
extraConfig = { options.my.gpg = {
enable = lib.mkEnableOption "GPG and GPG agent";
};
config = lib.mkIf cfg.enable {
programs.gnupg.agent = { programs.gnupg.agent = {
enable = true; enable = true;
pinentryPackage = pkgs.pinentry-curses; pinentryPackage = pkgs.pinentry-curses;
enableSSHSupport = true; enableSSHSupport = true;
}; };
my.hm.programs.gpg.enable = true;
my.persist.homeDirs = [ my.persist.homeDirs = [
{ {
directory = ".gnupg"; directory = ".gnupg";

View File

@@ -4,14 +4,15 @@
pkgs, pkgs,
... ...
}: }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.i18n.fcitx5;
optionName = "default fcitx5 settings"; in
optionPath = [ {
"i18n" options.my.i18n.fcitx5 = {
"fcitx5" enable = lib.mkEnableOption "default fcitx5 settings";
]; };
config' = {
config = lib.mkIf cfg.enable {
i18n.inputMethod = { i18n.inputMethod = {
enable = true; enable = true;
type = "fcitx5"; type = "fcitx5";
@@ -114,17 +115,11 @@ lib.my.makeSwitch {
desktop, desktop,
}: }:
{ {
${pkg} = final.symlinkJoin {
${pkg} = final.stdenvNoCC.mkDerivation { name = prev.${pkg}.name;
inherit (prev.${pkg}) pname version; paths = [ prev.${pkg} ];
src = prev.${pkg};
phases = [
"unpackPhase"
"installPhase"
];
nativeBuildInputs = [ final.makeWrapper ]; nativeBuildInputs = [ final.makeWrapper ];
installPhase = '' postBuild = ''
cp -r . $out
substituteInPlace $out/share/applications/${desktop}.desktop --replace-quiet "${prev.${pkg}}" $out substituteInPlace $out/share/applications/${desktop}.desktop --replace-quiet "${prev.${pkg}}" $out
wrapProgram $out/bin/${exe} --add-flags "--wayland-text-input-version=3" wrapProgram $out/bin/${exe} --add-flags "--wayland-text-input-version=3"
''; '';
@@ -157,17 +152,10 @@ lib.my.makeSwitch {
( (
{ pkg, desktops }: { pkg, desktops }:
{ {
${pkg} = final.symlinkJoin {
${pkg} = final.stdenvNoCC.mkDerivation { name = prev.${pkg}.name;
inherit (prev.${pkg}) pname version; paths = [ prev.${pkg} ];
src = prev.${pkg}; postBuild = lib.concatLines (
phases = [
"unpackPhase"
"installPhase"
];
installPhase =
"cp -r . $out \n"
+ lib.concatLines (
map ( map (
desktop: desktop:
"substituteInPlace $out/share/applications/${desktop}.desktop --replace-fail 'Exec=' 'Exec=env QT_IM_MODULE=fcitx XMODIFIERS=@im=fcitx '" "substituteInPlace $out/share/applications/${desktop}.desktop --replace-fail 'Exec=' 'Exec=env QT_IM_MODULE=fcitx XMODIFIERS=@im=fcitx '"

View File

@@ -1,13 +1,15 @@
{ config, lib, ... }: { config, lib, ... }:
lib.my.makeSwitch { let
inherit config; cfg = config.my.i18n.locale;
in
{
options.my.i18n.locale = {
enable = lib.mkEnableOption "default locale settings" // {
default = true; default = true;
optionName = "default locale settings"; };
optionPath = [ };
"i18n"
"locale" config = lib.mkIf cfg.enable {
];
config' = {
i18n = { i18n = {
defaultLocale = "en_US.UTF-8"; defaultLocale = "en_US.UTF-8";
extraLocaleSettings = { extraLocaleSettings = {

View File

@@ -16,7 +16,9 @@ in
}; };
sshKeyFile = lib.mkOption { sshKeyFile = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.my.persist.location}/home/${username}/.ssh/id_ed25519"; default = "${
if config.my.persist.enable then config.my.persist.location else ""
}/home/${username}/.ssh/id_ed25519";
}; };
}; };

View File

@@ -23,25 +23,11 @@ let
} settings; } settings;
in in
{ {
imports = [
(lib.my.makeHomePackageConfig {
inherit config pkgs;
packageName = "moonlight-qt";
packagePath = [ "moonlight-qt" ];
optionPath = [
"virt"
"moonlight"
];
extraConfig = {
my.persist.homeDirs = [
".config/Moonlight Game Streaming Project"
];
};
})
];
options.my.virt = { options.my.virt = {
enable = lib.mkEnableOption "virtualization"; enable = lib.mkEnableOption "virtualization";
moonlight = {
enable = lib.mkEnableOption "Moonlight";
};
looking-glass = { looking-glass = {
enable = lib.mkEnableOption "looking-glass"; enable = lib.mkEnableOption "looking-glass";
package = lib.mkPackageOption pkgs "looking-glass-client" { }; package = lib.mkPackageOption pkgs "looking-glass-client" { };
@@ -116,7 +102,7 @@ in
settings = lib.mkOption { settings = lib.mkOption {
description = "Looking Glass client configuration"; description = "Looking Glass client configuration";
default = { }; default = { };
type = lib.types.submodule ./types; type = lib.types.submodule ./_types;
example = { example = {
app.shmFile = "/dev/kvmfr0"; app.shmFile = "/dev/kvmfr0";
@@ -232,5 +218,11 @@ in
users.users.${username}.extraGroups = [ "libvirtd" ]; users.users.${username}.extraGroups = [ "libvirtd" ];
environment.systemPackages = with pkgs; [ virglrenderer ]; environment.systemPackages = with pkgs; [ virglrenderer ];
}) })
(lib.mkIf cfg.moonlight.enable {
my.hm.home.packages = [ pkgs.moonlight-qt ];
my.persist.homeDirs = [
".config/Moonlight Game Streaming Project"
];
})
]; ];
} }

View File

@@ -1,95 +0,0 @@
{
self,
lib,
inputs,
pkgsParams,
...
}:
let
forAllHosts =
mkSystem:
lib.mergeAttrsList (
builtins.map (hostname: {
${hostname} = mkSystem hostname;
}) (builtins.attrNames (builtins.readDir ./config/hosts))
);
pkgsModule =
{ config, ... }:
{
nixpkgs = pkgsParams // {
inherit (config.nixpkgs.hostPlatform) system;
};
};
hmModule = {
home-manager = {
sharedModules = [
inputs.sops-nix.homeManagerModules.sops
inputs.impermanence.nixosModules.home-manager.impermanence
inputs.stylix.homeModules.stylix
inputs.noctalia.homeModules.default
inputs.zen.homeModules.beta
{
nixpkgs = lib.mkForce { };
}
];
useGlobalPkgs = true;
};
};
vars = import ./vars.nix;
in
{
flake.nixosConfigurations = forAllHosts (
hostname:
lib.nixosSystem {
specialArgs = {
inherit
inputs
self
hostname
;
assets =
with lib.haumea;
load {
src = ./assets;
loader = [
(matchers.always loaders.path)
];
};
secrets =
with lib.haumea;
load {
src = ./secrets;
loader = [
(matchers.always loaders.path)
];
};
}
// vars;
modules =
(lib.umport {
paths = [ ./modules ];
exclude = [
./modules/virt/types
];
recursive = true;
})
++ (lib.umport {
paths = [ ./config/hosts/${hostname} ];
recursive = true;
})
++ [
(lib.mkAliasOptionModule [ "my" "hm" ] [ "home-manager" "users" vars.username ])
./config/base.nix
inputs.sops-nix.nixosModules.sops
inputs.impermanence.nixosModules.impermanence
inputs.home-manager.nixosModules.default
inputs.niri.nixosModules.niri
inputs.catppuccin.nixosModules.catppuccin
inputs.angrr.nixosModules.angrr
pkgsModule
hmModule
];
}
);
}

49
profiles/base.nix Normal file
View File

@@ -0,0 +1,49 @@
{
config,
hostname,
...
}:
{
# I prefer this to the default issue text
# ported from ArchLinux IIRC
environment.etc.issue.text = "\\e{lightcyan}\\S\\e{reset} Login (\\l)\n\n";
networking.hostName = hostname;
# don't change this unless you know what you are doing!
# for further information, see wiki.nixos.org
system.stateVersion = "24.11";
# disable this since we already have machine-id persisted
systemd.services."systemd-machine-id-commit".enable = !config.my.persist.enable;
# Enable core modules (user, nix, xdg, time are enabled by default)
my = {
user.enable = true;
nix.enable = true;
xdg.enable = true;
time.enable = true;
};
# Base persistence configuration
my.persist = {
nixosDirs = [
"/root"
"/var"
"/etc/ssh"
];
nixosFiles = [
"/etc/machine-id"
];
homeDirs = [
{
directory = ".ssh";
mode = "0700";
}
];
};
# Home Manager base configuration
my.hm = {
# nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
home.stateVersion = "24.11";
};
}

47
profiles/desktop.nix Normal file
View File

@@ -0,0 +1,47 @@
{ lib, ... }:
{
# Boot loader configuration
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 10;
};
grub.enable = false;
timeout = 0;
};
security.pam.loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "524288";
}
];
# Graphics support
hardware.graphics = {
enable = true;
enable32Bit = true;
};
# Printing service
services.printing.enable = true;
# GVFS for virtual filesystems
services.gvfs.enable = true;
# Enable desktop-related modules by default
my = {
audio.enable = true;
bluetooth.enable = true;
fonts.enable = true;
};
# Desktop persistence
my.persist = {
enable = lib.mkDefault true;
location = lib.mkDefault "/nix/persist";
};
}

26
profiles/server.nix Normal file
View File

@@ -0,0 +1,26 @@
{ lib, ... }:
{
# Boot loader configuration
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 10;
};
grub.enable = false;
timeout = 0;
};
# Disable desktop features on servers
my = {
audio.enable = false;
bluetooth.enable = false;
fonts.enable = false;
};
# Server persistence
my.persist = {
enable = lib.mkDefault true;
location = lib.mkDefault "/nix/persist";
};
}

24
profiles/wsl.nix Normal file
View File

@@ -0,0 +1,24 @@
{ username, lib, ... }:
{
# WSL-specific configuration
wsl = {
enable = true;
defaultUser = username;
};
# Fix VSCode remote
programs.nix-ld.enable = true;
# Force platform (WSL is always x86_64-linux)
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
# Disable desktop features
my = {
audio.enable = false;
bluetooth.enable = false;
fonts.enable = false;
};
# Disable persistence for WSL
my.persist.enable = false;
}