From 4196aac49c763c4ee2246af912e70589e0154586 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Wed, 1 Nov 2023 21:39:39 -0400 Subject: [PATCH] gerg-utils 2.0 --- lib/default.nix | 34 +++++++++++++++++++++++++--------- outputs.nix | 41 ++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index e3cc3af..4135a50 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -58,23 +58,39 @@ rec { ); gerg-utils = - config: f: - lib.foldr lib.recursiveUpdate { } ( + config: outputs: + lib.foldAttrs lib.mergeAttrs { } ( map ( system: - f { - inherit system; + let pkgs = if config == { } then unstable.legacyPackages.${system} else import unstable { inherit system config; }; - } + in + lib.mapAttrs + ( + name: value: + if + builtins.elem name [ + "defaultPackage" + "devShell" + "devShells" + "formatter" + "legacyPackages" + "packages" + ] + then + { ${system} = value pkgs; } + else + value + ) + outputs ) [ "x86_64-linux" ] ); - #"x86_64-darwin" "aarch64-linux" "aarch64-darwin" mkHosts = system: names: @@ -86,11 +102,11 @@ rec { modules = let - inputs' = constructInputs' system inputs; + importWithInputs' = map (x: import x (constructInputs' system inputs)); in builtins.concatLists [ - (map (x: import x inputs') (builtins.attrValues self.nixosModules)) - (map (x: import x inputs') (listNixFilesRecursive "${self}/hosts/${name}")) + (importWithInputs' (builtins.attrValues self.nixosModules)) + (importWithInputs' (listNixFilesRecursive "${self}/hosts/${name}")) (import "${unstable}/nixos/modules/module-list.nix") (lib.singleton { networking.hostName = name; diff --git a/outputs.nix b/outputs.nix index 75d38aa..33af969 100644 --- a/outputs.nix +++ b/outputs.nix @@ -2,25 +2,25 @@ inputs: let lib = import ./lib inputs; in -lib.gerg-utils { allowUnfree = true; } ( - { pkgs, system, ... }: - { - inherit lib; - nixosConfigurations = lib.mkHosts "x86_64-linux" [ - "gerg-desktop" - "game-desktop" - "media-laptop" - "iso" - ]; +lib.gerg-utils { } { + inherit lib; + nixosConfigurations = lib.mkHosts "x86_64-linux" [ + "gerg-desktop" + "game-desktop" + "media-laptop" + "iso" + ]; - nixosModules = lib.mkModules ./modules; + nixosModules = lib.mkModules ./modules; - diskoConfigurations = lib.mkDisko [ - "gerg-desktop" - "game-desktop" - "media-laptop" - ]; - formatter.${system} = pkgs.writeShellApplication { + diskoConfigurations = lib.mkDisko [ + "gerg-desktop" + "game-desktop" + "media-laptop" + ]; + formatter = + pkgs: + pkgs.writeShellApplication { name = "lint"; runtimeInputs = [ (pkgs.nixfmt.overrideAttrs { @@ -38,8 +38,7 @@ lib.gerg-utils { allowUnfree = true; } ( ''; }; - devShells.${system}.default = pkgs.mkShell { packages = [ pkgs.sops ]; }; + devShells = pkgs: { default = pkgs.mkShell { packages = [ pkgs.sops ]; }; }; - packages.${system} = lib.mkPackages ./packages pkgs; - } -) + packages = lib.mkPackages ./packages; +}