From 809e11313a1c85e15c50595992d6009cd5a073cd Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sun, 25 May 2025 17:34:46 -0700 Subject: [PATCH] feat: seperate module imports --- hosts/default.nix | 26 +++----- modules/base/nix.nix | 112 ++++++++++++++++++----------------- modules/darwin/base/home.nix | 14 ++++- modules/darwin/default.nix | 4 +- modules/nixos/base/home.nix | 13 +++- modules/nixos/default.nix | 4 +- 6 files changed, 94 insertions(+), 79 deletions(-) diff --git a/hosts/default.nix b/hosts/default.nix index d36180d..dcb2bde 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -8,33 +8,23 @@ config.easy-hosts = { shared.specialArgs.marleylib = import ../lib; - ### Module Imports ### - # TODO: Move module imports to custom module - shared.modules = with inputs; [ - lix.nixosModules.default - agenix.nixosModules.default - - { - home-manager.sharedModules = [ - nixcord.homeModules.nixcord - ]; - } - ]; + # shared.modules = with inputs; [ + # # TODO: Move module imports to custom module + # { + # home-manager.sharedModules = [ + # nixcord.homeModules.nixcord + # ]; + # } + # ]; perClass = class: { modules = ["${self}/modules/${class}/default.nix"]; # modules = with inputs; # (nixpkgs.lib.optionals (class == "nixos") [ - # home-manager.nixosModules.home-manager - # agenix.nixosModules.default - # stylix.nixosModules.stylix # niri-flake.nixosModules.niri # ]) # ++ (nixpkgs.lib.optionals (class == "darwin") [ - # home-manager.darwinModules.home-manager - # agenix.darwinModules.default - # stylix.darwinModules.stylix # ]); }; diff --git a/modules/base/nix.nix b/modules/base/nix.nix index 2bf0877..1ec2ac4 100644 --- a/modules/base/nix.nix +++ b/modules/base/nix.nix @@ -1,62 +1,68 @@ { - pkgs, inputs, + pkgs, ... }: { - nix = { - package = pkgs.lix; + imports = [ + inputs.lix.nixosModules.default # this is universal, despite the 'nixos' + ]; - # Pin system to flake nixpkgs version. - # i.e. for use in pkgs = import {}. - nixPath = ["nixpkgs=${inputs.nixpkgs}"]; + config = { + nix = { + package = pkgs.lix; - # Pin flake registry nixpkgs to flake nixpkgs version. - # i.e. for use in nix search nixpkgs. - registry = { - nixpkgs.flake = inputs.nixpkgs; + # Pin system to flake nixpkgs version. + # i.e. for use in pkgs = import {}. + nixPath = ["nixpkgs=${inputs.nixpkgs}"]; + + # Pin flake registry nixpkgs to flake nixpkgs version. + # i.e. for use in nix search nixpkgs. + registry = { + nixpkgs.flake = inputs.nixpkgs; + }; + + settings = { + experimental-features = ["nix-command" "flakes"]; + + trusted-users = [ + "root" + # @wheel/@admin are added in OS specific modules. + ]; + + # Set up caches. + extra-substituters = [ + "https://marleyos.cachix.org" + "https://nix-community.cachix.org" + ]; + + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "marleyos.cachix.org-1:q2kEtqvS5CoQ8BmKlWOfOnN+fi4gUoSuL6HRKy37eCA=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + + # Disable that annoying "git tree is dirty" warning. + warn-dirty = false; + + auto-optimise-store = true; + + use-xdg-base-directories = true; + }; + + # Garbage collection. + gc.automatic = true; + + # More useful repl. + environment.systemPackages = let + nrepl = + pkgs.writeShellScriptBin "nrepl" + # sh + '' + nix repl "${toString ./.}/repl.nix" "$@" + ''; + in [ + nrepl + ]; }; - - settings = { - experimental-features = ["nix-command" "flakes"]; - - trusted-users = [ - "root" - # @wheel/@admin are added in OS specific modules. - ]; - - # Set up caches. - extra-substituters = [ - "https://marleyos.cachix.org" - "https://nix-community.cachix.org" - ]; - - trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "marleyos.cachix.org-1:q2kEtqvS5CoQ8BmKlWOfOnN+fi4gUoSuL6HRKy37eCA=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - - # Disable that annoying "git tree is dirty" warning. - warn-dirty = false; - - auto-optimise-store = true; - - use-xdg-base-directories = true; - }; - - # Garbage collection. - gc.automatic = true; - - # More useful repl. - environment.systemPackages = let - nrepl = - pkgs.writeShellScriptBin "nrepl" - # sh - '' - nix repl "${toString ./.}/repl.nix" "$@" - ''; - in [ - nrepl - ]; }; } diff --git a/modules/darwin/base/home.nix b/modules/darwin/base/home.nix index 1cd63b0..55695f6 100644 --- a/modules/darwin/base/home.nix +++ b/modules/darwin/base/home.nix @@ -1,7 +1,15 @@ -{config, ...}: let +{ + config, + inputs, + ... +}: let inherit (config.marleyos.my) name; in { - home-manager.users."${name}" = { - home.homeDirectory = "/Users/${name}"; + imports = [inputs.home-manager.darwinModules.home-manager]; + + config = { + home-manager.users."${name}" = { + home.homeDirectory = "/Users/${name}"; + }; }; } diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index e12f3d1..f7de3ff 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,5 +1,7 @@ -{ +{inputs, ...}: { imports = [ + inputs.agenix.darwinModules.default + ../base ./base ]; diff --git a/modules/nixos/base/home.nix b/modules/nixos/base/home.nix index bc54361..5883ce7 100644 --- a/modules/nixos/base/home.nix +++ b/modules/nixos/base/home.nix @@ -1,7 +1,14 @@ -{config, ...}: let +{ + config, + inputs, + ... +}: let inherit (config.marleyos.my) name; in { - home-manager.users."${name}" = { - home.homeDirectory = "/home/${name}"; + imports = [inputs.home-manager.nixosModules.home-manager]; + config = { + home-manager.users."${name}" = { + home.homeDirectory = "/home/${name}"; + }; }; } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 409c471..d7a3b1b 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,5 +1,7 @@ -{ +{inputs, ...}: { imports = [ + inputs.agenix.nixosModules.default + ../base ./base