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