feat: add editsym function that transforms a readonly nix symlink into an editable file

This commit is contained in:
Nydragon 2024-08-26 16:47:06 +02:00
parent 49b7f591fe
commit 16140c81a8
Signed by: nydragon
SSH key fingerprint: SHA256:iQnIC12spf4QjWSbarmkD2No1cLMlu6TWoV7K6cYF5g
4 changed files with 40 additions and 7 deletions

View file

@ -4,8 +4,8 @@
config,
...
}:
let
inherit (pkgs.writers) writeFishBin writeBashBin;
nixos-rebuild =
name: word:
pkgs.writers.writeBashBin name ''
@ -35,7 +35,7 @@ in
'';
};
set-background = pkgs.writers.writeFishBin "set-background" ''
set-background = writeFishBin "set-background" ''
argparse 'f/file=!test -e "$_flag_value"' -- $argv; or return
set pids $(pidof swaybg)
@ -54,11 +54,11 @@ in
end
'';
nixedit = pkgs.writers.writeFishBin "nixedit" "env --chdir ~/.nixconf $EDITOR .";
nixedit = writeFishBin "nixedit" "env --chdir ~/.nixconf $EDITOR .";
getext = pkgs.writeScriptBin "ls | grep -E \"\.[a-zA-Z0-9]+$\" --only-matching | sort | uniq";
rpaste = pkgs.writers.writeBashBin "rpaste" ''
rpaste = writeBashBin "rpaste" ''
export $(cat ${config.age.secrets.rustypaste.path} | xargs)
curl -F "file=@$1" -H "Authorization: $AUTH_TOKEN" https://rusty.ccnlc.eu/
'';
@ -67,13 +67,22 @@ in
genswitch = nixos-rebuild "genswitch" "switch";
fishl = pkgs.writers.writeFishBin "fishl" ./logo.fish;
fishl = writeFishBin "fishl" ./logo.fish;
nrun = pkgs.writers.writeFishBin "nrun" ''
nrun = writeFishBin "nrun" ''
if echo $argv[1] | grep -Eq '^(github):.+/.+$'
nix run $argv[1] -- $argv[2..]
else
nix run nixpkgs#$argv[1] -- $argv[2..]
end
'';
editsym = writeFishBin "editsym" ''
for file in $argv
cp "$file" "$file.tmp"
unlink "$file"
mv "$file.tmp" "$file"
chmod -R 777 "$file"
end
'';
}

View file

@ -78,7 +78,7 @@
scripts.rpaste
scripts.genswitch
scripts.gentest
scripts.editsym
];
};
};

View file

@ -78,6 +78,7 @@
scripts.nrun
scripts.genswitch
scripts.gentest
scripts.editsym
];
};
};

23
modules/portals.nix Normal file
View file

@ -0,0 +1,23 @@
{
lib,
config,
pkgs,
...
}:
lib.mkIf config.xdg.portal.enabme {
xdg.portal = {
config = {
sway = {
"org.freedesktop.impl.portal.Screenshot.PickColor" = [ "hyprpicker" ];
};
common.default = "*";
};
# gtk portal needed to make gtk apps happy
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
];
};
}