Skip to content

Conversation

@vic
Copy link
Owner

@vic vic commented Oct 28, 2025

list of changes:

  • moved most files to ./modules and import-tree them instead of manually imports.
  • better documentation on default aspect dependencies.
  • split host/homes aspects and default aspects to their own file.
  • moved den.aspects.default to den.default
    this is to avoid poluting the aspects namespace since we expect lots of user custom
    aspects to be there.
  • add batteries (and easily replaceable):
    • import-tree
      allows people to import non-dendritic nix directories.
      helps with migration path. and for auto-generated stuff like nixos-hardware.
    • home-managed host (nixos and darwin) (fixes home-manager as darwin-module? #13 )

Pending for other PR:

- [ ] unfree
      generates an aspect that allows unfree packages.

Copilot AI review requested due to automatic review settings October 28, 2025 19:12
@vic vic marked this pull request as draft October 28, 2025 19:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the module structure by moving configuration from nix/ to a new modules/ directory and reorganizing the aspect system. The refactoring improves modularity and introduces a clearer separation between different concerns.

  • Simplified nix/flakeModule.nix to use import-tree for automatic module importing from ../modules
  • Reorganized aspect-related code into separate modules under modules/aspects/
  • Added new configuration modules (modules/config.nix, modules/options.nix, modules/scope.nix)

Reviewed Changes

Copilot reviewed 7 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
nix/template-packages.nix New file providing package definitions for templates using flake-compat
nix/flakeModule.nix Simplified to delegate module imports to import-tree
nix/aspects.nix Removed (logic moved to modules/aspects/)
modules/scope.nix New file setting up the den scope using flake-aspects
modules/options.nix New file defining den.hosts and den.homes options
modules/config.nix New file building OS and home configurations
modules/aspects/dependencies.nix Refactored aspect dependency creation logic from nix/aspects.nix
modules/aspects/den-batteries/_import-tree.nix New aspect provider for importing class-based directory structures
modules/aspects/defaults.nix Extracted default aspect definitions from nix/aspects.nix
modules/_types.nix New file containing type definitions for hosts and homes
flake.nix Updated packages reference to use template-packages.nix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings October 28, 2025 19:58
@vic vic changed the title batteries included WIP: batteries included Oct 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings October 28, 2025 21:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 9 out of 13 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vic vic force-pushed the reorg branch 2 times, most recently from d05252b to 1137df2 Compare October 28, 2025 21:18
Copilot AI review requested due to automatic review settings October 28, 2025 21:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 11 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings October 28, 2025 22:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 15 out of 20 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings October 28, 2025 23:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vic vic marked this pull request as ready for review October 28, 2025 23:21
Copilot AI review requested due to automatic review settings October 28, 2025 23:21
@vic vic changed the title WIP: batteries included basic batteries included Oct 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings October 29, 2025 00:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,14 @@
# configures class-automatic module auto imports for hosts/users/homes.
# See _example/hosts/*/_${class}/*.nix
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path reference should be _compat instead of _example to match the actual directory structure shown in the file.

Suggested change
# See _example/hosts/*/_${class}/*.nix
# See _compat/hosts/*/_${class}/*.nix

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings October 29, 2025 01:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 44 to 57
value.imports = [ (hmModule user) ];
}) hmUsers;

