From d7073b0472c60436ac93ed4ec2dee8a9abb278bd Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Thu, 1 Aug 2024 00:46:04 -0700 Subject: [PATCH] builders: refactor --- lib/builders.nix | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/builders.nix b/lib/builders.nix index 5cb8820..a05310e 100644 --- a/lib/builders.nix +++ b/lib/builders.nix @@ -2,13 +2,18 @@ let lib = nixpkgs.lib.extend (import ../lib); + + inherit (inputs.home-manager.lib) homeManagerConfiguration; + inherit (nixpkgs.lib) nixosSystem; + inherit (lib.strings) optionalString; + inherit (lib.attrsets) nameValuePair; in rec { toPartialNixosConfig = { hostname, system }: - { - name = hostname; - value = nixpkgs.lib.nixosSystem { + nameValuePair + hostname + (nixosSystem { inherit system; specialArgs = { inherit inputs lib; }; modules = [ @@ -16,8 +21,7 @@ rec { ../hosts/${hostname}/configuration.nix inputs.home-manager.nixosModules.default ]; - }; - }; + }); compileSystems = systems: lib.right @@ -29,12 +33,12 @@ rec { { user, system, hostname ? "", configHostname ? "" }: let configHost = if builtins.stringLength configHostname > 0 then configHostname else hostname; - hostStr = lib.strings.optionalString (builtins.stringLength hostname > 0) "@${hostname}"; + hostStr = optionalString (builtins.stringLength hostname > 0) "@${hostname}"; in assert lib.assertMsg (builtins.stringLength configHost > 0) "either configHostname or hostname need to exist"; - { - name = "${user}${hostStr}"; - value = inputs.home-manager.lib.homeManagerConfiguration { + nameValuePair + "${user}${hostStr}" + (homeManagerConfiguration { pkgs = nixpkgs.legacyPackages."${system}"; extraSpecialArgs = { inherit inputs; @@ -44,8 +48,7 @@ rec { modules = [ ../hosts/${configHost}/home.nix ]; - }; - }; + }); compileHomes = systems: lib.right