From 9786eb8672213344d8d1b7bdef12bc94510b20db Mon Sep 17 00:00:00 2001 From: outremonde Date: Tue, 10 Jun 2025 20:32:00 -0400 Subject: initialized repository Former-commit-id: 84647f22b951a957b2b83885b612115d473f6626 --- lib/helper.nix | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lib/helper.nix (limited to 'lib/helper.nix') diff --git a/lib/helper.nix b/lib/helper.nix new file mode 100644 index 0000000..5bea0f1 --- /dev/null +++ b/lib/helper.nix @@ -0,0 +1,80 @@ +{inputs}: let + helper = (import ./helper.nix) {inherit inputs;}; +in rec { + # Library to shorten flake. + + # Package Helpers + pkgsFor = sys: inputs.nixpkgs.legacyPackages.${sys}; + + # Miscellaneous + forAllSystems = inputs.nixpkgs.lib.genAttrs [ + "aarch64-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + + # Create a custom packages overlat for use in configs. IDK HOW THIS WORKS BUT IT DOES + customPackagesOverlay.nixpkgs.overlays = [ + (final: prev: + import ../pkgs { + pkgs = final; + inherit inputs; + }) + ]; + + # Create custom packages set for exposure via flake. + customPackages = forAllSystems ( + system: + import ../pkgs { + pkgs = inputs.nixpkgs.legacyPackages.${system}; + inherit inputs; + } + ); + + # Get Custom Libraries + umport = (import ./umport.nix {inherit (inputs.nixpkgs) lib;}).umport; + + # Configuration Buildables + mkSystem = system: architecture: ( + inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit inputs helper; + }; + modules = + [ + ../systems/${system}/system.nix + customPackagesOverlay + ] + ++ umport { + paths = [ + ../modules/system + ../features/system + ]; + recursive = true; + }; + system = architecture; + } + ); + + mkHome = user: system: architecture: ( + inputs.home-manager.lib.homeManagerConfiguration { + pkgs = pkgsFor architecture; + extraSpecialArgs = { + inherit inputs helper; + }; + modules = + [ + ../users/${system}/${user}.nix + customPackagesOverlay + ] + ++ umport { + paths = [ + ../modules/user + ../features/user + ]; + recursive = true; + }; + } + ); +} -- cgit v1.2.3