aspect.${class} =
{ pkgs, ... }:
let
homeDir = if pkgs.stdenvNoCC.isDarwin then "/Users/${user.userName}" else "/home/${user.userName}";
in
{
imports = [ inputs.${host.hm-input or "home-manager"}."${class}Modules".home-manager ];
home-manager.users = lib.listToAttrs homes;
users.users.${user.userName} = {
name = lib.mkDefault user.userName;
home = lib.mkDefault homeDir;
};
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable user is not in scope here. The function signature at line 30 takes { host } as parameter, not { host, user }. The user variable should be referenced from the hmUsers iteration context or passed as a parameter.

Suggested change
value.imports = [ (hmModule user) ];
}) hmUsers;
aspect.${class} =
{ pkgs, ... }:
let
homeDir = if pkgs.stdenvNoCC.isDarwin then "/Users/${user.userName}" else "/home/${user.userName}";
in
{
imports = [ inputs.${host.hm-input or "home-manager"}."${class}Modules".home-manager ];
home-manager.users = lib.listToAttrs homes;
users.users.${user.userName} = {
name = lib.mkDefault user.userName;
home = lib.mkDefault homeDir;
};
value = {
imports = [ (hmModule user) ];
users = {
users = {
${user.userName} = {
name = lib.mkDefault user.userName;
home = lib.mkDefault (
pkgs: if pkgs.stdenvNoCC.isDarwin then "/Users/${user.userName}" else "/home/${user.userName}"
);
};
};
};
};
}) hmUsers;
aspect.${class} =
{ pkgs, ... }:
{
imports = [ inputs.${host.hm-input or "home-manager"}."${class}Modules".home-manager ];
home-manager.users = lib.listToAttrs (map (user: {
name = user.userName;
value = {
imports = [ (hmModule user) ];
};
}) hmUsers);
users.users = lib.foldl' (acc: user: acc // (homes
# get the value for this user and apply pkgs to home
|> builtins.filter (h: h.name == user.userName)
|> (hlist: if hlist == [] then {} else
let h = hlist[0]; in
lib.mapAttrs (k: v: if k == "users" then
lib.mapAttrs (u: uconf: {
name = uconf.name;
home = uconf.home pkgs;
}) v.users
else v) h.value
)
)
) {} hmUsers;

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings October 29, 2025 01:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

};
in
{
imports = [ hm ] ++ perUser;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The perUser variable is a list created by map perUser (lib.attrValues host.users) on line 51, but it's being concatenated directly here. Since perUser is already a list of attribute sets, this should work, but the variable name users on line 51 would be clearer than reusing the function name perUser which is defined on line 52.

Suggested change
imports = [ hm ] ++ perUser;
imports = [ hm ] ++ users;

Copilot uses AI. Check for mistakes.
Comment on lines +37 to 38
nix run .#write-flake --override-input den "github:$GITHUB_REPOSITORY/$GITHUB_SHA"
nix flake update den
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --override-input flag is added on line 37, but line 38 immediately runs nix flake update den which may override the previous input override. Consider whether the flake update is necessary after the override, or if the order should be reversed.

Suggested change
nix run .#write-flake --override-input den "github:$GITHUB_REPOSITORY/$GITHUB_SHA"
nix flake update den
nix flake update den
nix run .#write-flake --override-input den "github:$GITHUB_REPOSITORY/$GITHUB_SHA"

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings October 29, 2025 01:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 90 to 92
{ home }:
{ class, ... }:
let
path = if class == "darwin" then "/Users" else "/home";
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic determines the home directory path based on the class. Consider using the same approach as in modules/aspects/batteries/home-manager.nix line 51 which also implements this pattern, to ensure consistency. Additionally, the previous implementation checked if the system string 'hasSuffix "darwin"', which may be more robust than relying solely on the class name.

Suggested change
{ home }:
{ class, ... }:
let
path = if class == "darwin" then "/Users" else "/home";
{ home, system }:
{ class, ... }:
let
path = if lib.hasSuffix system "darwin" then "/Users" else "/home";

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings October 29, 2025 02:04
@vic vic force-pushed the reorg branch 2 times, most recently from f16b1cc to feb91fa Compare October 29, 2025 02:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 4 to +8
{
inputs,
den,
lib,
...
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module function parameters are missing lib, which is used on lines 93, 97, and 98. Add lib to the function parameters to avoid evaluation errors.

Copilot uses AI. Check for mistakes.
@vic vic force-pushed the reorg branch 2 times, most recently from 1e6a2c8 to 2aac283 Compare October 29, 2025 02:10
Copilot AI review requested due to automatic review settings October 29, 2025 02:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,14 @@
# configures class-automatic module auto imports for hosts/users/homes.
# See _example/hosts/*/_${class}/*.nix
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references 'example/hosts/*/${class}/*.nix' but the actual paths used in the code are './_compat/hosts', './_compat/users', and './_compat/homes'. This should be updated to reference '_compat/' instead of '_example/' to match the actual implementation.

Suggested change
# See _example/hosts/*/_${class}/*.nix
# See _compat/hosts/*/_${class}/*.nix

Copilot uses AI. Check for mistakes.
move defaults

fixing hm

fixing
Copilot AI review requested due to automatic review settings October 29, 2025 02:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 17 out of 22 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vic vic merged commit 445c67f into main Oct 29, 2025
6 checks passed
@vic vic deleted the reorg branch October 29, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

home-manager as darwin-module?

2 participants