refactor: small changes

dev-docs
Moritz Böhme 2023-09-10 15:07:55 +02:00
parent 749e2cf67d
commit 372ee5985a
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
4 changed files with 86 additions and 54 deletions

View File

@ -34,17 +34,29 @@ let
which-nix = pkgs.writeFishApplication {
name = "which-nix";
runtimeInputs = with pkgs; [ which coreutils-full ];
runtimeInputs = with pkgs; [ which coreutils-full procps ];
text = /* fish */ ''
readlink -f (which $argv)
function recurse -a path;
if not test -f "$path"
return
end
echo $path
if test -L $path
recurse (readlink $path)
end
end
for arg in $argv
recurse (which $arg)
end
'';
completions = /* fish */ ''
complete -c which-nix -fa '(__fish_complete_command)'
'';
};
gi = pkgs.writeFishApplication
{
gi = pkgs.writeFishApplication {
name = "gi";
runtimeInputs = with pkgs; [ fzf gum curl ];
text = /* fish */ ''

View File

@ -8,9 +8,12 @@ with lib;
let
cfg = config.my.programs.fish;
shellConfig = config.my.shell;
exportedVariables =
let
exportVariables =
lib.mapAttrsToList (n: v: ''set -x ${n} "${v}"'') shellConfig.variables;
exportedVariables = lib.concatStringsSep "\n" exportVariables;
in
lib.concatStringsSep "\n" exportVariables;
in
{
options.my.programs.fish.enable = mkEnableOption "fish";

View File

@ -17,7 +17,7 @@ in
gateway = "vpn.uni-leipzig.de";
protocol = "anyconnect";
user = "mb18cele@uni-leipzig.de";
# NOTE file content as follows:
# NOTE: file content as follows:
# <my_password>
# "1-Standard-Uni" or "2-Spezial-Alles"
# Explanation:

View File

@ -2,16 +2,14 @@ _:
final: _:
with final.lib;
{
writeFishApplication =
rec {
fishFile =
{ name
, text
, completions ? null
, runtimeInputs ? [ ]
, destination
, content
, checkPhase ? null
}:
let
fishFile = destination: content: final.writeTextFile {
final.writeTextFile {
inherit name destination;
executable = true;
allowSubstitutes = true;
@ -19,8 +17,6 @@ with final.lib;
text = ''
#!${getExe final.fish}
${optionalString (runtimeInputs != [ ]) ''export PATH="${makeBinPath runtimeInputs}:$PATH"''}
${content}
'';
@ -33,8 +29,29 @@ with final.lib;
else checkPhase;
};
script = fishFile "/bin/${name}" text;
completions_file = fishFile "/share/fish/vendor_completions.d/${name}.fish" completions;
writeFishApplication =
{ name
, text
, completions ? null
, runtimeInputs ? [ ]
, checkPhase ? null
}:
let
runtimeHeader = optionalString (runtimeInputs != [ ])
''export PATH="${makeBinPath runtimeInputs}:$PATH"'';
script = fishFile {
inherit checkPhase;
name = "${name}_script";
destination = "/bin/${name}";
content = concatLines [ runtimeHeader text ];
};
completions_file = fishFile {
inherit checkPhase;
name = "${name}_completions";
destination = "/share/fish/vendor_completions.d/${name}.fish";
content = concatLines [ runtimeHeader completions ];
};
in
final.symlinkJoin {
inherit name;