improved automatic script alias creation and switched to lookup paths for nix-shell invocations
This commit is contained in:
parent
41a1a6a5f5
commit
209294075c
7 changed files with 21 additions and 10 deletions
|
@ -128,13 +128,26 @@ alias_dictionary = {
|
|||
"s": "sudo",
|
||||
}
|
||||
|
||||
# Create aliases for scripts with the .py extension stripped
|
||||
# Create aliases for scripts with the file extension stripped
|
||||
script_path = Path("/etc/nixos/scripts")
|
||||
if script_path.exists():
|
||||
for script in script_path.glob("*.py"):
|
||||
if script.name == "__init__.py":
|
||||
for sub_dir in script_path.iterdir():
|
||||
# ignore files within the nix subdirectory, since they are just nix-shell expressions
|
||||
# if you aren't using nix, you can remove this if statement
|
||||
if sub_dir.name == "nix":
|
||||
continue
|
||||
script_name = script.name.strip(".py")
|
||||
aliases.update({script_name: [str(script)]})
|
||||
if not sub_dir.is_dir():
|
||||
c = colors.Colors
|
||||
print(f"{c.YELLOW}{c.BOLD}WARNING: The path {c.PURPLE}'{sub_dir}'{c.YELLOW} is not a directory. Skipping alias creation for this path.{c.END}")
|
||||
continue
|
||||
|
||||
extension = f".{sub_dir.name}"
|
||||
|
||||
for script in sub_dir.glob(f"*{extension}"):
|
||||
if script.name == "__init__.py":
|
||||
continue
|
||||
|
||||
script_name = script.stem
|
||||
aliases[script_name] = [str(script)]
|
||||
|
||||
aliases.update(alias_dictionary)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
let
|
||||
nixpkgs = fetchTarball
|
||||
"https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz";
|
||||
pkgs = import nixpkgs {
|
||||
pkgs = import <nixpkgs> {
|
||||
config = { };
|
||||
overlays = [ ];
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell /etc/nixos/nixos/script-dependencies.nix -i python
|
||||
#! nix-shell /etc/nixos/scripts/nix/python.nix -i python
|
||||
|
||||
import argparse
|
||||
import os
|
|
@ -1,5 +1,5 @@
|
|||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell /etc/nixos/nixos/script-dependencies.nix -i python
|
||||
#! nix-shell /etc/nixos/scripts/nix/python.nix -i python
|
||||
|
||||
import argparse
|
||||
import mimetypes
|
Loading…
Reference in a new issue