diff --git a/flake.nix b/flake.nix index b20d8d4..aaf2559 100644 --- a/flake.nix +++ b/flake.nix @@ -92,13 +92,16 @@ default = self.overlays.kyouma; }; } // flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.kyouma ]; + }; in { -# packages = rec { + packages = shinyflakes.mapPackages (pkgs) { # newhost = pkgs.stdenv.mkDerivation { # name = "newhost"; # }; -# }; + }; # apps = rec { # newhost = self.packages.${system}.newhost; # default = newhost; diff --git a/lib/shinyflakes/default.nix b/lib/shinyflakes/default.nix index 1cf37e9..057760c 100644 --- a/lib/shinyflakes/default.nix +++ b/lib/shinyflakes/default.nix @@ -1,9 +1,10 @@ { self, nixpkgs, ... }@inputs: let - readHostDir = builtins.filter (name: name != "_minimal") ( - builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") ( - builtins.readDir ../../config/hosts))); + mapDir = dir: builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") ( + builtins.readDir ../../${dir})); - filterMinimal = attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix "-minimal" name)) attr; + filterDir = filterBy: dir: builtins.filter (name: name != filterBy) (mapDir dir); + + filterSuffix = suffix: attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix suffix name)) attr; genColmenaCfg = name: host: { deployment = { @@ -35,11 +36,14 @@ }; in { mapHosts = hostCfg: nixpkgs.lib.recursiveUpdate ( - nixpkgs.lib.genAttrs readHostDir (host: { hostname = host; })) hostCfg; + nixpkgs.lib.genAttrs (filterDir "_minimal" "config/hosts") (host: { hostname = host; })) hostCfg; mapColmenaCfg = extraColmenaCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (genColmenaCfg) ( - filterMinimal self.nixosConfigurations)) extraColmenaCfg; + filterSuffix "-minimal" self.nixosConfigurations)) extraColmenaCfg; mapNixosCfg = extraNixosCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (name: value: genNixosCfg value) self.hosts) extraNixosCfg; + + mapPackages = overlayPkgs: otherPackages: nixpkgs.lib.recursiveUpdate ( + nixpkgs.lib.genAttrs (mapDir "pkgs") (name: overlayPkgs.${name})) otherPackages; }