nixos-configs/packages/repl/repl.nix
matt1432 1b528a15d0
All checks were successful
Discord / discord commits (push) Has been skipped
feat(repl): make it work with onDroid
2024-11-21 12:59:47 -05:00

31 lines
755 B
Nix

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