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
[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
| | NixOS(Wayland) |
@@ -42,8 +45,19 @@ And more...
## Folder Structure
- `modules/` - custom NixOS modules
- `config/base.nix` - generic configs
- `config/hosts/<name>/` - hosts-specific configs
- `modules/core/` - core system modules (nix, persistence, time, user, xdg)
- `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
- `pkgs/` - custom packages
- `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
];
services.frp = {
enable = true;
instances."" = {
enable = true;
role = "client";
settings = {
serverAddr = "{{ .Envs.FRP_SERVER_ADDR }}";
@@ -384,7 +384,6 @@
customDomains = [ "memo.imxyy.top" ];
}
{
name = "efl-matrix-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 = {
sopsFile = secrets.imxyy-nix-server-hashed-password;
format = "binary";

View File

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

View File

@@ -6,40 +6,10 @@
...
}:
{
security.pam.loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "524288";
}
];
boot.kernelParams = [
"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.power-profiles-daemon.enable = true;
@@ -59,8 +29,6 @@
};
};
services.gvfs.enable = true;
services.openssh = {
enable = true;
settings = {
@@ -96,6 +64,4 @@
];
};
};
my.persist.nixosDirs = [ "/etc/NetworkManager/system-connections" ];
}

View File

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

View File

@@ -25,46 +25,17 @@ let
'';
in
{
security.pam.loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "524288";
}
];
systemd.services.btreset = {
script = lib.getExe btreset;
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot";
};
boot.kernelParams = [
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
"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 = {
enable = true;
keyboards = {
@@ -87,8 +58,6 @@ in
};
};
services.gvfs.enable = true;
programs.wireshark.enable = true;
programs.wireshark.package = pkgs.wireshark;
users.users.${username}.extraGroups = [ "wireshark" ];

View File

@@ -107,14 +107,34 @@
};
}
{
systems = [
"x86_64-linux"
];
systems = [ "x86_64-linux" ];
imports = [
./nixos.nix
./flake/hosts.nix
./treefmt.nix
./pkgs
./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.extend (
self: super: {
my = import ./my.nix { lib = self; };
umport = import ./umport.nix { lib = self; };
inherit (inputs.home-manager.lib) hm;
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 ? [ ],
include ? [ ],
exclude ? [ ],
extraExcludePredicate ? _: true,
recursive ? true,
}:
with lib;
@@ -22,23 +23,22 @@ let
excludedDirs = filter (path: pathIsDirectory path) exclude;
isExcluded =
path:
if elem path excludedFiles then
true
else
(filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ];
(elem path excludedFiles)
|| ((filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ])
|| extraExcludePredicate path;
in
unique (
(filter
(file: pathIsRegularFile file && hasSuffix ".nix" (builtins.toString file) && !isExcluded file)
(
concatMap (
_path:
path:
if recursive then
toList _path
toList path
else
mapAttrsToList (
name: type: _path + (if type == "directory" then "/${name}/default.nix" else "/${name}")
) (builtins.readDir _path)
name: type: path + (if type == "directory" then "/${name}/default.nix" else "/${name}")
) (builtins.readDir path)
) (unique (if path == null then paths else [ path ] ++ paths))
)
)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,12 +8,15 @@
username,
...
}:
lib.my.makeSwitch {
inherit config;
default = true;
optionName = "default nix settings";
optionPath = [ "nix" ];
config' = {
let
cfg = config.my.nix;
in
{
options.my.nix = {
enable = lib.mkEnableOption "default nix settings";
};
config = lib.mkIf cfg.enable {
# This will add each flake input as a registry
# To make nix3 commands consistent with your flake
nix.registry = (lib.mapAttrs (_: flake: { inherit flake; })) (
@@ -58,14 +61,24 @@ lib.my.makeSwitch {
group = "users";
mode = "0400";
};
my.hm.nix.extraOptions = ''
!include ${config.sops.secrets.nix-github-token.path}
'';
my.hm.home.packages = with pkgs; [
nixd
nixfmt
];
my.hm = {
nix.extraOptions = ''
!include ${config.sops.secrets.nix-github-token.path}
'';
home.packages = with pkgs; [
nixd
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
/*
@@ -82,10 +95,5 @@ lib.my.makeSwitch {
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";
location = lib.mkOption {
type = lib.types.str;
default = "/nix/persist";
example = lib.literalExpression ''
"/persistent"
'';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,7 +16,9 @@ in
};
sshKeyFile = lib.mkOption {
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;
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 = {
enable = lib.mkEnableOption "virtualization";
moonlight = {
enable = lib.mkEnableOption "Moonlight";
};
looking-glass = {
enable = lib.mkEnableOption "looking-glass";
package = lib.mkPackageOption pkgs "looking-glass-client" { };
@@ -116,7 +102,7 @@ in
settings = lib.mkOption {
description = "Looking Glass client configuration";
default = { };
type = lib.types.submodule ./types;
type = lib.types.submodule ./_types;
example = {
app.shmFile = "/dev/kvmfr0";
@@ -232,5 +218,11 @@ in
users.users.${username}.extraGroups = [ "libvirtd" ];
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;
}