fixes & cleanup
This commit is contained in:
@@ -36,28 +36,79 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs:
|
||||
outputs =
|
||||
inputs:
|
||||
let
|
||||
lib = inputs.nixpkgs.lib;
|
||||
gen = import ./generator.nix { inherit inputs; };
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
linuxSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
forEachSystem = lib.genAttrs;
|
||||
overlays = import ./overlays { inherit inputs; };
|
||||
mkPkgs =
|
||||
system:
|
||||
import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = overlays ++ [
|
||||
(final: prev: {
|
||||
custom = import ./packages { pkgs = final; };
|
||||
})
|
||||
];
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
gen = import ./generator.nix { inherit inputs mkPkgs supportedSystems; };
|
||||
systemsDir = ./systems;
|
||||
isIgnoredSystemDir = name: lib.hasPrefix "_" name || lib.hasPrefix "." name;
|
||||
systemNames = lib.attrNames (lib.filterAttrs
|
||||
(name: type:
|
||||
systemNames = lib.attrNames (
|
||||
lib.filterAttrs (
|
||||
name: type:
|
||||
type == "directory"
|
||||
&& !isIgnoredSystemDir name
|
||||
&& builtins.pathExists (systemsDir + "/${name}/cfg.nix"))
|
||||
(builtins.readDir systemsDir));
|
||||
hostsByType = systemType:
|
||||
lib.filter
|
||||
(host: (import (systemsDir + "/${host}/cfg.nix")).syscfg.type == systemType)
|
||||
systemNames;
|
||||
generateHosts = systemType:
|
||||
lib.genAttrs
|
||||
(hostsByType systemType)
|
||||
(host: gen.generate { inherit host; });
|
||||
in {
|
||||
devShells = import ./shells { inherit inputs; };
|
||||
&& builtins.pathExists (systemsDir + "/${name}/cfg.nix")
|
||||
) (builtins.readDir systemsDir)
|
||||
);
|
||||
hostsByType =
|
||||
systemType:
|
||||
lib.filter (host: (import (systemsDir + "/${host}/cfg.nix")).syscfg.type == systemType) systemNames;
|
||||
generateHosts =
|
||||
systemType: lib.genAttrs (hostsByType systemType) (host: gen.generate { inherit host; });
|
||||
flattenPackages =
|
||||
prefix: attrs:
|
||||
lib.concatMapAttrs (
|
||||
name: value:
|
||||
let
|
||||
packageName = lib.concatStringsSep "-" (prefix ++ [ name ]);
|
||||
defaultPackageName = lib.concatStringsSep "-" prefix;
|
||||
in
|
||||
if lib.isDerivation value then
|
||||
{
|
||||
"${if name == "default" && prefix != [ ] then defaultPackageName else packageName}" = value;
|
||||
}
|
||||
else if lib.isAttrs value then
|
||||
flattenPackages (if name == "default" then prefix else prefix ++ [ name ]) value
|
||||
else
|
||||
{ }
|
||||
) attrs;
|
||||
mkPackages =
|
||||
system:
|
||||
let
|
||||
pkgs = mkPkgs system;
|
||||
in
|
||||
lib.optionalAttrs pkgs.stdenv.isLinux (flattenPackages [ ] pkgs.custom);
|
||||
in
|
||||
{
|
||||
packages = forEachSystem linuxSystems mkPackages;
|
||||
devShells = import ./shells {
|
||||
inherit inputs mkPkgs;
|
||||
supportedSystems = linuxSystems;
|
||||
};
|
||||
|
||||
nixosConfigurations = generateHosts "nixos";
|
||||
darwinConfigurations = generateHosts "macos";
|
||||
@@ -76,8 +127,8 @@
|
||||
# diyu - ?
|
||||
# tirnanog - ?
|
||||
# valhalla - ?
|
||||
# arcadia - ?
|
||||
# elysium - ?
|
||||
# arcadia - ?
|
||||
# elysium - ?
|
||||
# empyrean - ?
|
||||
# duat - ?
|
||||
# sheol - ?
|
||||
|
||||
Reference in New Issue
Block a user