chore!(util): clean up
Fix `hasDirectories` Correctly detect `autoDarwinConfigurations` (did not check for `home`) Decrease usage of `with` Depend more on `lib` functions over custom implementations Reindent correctly some code
This commit is contained in:
parent
c58f383168
commit
46f6f90a0c
2 changed files with 64 additions and 42 deletions
39
flake.nix
39
flake.nix
|
@ -78,25 +78,24 @@
|
|||
let
|
||||
inherit (self) outputs;
|
||||
util = import ./util { inherit inputs outputs; };
|
||||
in
|
||||
with util; rec {
|
||||
in rec {
|
||||
# Packages (`nix build`)
|
||||
packages = forEachPkgs (pkgs:
|
||||
packages = util.forEachPkgs (pkgs:
|
||||
import ./pkgs { inherit pkgs; }
|
||||
);
|
||||
|
||||
# Apps (`nix run`)
|
||||
apps = forEachPkgs (pkgs:
|
||||
apps = util.forEachPkgs (pkgs:
|
||||
import ./apps { inherit pkgs; }
|
||||
);
|
||||
|
||||
# Dev Shells (`nix develop`)
|
||||
devShells = forEachPkgs (pkgs:
|
||||
devShells = util.forEachPkgs (pkgs:
|
||||
import ./shells { inherit pkgs; }
|
||||
);
|
||||
|
||||
# Formatter
|
||||
formatter = forEachPkgs (pkgs:
|
||||
formatter = util.forEachPkgs (pkgs:
|
||||
pkgs.nixpkgs-fmt
|
||||
);
|
||||
|
||||
|
@ -107,22 +106,24 @@
|
|||
overlays = import ./overlays { inherit inputs outputs; };
|
||||
|
||||
# Machines
|
||||
inherit machines;
|
||||
inherit homeManagerMachines;
|
||||
inherit nixDarwinMachines;
|
||||
inherit nixOnDroidMachines;
|
||||
inherit nixosMachines;
|
||||
inherit (util)
|
||||
machines
|
||||
homeManagerMachines
|
||||
nixDarwinMachines
|
||||
nixOnDroidMachines
|
||||
nixosMachines;
|
||||
|
||||
# Modules
|
||||
inherit nixosModules;
|
||||
inherit nixOnDroidModules;
|
||||
inherit nixDarwinModules;
|
||||
inherit homeManagerModules;
|
||||
inherit (util)
|
||||
nixosModules
|
||||
nixOnDroidModules
|
||||
nixDarwinModules
|
||||
homeManagerModules;
|
||||
|
||||
# Configurations
|
||||
nixosConfigurations = autoNixosConfigurations;
|
||||
nixOnDroidConfigurations = autoNixOnDroidConfigurations;
|
||||
darwinConfigurations = autoDarwinConfigurations;
|
||||
homeConfigurations = autoHomeConfigurations;
|
||||
nixosConfigurations = util.autoNixosConfigurations;
|
||||
nixOnDroidConfigurations = util.autoNixOnDroidConfigurations;
|
||||
darwinConfigurations = util.autoDarwinConfigurations;
|
||||
homeConfigurations = util.autoHomeConfigurations;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ rec {
|
|||
# NOTE: Implying `attrs` is the output of `recurseDir`
|
||||
hasFiles = files: attrs:
|
||||
builtins.all
|
||||
(b: b)
|
||||
lib.id
|
||||
(builtins.map
|
||||
(file:
|
||||
builtins.hasAttr file attrs &&
|
||||
|
@ -30,13 +30,15 @@ rec {
|
|||
# NOTE: Implying `attrs` is the output of `recurseDir`
|
||||
hasDirectories = directories: attrs:
|
||||
builtins.all
|
||||
(b: b)
|
||||
lib.id
|
||||
(builtins.map
|
||||
(directory:
|
||||
builtins.hasAttr directory attrs &&
|
||||
builtins.getAttr directory attrs == "set")
|
||||
lib.isAttrs (builtins.getAttr directory attrs))
|
||||
directories);
|
||||
|
||||
and = lib.all lib.id;
|
||||
|
||||
# pkgs helpers
|
||||
forEachSystem = lib.genAttrs [
|
||||
"aarch64-linux"
|
||||
|
@ -159,13 +161,14 @@ rec {
|
|||
createConfigurations =
|
||||
pred: mkHost: machines:
|
||||
lib.foldAttrs
|
||||
(acc: x: acc)
|
||||
lib.const
|
||||
[ ]
|
||||
(builtins.attrValues
|
||||
(builtins.mapAttrs
|
||||
(system: hosts:
|
||||
lib.attrsets.filterAttrs
|
||||
(host: config: config != null)
|
||||
(host: config:
|
||||
config != null)
|
||||
(builtins.mapAttrs
|
||||
(host: config:
|
||||
if (pred system host config)
|
||||
|
@ -178,9 +181,15 @@ rec {
|
|||
autoNixosConfigurations =
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "configuration.nix" ]
|
||||
config)
|
||||
(hasDirectories
|
||||
[ "home" ]
|
||||
config)
|
||||
])
|
||||
(system: host: config:
|
||||
mkNixosHost
|
||||
../machines/nixos/${system}/${host}
|
||||
|
@ -194,9 +203,12 @@ rec {
|
|||
autoNixOnDroidConfigurations =
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "configuration.nix" "home.nix" ]
|
||||
config)
|
||||
])
|
||||
(system: host: config:
|
||||
mkNixOnDroidHost
|
||||
../machines/nix-on-droid/${system}/${host}
|
||||
|
@ -207,9 +219,15 @@ rec {
|
|||
autoDarwinConfigurations =
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "configuration.nix" ]
|
||||
config)
|
||||
(hasDirectories
|
||||
[ "home" ]
|
||||
config)
|
||||
])
|
||||
(system: host: config:
|
||||
mkNixDarwinHost
|
||||
../machines/nix-darwin/${system}/${host}
|
||||
|
@ -223,9 +241,12 @@ rec {
|
|||
autoHomeConfigurations =
|
||||
createConfigurations
|
||||
(system: host: config:
|
||||
hasFiles
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "home.nix" ]
|
||||
config)
|
||||
])
|
||||
(system: host: config:
|
||||
mkHomeManagerHost
|
||||
../machines/home-manager/${system}/${host}
|
||||
|
|
Loading…
Reference in a new issue