56 lines
2 KiB
Nix
56 lines
2 KiB
Nix
{ inputs ? import ./inputs.nix {} }:
|
|
|
|
let
|
|
|
|
lib = (import "${inputs.nixpkgs}/lib").extend (import ./lib/overlays/version-info-fixup.nix { inherit inputs; });
|
|
|
|
self = {
|
|
inherit inputs lib self;
|
|
modifiedNixpkgs = import ./pkgs/top-level/impure.nix;
|
|
modifiedNixpkgsPure = import ./pkgs/top-level/default.nix;
|
|
overlays = {
|
|
selfExpr = import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = inputs.nixpkgs; };
|
|
unstable = import ./pkgs/overlays/unstable.nix;
|
|
versionInfoFixup = import ./pkgs/overlays/version-info-fixup.nix { inherit inputs; };
|
|
};
|
|
nixosConfigurations = let
|
|
# list nix file paths in ./hosts to attributes in nixosConfigurations
|
|
filePaths = lib.pipe ./hosts [
|
|
builtins.readDir
|
|
( lib.filterAttrs (name: type:
|
|
# filter out non-nix files
|
|
type == "regular"
|
|
# filter out files that don't end in .nix
|
|
&& lib.hasSuffix ".nix" name
|
|
# filter out files that start with .
|
|
&& !lib.hasPrefix "." name
|
|
))
|
|
(lib.mapAttrsToList (name: _: name))
|
|
];
|
|
nixosSystem = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix";
|
|
in
|
|
# mapped list of nix file paths to attrSet with initialized NixOS configurations,
|
|
# whose names are derived from file names
|
|
lib.pipe filePaths [
|
|
(builtins.map (name: {
|
|
name = builtins.substring 0 (builtins.stringLength name - 4) name;
|
|
value = nixosSystem {
|
|
inherit lib;
|
|
modules = [
|
|
./hosts/${name}
|
|
{
|
|
config.nixpkgs.overlays = [
|
|
( import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = "${builtins.toString ./.}/pkgs/top-level/impure.nix"; } )
|
|
( import "${inputs.nixpkgs}/pkgs/top-level/by-name-overlay.nix" "${builtins.toString ./.}/pkgs/by-name" )
|
|
self.overlays.versionInfoFixup
|
|
];
|
|
}
|
|
];
|
|
specialArgs = { inherit self inputs; };
|
|
};
|
|
}))
|
|
builtins.listToAttrs
|
|
];
|
|
};
|
|
|
|
in self
|