-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrepl.nix
More file actions
43 lines (41 loc) · 970 Bytes
/
repl.nix
File metadata and controls
43 lines (41 loc) · 970 Bytes
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
# better repl with preloaded functions and libs already loaded
# https://bmcgee.ie/posts/2023/01/nix-and-its-slow-feedback-loop/#how-you-should-use-the-repl
{
# host is passed down from the nrepl via a --arg argument, defaulting to the current host
host ? "desktop",
...
}:
let
user = "iynaix";
flake = builtins.getFlake (toString ./.);
inherit (flake.inputs.nixpkgs) lib;
in
(
flake.nixosConfigurations
|> lib.attrNames
|> lib.filter (n: !(lib.hasInfix "-" n))
|> map (
name:
let
cfg = flake.nixosConfigurations.${name}.config;
in
{
# utility variables for each host
"${name}" = cfg;
"${name}o" = cfg.custom;
}
)
|> lib.mergeAttrsList
)
// rec {
inherit lib;
inherit (flake) inputs;
inherit flake host user;
self = flake;
# default host
inherit (flake.nixosConfigurations.${host}) pkgs;
c = flake.nixosConfigurations.${host}.config;
config = c;
co = c.custom;
# your code here
}