gerg-utils 2.0

This commit is contained in:
Gerg-L 2023-11-01 21:39:39 -04:00
parent 42b80afd9c
commit 4196aac49c
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
2 changed files with 45 additions and 30 deletions

View file

@ -58,23 +58,39 @@ rec {
); );
gerg-utils = gerg-utils =
config: f: config: outputs:
lib.foldr lib.recursiveUpdate { } ( lib.foldAttrs lib.mergeAttrs { } (
map map
( (
system: system:
f { let
inherit system;
pkgs = pkgs =
if config == { } then if config == { } then
unstable.legacyPackages.${system} unstable.legacyPackages.${system}
else else
import unstable { inherit system config; }; 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-linux" ]
); );
#"x86_64-darwin" "aarch64-linux" "aarch64-darwin"
mkHosts = mkHosts =
system: names: system: names:
@ -86,11 +102,11 @@ rec {
modules = modules =
let let
inputs' = constructInputs' system inputs; importWithInputs' = map (x: import x (constructInputs' system inputs));
in in
builtins.concatLists [ builtins.concatLists [
(map (x: import x inputs') (builtins.attrValues self.nixosModules)) (importWithInputs' (builtins.attrValues self.nixosModules))
(map (x: import x inputs') (listNixFilesRecursive "${self}/hosts/${name}")) (importWithInputs' (listNixFilesRecursive "${self}/hosts/${name}"))
(import "${unstable}/nixos/modules/module-list.nix") (import "${unstable}/nixos/modules/module-list.nix")
(lib.singleton { (lib.singleton {
networking.hostName = name; networking.hostName = name;

View file

@ -2,25 +2,25 @@ inputs:
let let
lib = import ./lib inputs; lib = import ./lib inputs;
in in
lib.gerg-utils { allowUnfree = true; } ( lib.gerg-utils { } {
{ pkgs, system, ... }: inherit lib;
{ nixosConfigurations = lib.mkHosts "x86_64-linux" [
inherit lib; "gerg-desktop"
nixosConfigurations = lib.mkHosts "x86_64-linux" [ "game-desktop"
"gerg-desktop" "media-laptop"
"game-desktop" "iso"
"media-laptop" ];
"iso"
];
nixosModules = lib.mkModules ./modules; nixosModules = lib.mkModules ./modules;
diskoConfigurations = lib.mkDisko [ diskoConfigurations = lib.mkDisko [
"gerg-desktop" "gerg-desktop"
"game-desktop" "game-desktop"
"media-laptop" "media-laptop"
]; ];
formatter.${system} = pkgs.writeShellApplication { formatter =
pkgs:
pkgs.writeShellApplication {
name = "lint"; name = "lint";
runtimeInputs = [ runtimeInputs = [
(pkgs.nixfmt.overrideAttrs { (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;
} }
)