Tweak repl implementation

This commit is contained in:
Gytis Ivaskevicius 2021-08-23 21:58:05 +03:00 committed by David Arnold
parent ebb41749ab
commit ecfd19c7b9
2 changed files with 5 additions and 5 deletions

View File

@ -24,7 +24,7 @@ Main flake-utils-plus features (Attributes visible from `flake.nix`):
- [`lib.exportModules [ ./a.nix ./b.nix ]`](./lib/exportModules.nix) - Generates module attribute which look like this `{ a = import ./a.nix; b = import ./b.nix; }`.
- [`lib.exportOverlays channels`](./lib/exportOverlays.nix) - Exports all overlays from channels as an appropriately namespaced attribute set. Users can instantiate with their nixpkgs version.
- [`lib.exportPackages self.overlays channels`](./lib/exportPackages.nix) - Similar to the overlay generator, but outputs them as packages for the platforms defined in `meta.platforms`. Unlike overlays, these packages are consistent across flakes allowing them to be cached.
- `pkgs.fup-repl` - Adds a kick-ass repl. Usage:
- `pkgs.fup-repl` - A package that adds a kick-ass repl. Usage:
- `$ repl` - Loads your system repl into scope as well as `pkgs` and `lib` from `nixpkgs` input.
- `$ repl /path/to/flake.nix` - Same as above only that it loads specified flake.

View File

@ -1,8 +1,8 @@
{ flakePath ? null, hostnamePath ? "/etc/hostname" }:
{ flakePath ? null, hostnamePath ? "/etc/hostname", registryPath ? /etc/nix/registry.json }:
let
inherit (builtins) getFlake head match currentSystem readFile pathExists filter fromJSON;
registryPath = /etc/nix/registry.json;
selfFlake =
if pathExists registryPath
then filter (it: it.from.id == "self") (fromJSON (readFile registryPath)).flakes
@ -16,7 +16,7 @@ let
else "/etc/nixos");
flake = if pathExists flakePath' then getFlake flakePath' else { };
hostname = if pathExists hostnamePath then head (match "([a-zA-Z0-9]+)\n" (readFile hostnamePath)) else "";
hostname = if pathExists hostnamePath then head (match "([a-zA-Z0-9\\-]+)\n" (readFile hostnamePath)) else "";
nixpkgsFromInputsPath = flake.inputs.nixpkgs.outPath or "";
nixpkgs = flake.pkgs.${currentSystem}.nixpkgs or (if nixpkgsFromInputsPath != "" then import nixpkgsFromInputsPath { } else { });
@ -29,4 +29,4 @@ in
// (flake.nixosConfigurations or { })
// flake.nixosConfigurations.${hostname} or { }
// nixpkgsOutput
// { loadFlake = path: getFlake (toString path); }
// { getFlake = path: getFlake (toString path); }