2023-12-02 14:32:48 -05:00
|
|
|
{
|
2024-11-21 12:59:47 -05:00
|
|
|
flakePath,
|
2023-12-02 14:32:48 -05:00
|
|
|
hostnamePath ? "/etc/hostname",
|
|
|
|
}: let
|
2024-11-21 12:59:47 -05:00
|
|
|
inherit (builtins) currentSystem getFlake head match pathExists readFile removeAttrs;
|
2023-12-02 14:32:48 -05:00
|
|
|
|
|
|
|
hostname =
|
|
|
|
if pathExists hostnamePath
|
|
|
|
then head (match "([a-zA-Z0-9\\-]+)\n" (readFile hostnamePath))
|
|
|
|
else "";
|
|
|
|
|
2024-11-21 12:59:47 -05:00
|
|
|
self =
|
|
|
|
if pathExists flakePath
|
|
|
|
then
|
|
|
|
removeAttrs (getFlake (toString flakePath)) [
|
|
|
|
# If you use flakegen, these take a lot of space
|
|
|
|
"nextFlake"
|
|
|
|
"nextFlakeSource"
|
|
|
|
]
|
|
|
|
else {};
|
2023-12-02 14:32:48 -05:00
|
|
|
|
2024-11-21 12:59:47 -05:00
|
|
|
pkgs = self.inputs.nixpkgs.legacyPackages.${currentSystem} or {};
|
|
|
|
lib =
|
|
|
|
if pkgs != {}
|
|
|
|
then {inherit (pkgs) lib;}
|
|
|
|
else {};
|
2023-12-02 14:32:48 -05:00
|
|
|
in
|
2024-11-21 12:59:47 -05:00
|
|
|
{inherit lib pkgs self;}
|
|
|
|
// self.nixosConfigurations.${hostname}
|
|
|
|
or self.nixOnDroidConfigurations.default
|
|
|
|
or {}
|