feat(nix): add system module, pass config to lib

This commit introduces a system module for NixOS and Home Manager,
and passes the configuration to the lib file.
This commit is contained in:
Mohammad Rafiq 2025-07-07 07:58:15 +08:00
parent b7358cd825
commit 46cf93f69b
No known key found for this signature in database
4 changed files with 25 additions and 6 deletions

View file

@ -1,12 +1,13 @@
{ config, lib, ... }:
let
inherit (config.flake.lib) flattenAttrs;
cfg = config.flake;
inherit (config.flake.lib) forAllUsers flattenAttrs;
inherit (lib.attrsets) filterAttrs;
owner = flattenAttrs (filterAttrs (_: v: (v.primary or false)) config.flake.manifest.users);
owner = flattenAttrs (filterAttrs (_: v: (v.primary or false)) cfg.manifest.users);
in
{
flake.modules.nixos.default =
{ pkgs, ... }:
{ pkgs, config, ... }:
{
#TODO: move sudo/security options elsewhere
security.sudo.wheelNeedsPassword = false;
@ -26,5 +27,12 @@ in
openssh.authorizedKeys.keys = [ owner.pubkey ];
};
};
home-manager.users = forAllUsers (
name: _: {
#TODO: move into nixos/darwin config - should not apply to homeConfigurations
home.username = name;
home.homeDirectory = config.users.users.${name}.home;
}
);
};
}