Compare commits
No commits in common. "de0e43ef6a0c50e959be9ef6bea3ea323c0cc929" and "23ccfed77e48e721c99e0e67dc18cda5f062a46c" have entirely different histories.
de0e43ef6a
...
23ccfed77e
9 changed files with 37 additions and 246 deletions
|
@ -35,7 +35,6 @@
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
system = system;
|
system = system;
|
||||||
hostname = "eclipse";
|
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
# imports
|
# imports
|
||||||
|
@ -50,9 +49,9 @@
|
||||||
./nixos/nvidia.nix
|
./nixos/nvidia.nix
|
||||||
./nixos/nvim.nix
|
./nixos/nvim.nix
|
||||||
./nixos/pkg.nix
|
./nixos/pkg.nix
|
||||||
./nixos/shell.nix
|
|
||||||
./nixos/sudo.nix
|
./nixos/sudo.nix
|
||||||
./nixos/tailscale.nix
|
./nixos/tailscale.nix
|
||||||
|
./nixos/zsh.nix
|
||||||
|
|
||||||
{
|
{
|
||||||
# enable bluetooth
|
# enable bluetooth
|
||||||
|
@ -82,7 +81,6 @@
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
system = system;
|
system = system;
|
||||||
hostname = "eclipse";
|
|
||||||
};
|
};
|
||||||
users.cswimr = {
|
users.cswimr = {
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
".config/fastfetch/config.jsonc".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/fastfetch.jsonc";
|
".config/fastfetch/config.jsonc".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/fastfetch.jsonc";
|
||||||
};
|
};
|
||||||
|
|
||||||
home.sessionPath = [
|
|
||||||
"/etc/nixos/scripts"
|
|
||||||
];
|
|
||||||
|
|
||||||
# link the configuration file in current directory to the specified location in home directory
|
# link the configuration file in current directory to the specified location in home directory
|
||||||
# home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg;
|
# home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg;
|
||||||
|
|
||||||
|
@ -59,7 +55,6 @@
|
||||||
insteadOf = [ "https://github.com/" "gh:" "github:" ];
|
insteadOf = [ "https://github.com/" "gh:" "github:" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
hub.protocol = "ssh";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
ms-python.vscode-pylance
|
ms-python.vscode-pylance
|
||||||
ms-python.debugpy
|
ms-python.debugpy
|
||||||
ms-python.black-formatter
|
ms-python.black-formatter
|
||||||
|
ms-python.isort
|
||||||
|
ms-python.flake8
|
||||||
charliermarsh.ruff
|
charliermarsh.ruff
|
||||||
matangover.mypy
|
matangover.mypy
|
||||||
|
|
||||||
|
@ -61,9 +63,6 @@
|
||||||
gregorbiswanger.json2ts
|
gregorbiswanger.json2ts
|
||||||
vendicated.vencord-companion
|
vendicated.vencord-companion
|
||||||
|
|
||||||
# Lua
|
|
||||||
sumneko.lua
|
|
||||||
|
|
||||||
# Luau
|
# Luau
|
||||||
evaera.vscode-rojo
|
evaera.vscode-rojo
|
||||||
undermywheel.roblox-lua
|
undermywheel.roblox-lua
|
||||||
|
@ -128,7 +127,6 @@
|
||||||
# Misc - Linters
|
# Misc - Linters
|
||||||
tekumara.typos-vscode
|
tekumara.typos-vscode
|
||||||
stylelint.vscode-stylelint
|
stylelint.vscode-stylelint
|
||||||
davidanson.vscode-markdownlint
|
|
||||||
|
|
||||||
# Misc - Formatters
|
# Misc - Formatters
|
||||||
esbenp.prettier-vscode
|
esbenp.prettier-vscode
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Edit this configuration file to define what should be installed on
|
# Edit this configuration file to define what should be installed on
|
||||||
# your system. Help is available in the configuration.nix(5) man page
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
{ pkgs, hostname, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
nix = {
|
nix = {
|
||||||
settings = {
|
settings = {
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
networking.hostName = hostname; # Define your hostname.
|
networking.hostName = "eclipse"; # Define your hostname.
|
||||||
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
|
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
|
||||||
|
|
||||||
# Configure network proxy if necessary
|
# Configure network proxy if necessary
|
||||||
|
@ -45,6 +45,19 @@
|
||||||
LC_TIME = "en_US.UTF-8";
|
LC_TIME = "en_US.UTF-8";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Enable the X11 windowing system.
|
||||||
|
# You can disable this if you're only using the Wayland session.
|
||||||
|
services.xserver.enable = false;
|
||||||
|
|
||||||
|
# Enable the SDDM Display Manager and enable its Wayland support.
|
||||||
|
services.displayManager.sddm = {
|
||||||
|
enable = true;
|
||||||
|
wayland.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable the KDE Plasma Desktop Environment.
|
||||||
|
services.desktopManager.plasma6.enable = true;
|
||||||
|
|
||||||
# Configure keymap in X11
|
# Configure keymap in X11
|
||||||
services.xserver.xkb = {
|
services.xserver.xkb = {
|
||||||
layout = "us";
|
layout = "us";
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
|
|
||||||
# XDG settings
|
# XDG settings
|
||||||
XDG_CONFIG_HOME = lib.mkDefault "$HOME/.config";
|
XDG_CONFIG_HOME = lib.mkDefault "$HOME/.config";
|
||||||
|
|
||||||
# less settings
|
|
||||||
LESS = "-R";
|
|
||||||
# Fix unicode characters not being displayed properly in less or cat (bat)
|
|
||||||
# https://github.com/sharkdp/bat/issues/2578#issuecomment-1598332705
|
|
||||||
LESSUTFCHARDEF = "E000-F8FF:p,F0000-FFFFD:p,100000-10FFFD:p";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.sessionVariables = {
|
environment.sessionVariables = {
|
||||||
|
|
|
@ -10,26 +10,12 @@ let
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
# we install xdg-desktop-portal-gtk so GTK theming works in KDE Plasma
|
# we install xdg-desktop-portal-gtk so GTK theming works in KDE Plasma
|
||||||
xdg-desktop-portal-gtk
|
xdg-desktop-portal-gtk
|
||||||
libnotify
|
|
||||||
];
|
];
|
||||||
flakePackages = with inputs; [ zen-browser.packages.${system}.specific ];
|
flakePackages = with inputs; [ zen-browser.packages.${system}.specific ];
|
||||||
in {
|
in {
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
lib.lists.unique (kdePackages ++ packages ++ flakePackages);
|
lib.lists.unique (kdePackages ++ packages ++ flakePackages);
|
||||||
|
|
||||||
# Enable the X11 windowing system.
|
|
||||||
# You can leave this disabled if you're only using the Wayland session.
|
|
||||||
services.xserver.enable = false;
|
|
||||||
|
|
||||||
# Enable the SDDM Display Manager and enable its Wayland support.
|
|
||||||
services.displayManager.sddm = {
|
|
||||||
enable = true;
|
|
||||||
wayland.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Enable the KDE Plasma Desktop Environment.
|
|
||||||
services.desktopManager.plasma6.enable = true;
|
|
||||||
|
|
||||||
programs.partition-manager.enable = true;
|
programs.partition-manager.enable = true;
|
||||||
|
|
||||||
fonts.packages = with pkgs; [
|
fonts.packages = with pkgs; [
|
||||||
|
|
|
@ -6,7 +6,6 @@ let
|
||||||
wget
|
wget
|
||||||
curl
|
curl
|
||||||
git
|
git
|
||||||
hub
|
|
||||||
(nnn.override { withNerdIcons = true; })
|
(nnn.override { withNerdIcons = true; })
|
||||||
fzf
|
fzf
|
||||||
ripgrep
|
ripgrep
|
||||||
|
@ -14,7 +13,6 @@ let
|
||||||
zip
|
zip
|
||||||
xz
|
xz
|
||||||
unzip
|
unzip
|
||||||
p7zip
|
|
||||||
jq
|
jq
|
||||||
yq-go
|
yq-go
|
||||||
eza
|
eza
|
||||||
|
@ -39,16 +37,19 @@ let
|
||||||
lazydocker
|
lazydocker
|
||||||
bat
|
bat
|
||||||
nixfmt
|
nixfmt
|
||||||
zenity
|
|
||||||
forgejo-runner # for some reason this installs forgejo-runner as act_runner
|
forgejo-runner # for some reason this installs forgejo-runner as act_runner
|
||||||
libwebp
|
libwebp
|
||||||
fontforge
|
fontforge
|
||||||
packwiz
|
|
||||||
|
|
||||||
# for scripts
|
# python stuff 🐍
|
||||||
|
uv
|
||||||
|
python313
|
||||||
python312
|
python312
|
||||||
python312Packages.requests
|
python311
|
||||||
python312Packages.tkinter
|
|
||||||
|
# javascript stuff 🤮
|
||||||
|
nodejs
|
||||||
|
corepack
|
||||||
];
|
];
|
||||||
flakePackages = with inputs; [ compose2nix.packages.${system}.default ];
|
flakePackages = with inputs; [ compose2nix.packages.${system}.default ];
|
||||||
in {
|
in {
|
||||||
|
|
|
@ -57,14 +57,21 @@
|
||||||
add_newline = false;
|
add_newline = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
users.defaultUserShell = pkgs.fish;
|
users.defaultUserShell = pkgs.zsh;
|
||||||
programs.fish = {
|
programs.zsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
enableCompletion = true;
|
||||||
|
enableBashCompletion = true;
|
||||||
|
autosuggestions.enable = true;
|
||||||
|
syntaxHighlighting.enable = true;
|
||||||
shellInit = ''
|
shellInit = ''
|
||||||
export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
|
export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
shellAliases = let ezaArgs = "--time-style='+%Y-%m-%d %H:%M' --icons=auto";
|
histSize = 10000;
|
||||||
|
histFile = "$HOME/.zsh_history";
|
||||||
|
|
||||||
|
shellAliases = let ezaArgs = "--time-style='+%Y-%m-%d %H:%M' --icons";
|
||||||
in {
|
in {
|
||||||
ff = "fastfetch";
|
ff = "fastfetch";
|
||||||
neofetch = "fastfetch";
|
neofetch = "fastfetch";
|
||||||
|
@ -83,15 +90,12 @@
|
||||||
ls = "eza ${ezaArgs}";
|
ls = "eza ${ezaArgs}";
|
||||||
lsa = "eza -lah ${ezaArgs}";
|
lsa = "eza -lah ${ezaArgs}";
|
||||||
tree = "eza --tree --git-ignore ${ezaArgs}";
|
tree = "eza --tree --git-ignore ${ezaArgs}";
|
||||||
git = "hub";
|
|
||||||
|
|
||||||
create-devenv = "nix flake init --template github:cachix/devenv && direnv allow";
|
create-devenv = "nix flake init --template github:cachix/devenv && direnv allow";
|
||||||
develop = "nix develop --no-pure-eval";
|
develop = "nix develop --no-pure-eval";
|
||||||
nixpkgs-update = "nix run --option extra-substituters 'https://nix-community.cachix.org/' --option extra-trusted-public-keys 'nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=' github:ryantm/nixpkgs-update --";
|
|
||||||
nixrc = "$EDITOR /etc/nixos";
|
nixrc = "$EDITOR /etc/nixos";
|
||||||
delete-vscode-settings-backup = "rm -rf ~/.config/Code/User/settings.json.bak";
|
|
||||||
upd =
|
upd =
|
||||||
"sudo nixos-generate-config --dir /etc/nixos/hosts && sudo rm /etc/nixos/hosts/configuration.nix && sudo mv /etc/nixos/hosts/hardware-configuration.nix /etc/nixos/hosts/$(hostname).nix && git -C /etc/nixos --git-dir=/etc/nixos/.git add /etc/nixos/hosts/$(hostname).nix && delete-vscode-settings-backup && sudo nixos-rebuild switch --flake /etc/nixos";
|
"sudo nixos-generate-config --dir /etc/nixos/hosts && sudo rm /etc/nixos/hosts/configuration.nix && sudo mv /etc/nixos/hosts/hardware-configuration.nix /etc/nixos/hosts/$(hostname).nix && git -C /etc/nixos --git-dir=/etc/nixos/.git add /etc/nixos/hosts/$(hostname).nix && sudo nixos-rebuild switch";
|
||||||
|
|
||||||
taildrop = "tailscale file";
|
taildrop = "tailscale file";
|
||||||
|
|
198
scripts/zipline
198
scripts/zipline
|
@ -1,198 +0,0 @@
|
||||||
#! /usr/bin/env nix-shell
|
|
||||||
#! nix-shell -i python3 -p python312 python312Packages.tkinter python312Packages.requests libnotify
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import mimetypes
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
from pathlib import Path
|
|
||||||
from shutil import which
|
|
||||||
from tkinter import Tk
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
import requests # type: ignore
|
|
||||||
|
|
||||||
|
|
||||||
def read_secret_file(secret: str) -> str:
|
|
||||||
with open(f"/run/secrets/{secret}", "r") as f:
|
|
||||||
return f.read().strip()
|
|
||||||
|
|
||||||
|
|
||||||
def does_desktop_entry_exist(desktop_entry: str) -> bool:
|
|
||||||
if not desktop_entry:
|
|
||||||
raise ValueError("Please provide the full filename of the desktop entry.")
|
|
||||||
|
|
||||||
if not desktop_entry.endswith(".desktop"):
|
|
||||||
desktop_entry += ".desktop"
|
|
||||||
|
|
||||||
entry_paths = []
|
|
||||||
|
|
||||||
# Check if qtpaths is available
|
|
||||||
if which("qtpaths"):
|
|
||||||
result = subprocess.run(
|
|
||||||
["qtpaths", "--paths", "ApplicationsLocation"],
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
entry_paths = result.stdout.strip().split(":")
|
|
||||||
else:
|
|
||||||
print("qtpaths is not installed, falling back to XDG_DATA_DIRS.")
|
|
||||||
xdg_data_dirs = os.getenv("XDG_DATA_DIRS", "/usr/share:/usr/local/share").split(
|
|
||||||
":"
|
|
||||||
)
|
|
||||||
entry_paths = [os.path.join(path, "applications") for path in xdg_data_dirs]
|
|
||||||
entry_paths.append(os.path.expanduser("~/.local/share/applications"))
|
|
||||||
|
|
||||||
print(f"Checking the following paths for {desktop_entry}:\n{entry_paths}\n{'-'*20}")
|
|
||||||
|
|
||||||
# Search for the desktop entry file
|
|
||||||
for entry_path in entry_paths:
|
|
||||||
entry_file = Path(entry_path) / f"{desktop_entry}"
|
|
||||||
print(f"Checking for {entry_file}")
|
|
||||||
if entry_file.is_file():
|
|
||||||
print(f"{desktop_entry} found in {entry_path}")
|
|
||||||
return True
|
|
||||||
|
|
||||||
print(f"Desktop entry {desktop_entry} does not exist.")
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def copy_to_clipboard(text: str) -> None:
|
|
||||||
root = Tk()
|
|
||||||
root.withdraw()
|
|
||||||
root.clipboard_clear()
|
|
||||||
root.clipboard_append(text)
|
|
||||||
root.update()
|
|
||||||
root.destroy()
|
|
||||||
|
|
||||||
|
|
||||||
def notify(
|
|
||||||
application_name: str,
|
|
||||||
title: str,
|
|
||||||
message: str,
|
|
||||||
urgency: str = "low",
|
|
||||||
category: str | None = None,
|
|
||||||
icon: Path | None = None,
|
|
||||||
desktop_entry: str | None = None,
|
|
||||||
) -> None:
|
|
||||||
args = ["notify-send" "-a", application_name, "-u", urgency]
|
|
||||||
if category:
|
|
||||||
args.append("-c")
|
|
||||||
args.append(category)
|
|
||||||
if icon:
|
|
||||||
args.append("-i")
|
|
||||||
args.append(str(icon))
|
|
||||||
if desktop_entry:
|
|
||||||
args.append("-h")
|
|
||||||
args.append(f"string:desktop-entry:{desktop_entry}")
|
|
||||||
args.append(title)
|
|
||||||
args.append(message)
|
|
||||||
subprocess.run(args)
|
|
||||||
|
|
||||||
|
|
||||||
def zipline(
|
|
||||||
file_path: Path,
|
|
||||||
instance_url: str,
|
|
||||||
application_name: str = None,
|
|
||||||
desktop_entry: str = None,
|
|
||||||
) -> Any:
|
|
||||||
token = read_secret_file("zipline")
|
|
||||||
if not token:
|
|
||||||
print("Secret file at /run/secrets/zipline either does not exist or is empty.")
|
|
||||||
raise FileNotFoundError(
|
|
||||||
"Secret file at /run/secrets/zipline either does not exist or is empty."
|
|
||||||
)
|
|
||||||
|
|
||||||
if not os.path.isfile(file_path):
|
|
||||||
print(f"File at {file_path} does not exist.")
|
|
||||||
raise FileNotFoundError(f"File at {file_path} does not exist.")
|
|
||||||
|
|
||||||
use_send_notify = False
|
|
||||||
if application_name and desktop_entry:
|
|
||||||
if not does_desktop_entry_exist(desktop_entry=desktop_entry):
|
|
||||||
print("Desktop entry does not exist.")
|
|
||||||
raise FileNotFoundError("Desktop entry does not exist.")
|
|
||||||
|
|
||||||
if not which("notify-send"):
|
|
||||||
print("notify-send is not installed.")
|
|
||||||
raise FileNotFoundError("notify-send is not installed.")
|
|
||||||
|
|
||||||
use_send_notify = True
|
|
||||||
|
|
||||||
content_type = mimetypes.guess_type(file_path)[0] or "application/octet-stream"
|
|
||||||
|
|
||||||
try:
|
|
||||||
headers = {"authorization": token}
|
|
||||||
files = {
|
|
||||||
"file": (os.path.basename(file_path), open(file_path, "rb"), content_type)
|
|
||||||
}
|
|
||||||
response = requests.post(
|
|
||||||
f"{instance_url.rstrip('/')}/api/upload", headers=headers, files=files
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.status_code == 200:
|
|
||||||
response_data = response.json()
|
|
||||||
link = response_data.get("files", [None])[0]
|
|
||||||
|
|
||||||
if link:
|
|
||||||
copy_to_clipboard(text=link)
|
|
||||||
|
|
||||||
if use_send_notify:
|
|
||||||
notify(
|
|
||||||
application_name=application_name,
|
|
||||||
title="Upload Successful",
|
|
||||||
message=f"Link copied to clipboard: {link}",
|
|
||||||
urgency="low",
|
|
||||||
category="transfer.complete",
|
|
||||||
icon=file_path,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
raise ValueError("Invalid response format.")
|
|
||||||
else:
|
|
||||||
error_message = response.text
|
|
||||||
raise Exception(error_message)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
if use_send_notify:
|
|
||||||
notify(
|
|
||||||
application_name=application_name,
|
|
||||||
title="Upload Failed",
|
|
||||||
message=f"An error occurred: {e}",
|
|
||||||
urgency="critical",
|
|
||||||
category="transfer.error",
|
|
||||||
icon=file_path,
|
|
||||||
)
|
|
||||||
raise e
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
prog="zipline",
|
|
||||||
description="Upload a file to a Zipline instance.",
|
|
||||||
epilog="Example usage: zipline /path/to/file.txt",
|
|
||||||
)
|
|
||||||
parser.add_argument("file", help="The file to upload.")
|
|
||||||
parser.add_argument(
|
|
||||||
"--url",
|
|
||||||
help="The URL of the Zipline instance. Defaults to 'https://csw.im'.",
|
|
||||||
default="https://csw.im",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--application-name",
|
|
||||||
help="The name of the application that is uploading the file. Defaults to 'Zipline'.",
|
|
||||||
default="Zipline",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--desktop-entry",
|
|
||||||
help="The desktop entry file for the application that is uploading the file. If this is provided, send-notify will be invoked to display a notification if the upload succeeds or fails.",
|
|
||||||
default=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
zipline(
|
|
||||||
file_path=args.file,
|
|
||||||
instance_url=args.url,
|
|
||||||
application_name=args.application_name,
|
|
||||||
desktop_entry=args.desktop_entry,
|
|
||||||
)
|
|
Loading…
Reference in a new issue