Migrate to common module structure
This commit is contained in:
@@ -4,16 +4,18 @@ let
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../../modules/darwin/sane-defaults
|
||||
../../modules/common/sane-defaults
|
||||
../../modules/common/users
|
||||
];
|
||||
system.primaryUser = "yadunut";
|
||||
users.users."yadunut" = {
|
||||
openssh.authorizedKeys.keys = [ keys.yadunut ];
|
||||
};
|
||||
users.users."root" = {
|
||||
openssh.authorizedKeys.keys = [ keys.yadunut ];
|
||||
|
||||
nut = {
|
||||
users.enable = true;
|
||||
sane-defaults.enable = true;
|
||||
};
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
homebrew = {
|
||||
enable = true;
|
||||
onActivation.cleanup = "zap";
|
||||
|
||||
32
modules/common/sane-defaults/default.nix
Normal file
32
modules/common/sane-defaults/default.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
_class,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf mkEnableOption;
|
||||
cfg = config.nut.sane-defaults;
|
||||
nixosModule = mkIf cfg.enable { };
|
||||
darwinModule = mkIf cfg.enable {
|
||||
system.defaults = {
|
||||
NSGlobalDomain = {
|
||||
InitialKeyRepeat = 10;
|
||||
KeyRepeat = 1;
|
||||
AppleShowAllExtensions = true;
|
||||
ApplePressAndHoldEnabled = false;
|
||||
};
|
||||
dock.autohide = true;
|
||||
dock.autohide-delay = 0.0;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.optionalAttrs (_class == "nixos") nixosModule)
|
||||
(lib.optionalAttrs (_class == "darwin") darwinModule)
|
||||
];
|
||||
options.nut.sane-defaults = {
|
||||
enable = mkEnableOption "enable sane defaults";
|
||||
};
|
||||
}
|
||||
19
modules/common/template/default.nix
Normal file
19
modules/common/template/default.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
_class,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
cfg = config.nut.template;
|
||||
nixosModule = mkIf cfg.enable { };
|
||||
darwinModule = mkIf cfg.enable { };
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.optionalAttrs (_class == "nixos") nixosModule)
|
||||
(lib.optionalAttrs (_class == "darwin") darwinModule)
|
||||
];
|
||||
options.nut.template = { };
|
||||
}
|
||||
53
modules/common/users/default.nix
Normal file
53
modules/common/users/default.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
_class,
|
||||
lib,
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
keys = import ../../../keys.nix;
|
||||
cfg = config.nut.users;
|
||||
nixosModule = {
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Enable Home Manager for NixOS and define the user
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.yadunut = {
|
||||
imports = [ ./home.nix ];
|
||||
home.homeDirectory = lib.mkForce "/home/yadunut";
|
||||
};
|
||||
};
|
||||
};
|
||||
darwinModule = {
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users."yadunut" = {
|
||||
openssh.authorizedKeys.keys = [ keys.yadunut ];
|
||||
};
|
||||
users.users."root" = {
|
||||
openssh.authorizedKeys.keys = [ keys.yadunut ];
|
||||
};
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.yadunut = {
|
||||
imports = [ ./home.nix ];
|
||||
home.homeDirectory = lib.mkForce "/Users/yadunut";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# Import the correct Home Manager module for the current platform
|
||||
(
|
||||
if _class == "darwin" then
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
else
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
)
|
||||
(lib.optionalAttrs (_class == "nixos") nixosModule)
|
||||
(lib.optionalAttrs (_class == "darwin") darwinModule)
|
||||
];
|
||||
options.nut.users = {
|
||||
enable = lib.mkEnableOption "user setup";
|
||||
};
|
||||
}
|
||||
45
modules/common/users/home.nix
Normal file
45
modules/common/users/home.nix
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
_class,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
config = {
|
||||
nut = {
|
||||
git = {
|
||||
enable = true;
|
||||
gpgProgram = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
|
||||
signingKey = "~/.ssh/yadunut_ed25519.pub";
|
||||
};
|
||||
zsh.enable = true;
|
||||
};
|
||||
home.username = "yadunut";
|
||||
home.packages = [
|
||||
pkgs.entr
|
||||
pkgs.jq
|
||||
pkgs.just
|
||||
pkgs.rsync
|
||||
pkgs.codex
|
||||
pkgs.dive
|
||||
pkgs.cachix
|
||||
pkgs.ouch
|
||||
|
||||
pkgs.claude-code
|
||||
pkgs.codex
|
||||
pkgs.amp-cli
|
||||
];
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
programs.home-manager.enable = true;
|
||||
home.stateVersion = "25.05";
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
config
|
||||
../../home/git
|
||||
../../home/zsh
|
||||
];
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
self,
|
||||
lib,
|
||||
inputs,
|
||||
clan-core,
|
||||
specialArgs,
|
||||
config,
|
||||
options,
|
||||
_class,
|
||||
modulesPath,
|
||||
_prefix,
|
||||
}@args:
|
||||
let
|
||||
_ = builtins.trace "MODULE ARGS:\n${lib.generators.toPretty { } (builtins.attrNames args)}" null;
|
||||
in
|
||||
{
|
||||
system.defaults = {
|
||||
NSGlobalDomain = {
|
||||
InitialKeyRepeat = 10;
|
||||
KeyRepeat = 1;
|
||||
AppleShowAllExtensions = true;
|
||||
ApplePressAndHoldEnabled = false;
|
||||
};
|
||||
dock.autohide = true;
|
||||
dock.autohide-delay = 0.0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user