repl.nix (872B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{ path ? /etc/nixos, host ? false, }: let inherit (builtins) currentSystem getFlake head match pathExists readFile removeAttrs toString ; flake = if pathExists "${path}/flake.nix" then getFlake "${toString path}" else getFlake "/etc/nixos"; pkgs = if (flake.inputs ? nixpkgs) then import flake.inputs.nixpkgs.outPath {} else if (flake.legacyPackages ? currentSystem) then import flake.legacyPackages."${currentSystem}" else import <nixpkgs> {}; in { inherit flake; } // builtins // (removeAttrs (pkgs // pkgs.lib) [ "options" "config" ]) // flake // (flake.nixosConfigurations or {}) // ( if host then flake.nixosConfigurations."${head ( match '' ([a-zA-Z0-9\-]+) '' (readFile "/etc/hostname") )}" else {} )