Commit 0950014

HPCesia <me@hpcesia.com>
2026-03-22 06:52:17
refactor: core -> den default
den
1 parent b75a8ed
modules/core/nix/database.nix
@@ -8,11 +8,11 @@
     inputs.nixpkgs.follows = "nixpkgs";
   };
 
-  flake.modules.nixos.core = {pkgs, ...}: {
+  den.default.nixos = {pkgs, ...}: {
     programs.command-not-found.dbPath = lib.mkForce inputs.programsdb.packages.${pkgs.stdenv.system}.programs-sqlite;
   };
 
-  flake.modules.homeManager.core = {
+  den.default.homeManager = {
     lib,
     pkgs,
     osConfig,
modules/core/nix/default.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = {
+  den.default.nixos = {
     nix.settings = {
       experimental-features = ["auto-allocate-uids" "cgroups"];
 
modules/core/nix/flakes.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     nix.settings = {
       experimental-features = ["nix-command" "flakes"];
       flake-registry = "";
modules/core/nix/github-token.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = {config, ...}: {
+  den.default.nixos = {config, ...}: {
     nix.extraOptions = ''
       !include ${config.vaultix.templates.nix-access-tokens.path}
     '';
modules/core/nix/lix.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = {pkgs, ...}: {
+  den.default.nixos = {pkgs, ...}: {
     nixpkgs.overlays = [
       (final: prev: {
         inherit
modules/core/nix/nh.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     programs.nh = {
       enable = true;
       clean.enable = true;
modules/core/nix/nixpkgs.nix
@@ -3,7 +3,7 @@
   config,
   ...
 }: {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     # nixos modules' nixpkgs config, will affect all nixos modules
     # flake-parts global nixpkgs config: modules/flake/nixpkgs.nix
     nixpkgs.config = {allowUnfree = true;};
modules/core/nix/substituters.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     nix.settings = {
       substituters = [
         # cache mirror located in China
modules/core/shell/bash.nix
@@ -1,9 +1,9 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     programs.bash.enable = true;
   };
 
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     programs.bash = {
       enable = true;
       enableCompletion = true;
modules/core/shell/fish.nix
@@ -1,11 +1,11 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     stylix.targets.fish.enable = false;
 
     programs.fish.enable = true;
   };
 
-  flake.modules.homeManager.core = {pkgs, ...}: {
+  den.default.homeManager = {pkgs, ...}: {
     programs.fish = {
       enable = true;
       generateCompletions = true;
modules/core/tools/starship/default.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     programs.starship = {
       enable = true;
 
@@ -7,7 +7,7 @@
       enableFishIntegration = true;
 
       # Read from file because I'm too lazy to convert it to Nix expr.
-      settings = builtins.fromTOML (builtins.readFile ./starship.toml);
+      settings = fromTOML (builtins.readFile ./starship.toml);
     };
   };
 }
modules/core/tools/autin.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     # Atuin replaces your existing shell history with a SQLite database,
     # and records additional context for your commands.
     # Additionally, it provides optional and fully encrypted
modules/core/tools/bat.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     # a cat clone with syntax highlighting and Git integration.
     programs.bat = {
       enable = true;
modules/core/tools/carapace.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     programs.carapace = {
       enable = true;
       enableBashIntegration = true;
modules/core/tools/eza.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     programs.eza = {
       enable = true;
       enableBashIntegration = true;
modules/core/tools/fastfetch.nix
@@ -1,9 +1,5 @@
 {
-  flake.modules.nixos.core = {pkgs, ...}: {
-    environment.systemPackages = [pkgs.fastfetch];
-  };
-
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     programs.fastfetch = {
       enable = true;
       settings = {
modules/core/tools/fzf.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     programs.fzf = {
       enable = true;
     };
modules/core/tools/packages.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = {pkgs, ...}: {
+  den.default.nixos = {pkgs, ...}: {
     environment.systemPackages = with pkgs; [
       git
 
@@ -25,11 +25,12 @@
       file
       which
       findutils
+      fastfetchMinimal
       zellij
     ];
   };
 
-  flake.modules.homeManager.core = {pkgs, ...}: {
+  den.default.homeManager = {pkgs, ...}: {
     home.packages = with pkgs; [
       fd # search for files by name, faster than find
       ripgrep # search for files by its content, replacement of grep
modules/core/tools/tealdeer.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     # very fast version of tldr in Rust
     programs.tealdeer = {
       enable = true;
modules/core/tools/yazi.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = {pkgs, ...}: let
+  den.default.homeManager = {pkgs, ...}: let
     yaziPlugins.auto-layout = pkgs.yaziPlugins.mkYaziPlugin {
       pname = "auto-layout.yazi";
       version = "unstable-25-07-30";
modules/core/tools/zellij.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = {config, ...}: {
+  den.default.homeManager = {config, ...}: {
     programs.zellij = {
       enable = true;
       settings = {
modules/core/tools/zoxide.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = _: {
+  den.default.homeManager = {
     # zoxide is a smarter cd command, inspired by z and autojump.
     # It remembers which directories you use most frequently,
     # so you can "jump" to them in just a few keystrokes.
modules/core/boot.nix
@@ -1,10 +1,10 @@
 {lib, ...}: {
-  flake.modules.nixos.boot-core = _: {
+  den.default.nixos = {
     boot.loader = {
       # Don't need to keep too many generations when using Git for version control.
       systemd-boot.configurationLimit = lib.mkDefault 10;
       # pick the highest resolution for systemd-boot's console.
-      consoleMode = lib.mkDefault "max";
+      systemd-boot.consoleMode = lib.mkDefault "max";
       # Wait x seconds to select the boot entry.
       timeout = lib.mkDefault 8;
     };
modules/core/editors.nix
@@ -1,12 +1,6 @@
 {
-  flake.modules.nixos.core = {pkgs, ...}: {
+  den.default.nixos = {pkgs, ...}: {
     environment.variables.EDITOR = "hx";
     environment.systemPackages = [pkgs.helix];
   };
-
-  flake.modules.homeManager.core = _: {
-    programs.helix = {
-      enable = true;
-    };
-  };
 }
modules/core/home.nix
@@ -1,14 +1,19 @@
-{inputs, ...}: {
-  flake.modules.nixos.core = _: {
-    imports = [
-      inputs.home-manager.nixosModules.home-manager
-    ];
-    home-manager.useGlobalPkgs = true;
-    home-manager.useUserPackages = true;
-    home-manager.backupFileExtension = "home-manager.backup";
+{
+  lib,
+  den,
+  ...
+}: {
+  den.default = {
+    includes = [den.aspects.core._.hm-host];
+    homeManager.manual.manpages.enable = false;
   };
-
-  flake.modules.homeManager.core = _: {
-    manual.manpages.enable = false;
+  den.aspects.core.provides.hm-host = {host, ...}: {
+    nixos = lib.optionalAttrs (host.home-manager.enable) {
+      home-manager = {
+        useGlobalPkgs = true;
+        useUserPackages = true;
+        backupFileExtension = "home-manager.backup";
+      };
+    };
   };
 }
modules/core/l10n.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = {config, ...}: {
+  den.default.nixos = {config, ...}: {
     time.timeZone = "Asia/Shanghai";
 
     # fix https://github.com/NixOS/nixpkgs/issues/238025
modules/core/nameserver.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     networking.nameservers = [
       # IPv4
       "119.29.29.29" # DNSPod
modules/core/networking.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     networking.nftables.enable = true;
   };
 }
modules/core/ssh.nix
@@ -1,23 +1,25 @@
-topArgs: {
-  flake.modules.nixos.core = {config, ...}: {
-    services.openssh = let
-      currentHostMeta = topArgs.config.flake.meta.host.hosts.${config.networking.hostName};
-    in {
-      enable = currentHostMeta.deploy; # Enable ssh server only for deployable hosts
-      ports = currentHostMeta.sshPorts;
-      settings = {
-        PermitRootLogin = "prohibit-password";
-        PasswordAuthentication = false;
+{den, ...}: {
+  den.default.includes = [
+    den.aspects.core._.ssh
+  ];
+  den.aspects.core.provides.ssh = {host, ...}: {
+    nixos = {
+      services.openssh = {
+        enable = host.deployable;
+        ports = host.sshPorts;
+        settings = {
+          PermitRootLogin = "prohibit-password";
+          PasswordAuthentication = false;
+        };
+        openFirewall = true;
+        hostKeys = [
+          {
+            path = "/etc/ssh/ssh_host_ed25519_key";
+            type = "ed25519";
+          }
+        ];
       };
-      openFirewall = true;
-      hostKeys = [
-        {
-          path = "/etc/ssh/ssh_host_ed25519_key";
-          type = "ed25519";
-        }
-      ];
+      environment.enableAllTerminfo = true;
     };
-
-    environment.enableAllTerminfo = true;
   };
 }
modules/core/stylix.nix
@@ -14,7 +14,7 @@
     };
   };
 
-  flake.modules.nixos.core = {
+  den.default.nixos = {
     pkgs,
     config,
     ...
modules/core/time-sync.nix
@@ -1,17 +1,16 @@
-{lib, ...} @ topArgs: {
-  flake.modules.nixos.core = {config, ...}: let
-    hostMeta = topArgs.config.flake.meta.host.hosts.${config.networking.hostName};
-  in {
-    # Use an NTP server located in the mainland of China to synchronize the system time
-    networking.timeServers = [
-      "ntp.aliyun.com" # Aliyun NTP Server
-      "ntp.tencent.com" # Tencent NTP Server
-    ];
-
-    # Use chrony for better time synchronization on laptops
-    services.timesyncd.enable = lib.mkIf (hostMeta.isLaptop) false;
-    services.chrony = lib.mkIf (hostMeta.isLaptop) {
-      enable = true;
+{den, ...}: {
+  den.default.includes = [den.aspects.core._.time-sync];
+  den.aspects.core.provides.time-sync = {host, ...}: {
+    nixos = {
+      # Use an NTP server located in the mainland of China to synchronize the system time
+      networking.timeServers = [
+        "ntp.aliyun.com" # Aliyun NTP Server
+        "ntp.tencent.com" # Tencent NTP Server
+      ];
+      services = {
+        timesyncd.enable = host.usage != "laptop";
+        chrony.enable = host.usage == "laptop";
+      };
     };
   };
 }
modules/core/userborn.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.core = _: {
+  den.default.nixos = {
     services.userborn.enable = true;
     users.mutableUsers = false;
   };
modules/core/xdg.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.core = {config, ...}: {
+  den.default.homeManager = {config, ...}: {
     xdg = {
       enable = true;
       userDirs.setSessionVariables = true;
modules/hosts/kevin/default.nix
@@ -50,7 +50,6 @@ in {
   flake.modules.nixos."hosts/kevin" = _: {
     imports =
       (with config.flake.modules.nixos; [
-        core
         desktop
         dev
       ])
@@ -66,7 +65,6 @@ in {
           home-manager.users.hpcesia = {
             imports =
               (with config.flake.modules.homeManager; [
-                core
                 desktop
                 dev
               ])
modules/hosts/pardofelis/default.nix
@@ -41,26 +41,22 @@
     isServer = true;
   };
   flake.modules.nixos."hosts/pardofelis" = _: {
-    imports =
-      (with config.flake.modules.nixos; [
-        core
-      ])
-      ++ (
-        map
-        (n: config.flake.modules.nixos."${config.flake.meta.service.prefix}${n}")
-        [
-          "artalk"
-          "authelia"
-          "fail2ban"
-          "forgejo"
-          "freshrss"
-          "goatcounter"
-          "gokapi"
-          "homepage"
-          "restic"
-          "vaultwarden"
-          "wakapi"
-        ]
-      );
+    imports = (
+      map
+      (n: config.flake.modules.nixos."${config.flake.meta.service.prefix}${n}")
+      [
+        "artalk"
+        "authelia"
+        "fail2ban"
+        "forgejo"
+        "freshrss"
+        "goatcounter"
+        "gokapi"
+        "homepage"
+        "restic"
+        "vaultwarden"
+        "wakapi"
+      ]
+    );
   };
 }