feat(porgrams): add nix-edit
This commit is contained in:
parent
57f2094c44
commit
888b3246a7
3 changed files with 42 additions and 0 deletions
|
@ -33,6 +33,7 @@ in
|
|||
gpg.enable = mkDefault true;
|
||||
hyprland.enable = mkDefault true;
|
||||
logseq.enable = mkDefault true;
|
||||
nix-edit.enable = mkDefault true;
|
||||
nvim.enable = mkDefault true;
|
||||
python.versions."311".enable = mkDefault true;
|
||||
spotify.enable = mkDefault true;
|
||||
|
|
26
modules/programs/nix-edit/default.nix
Normal file
26
modules/programs/nix-edit/default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ lib
|
||||
, config
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.my.programs.nix-edit;
|
||||
in
|
||||
{
|
||||
options.my.programs.nix-edit.enable = mkEnableOption "nix-edit";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages =
|
||||
let
|
||||
nix-edit = pkgs.writeShellApplication {
|
||||
name = "nix-edit";
|
||||
runtimeInputs = with pkgs; [ nix gnugrep ];
|
||||
text = builtins.readFile ./nix-edit.sh;
|
||||
};
|
||||
in
|
||||
[ nix-edit ];
|
||||
};
|
||||
|
||||
}
|
15
modules/programs/nix-edit/nix-edit.sh
Executable file
15
modules/programs/nix-edit/nix-edit.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
input=$(
|
||||
echo ":lf nixpkgs"
|
||||
echo "pkgs = legacyPackages.\${builtins.currentSystem}"
|
||||
echo ":doc $1"
|
||||
echo ":e $1"
|
||||
)
|
||||
echo "$input" | nix repl --quiet 2> >(grep -v "ioctl" |
|
||||
grep -v "^error: value does not have documentation$" |
|
||||
grep -vP "error: .* has no source location information" |
|
||||
grep -vP "Welcome to Nix \d+\.\d+\.\d+\." |
|
||||
grep -vP "Added \d+ variables." |
|
||||
grep -v -e '^[[:space:]]*$'
|
||||
)
|
Loading…
Reference in a new issue