Move Nix files back to the root of the project

This commit is contained in:
Oliver Davies 2025-03-29 23:19:06 +00:00
parent 52044d9995
commit 087153a16d
223 changed files with 12 additions and 12 deletions

13
pkgs/backup-websites.nix Normal file
View file

@ -0,0 +1,13 @@
{ lib, pkgs, ... }:
pkgs.writeShellApplication {
name = "backup-websites";
text = ''
backup_path="''${HOME}/server-backup"
mkdir -p "''${backup_path}"
${lib.getExe pkgs.rsync} -avzP ssh.oliverdavies.uk:/var/www/vhosts/ "''${backup_path}" --delete-after
'';
}

43
pkgs/build-glove80.nix Normal file
View file

@ -0,0 +1,43 @@
{ pkgs, ... }:
with pkgs;
writeShellApplication {
name = "build-glove80";
runtimeInputs = [
cachix
git
nix
];
text = ''
BRANCH="''${1:-main}"
SRC_DIR="''${PWD}/src"
CONFIG_DIR="''${PWD}/config"
NIX_FILE="''${CONFIG_DIR}/default.nix"
# Ensure cachix is configured
echo "Using moergo-glove80-zmk-dev cache"
cachix use moergo-glove80-zmk-dev
# Clone or update the ZMK repository
if [ ! -d "$SRC_DIR" ]; then
echo "Cloning ZMK repository into ./src..."
git clone https://github.com/moergo-sc/zmk "$SRC_DIR"
else
echo "Updating ZMK repository in ./src..."
git -C "$SRC_DIR" fetch --all
fi
# Checkout the specified branch or tag
echo "Checking out branch/tag: $BRANCH in ./src"
git -C "$SRC_DIR" checkout -q --detach "$BRANCH"
# Build firmware using Nix
echo "Building firmware from: $NIX_FILE"
nix-build "$NIX_FILE" --arg firmware "import ''${SRC_DIR}/default.nix {}" -j2 -o ./glove80.uf2 --show-trace
echo "Firmware built successfully: $(realpath ./glove80.uf2)"
'';
}

18
pkgs/default.nix Normal file
View file

@ -0,0 +1,18 @@
{ pkgs, prev, ... }:
let
inherit (pkgs) callPackage;
vimPlugins = callPackage ./vim-plugins { inherit callPackage; };
in
{
backup-websites = callPackage ./backup-websites.nix { };
build-glove80 = callPackage ./build-glove80.nix { };
displayselect = callPackage ./displayselect { };
notes = callPackage ./notes { };
passmenu-otp = callPackage ./passmenu-otp.nix { };
tmux-sessionizer = callPackage ./tmux-sessionizer { };
upload-to-files = callPackage ./upload-to-files.nix { };
vimPlugins = prev.vimPlugins // vimPlugins;
}

View file

@ -0,0 +1,30 @@
{ pkgs, ... }:
with pkgs;
stdenv.mkDerivation {
pname = "displayselect";
version = "0.1.0";
src = fetchFromGitHub {
owner = "lukesmithxyz";
repo = "voidrice";
rev = "master";
sha256 = "u4iy2p9i5ORLHcKmAOHVJNaKfYbt+SYUYKblgsRevN8=";
};
buildInputs = [
bash
xorg.xrandr
];
patches = [ ./scaling.patch ];
installPhase = ''
mkdir -p $out/bin
cp .local/bin/displayselect $out/bin
chmod +x $out/bin/displayselect
'';
meta.mainProgram = "displayselect";
}

View file

@ -0,0 +1,26 @@
diff --git a/.local/bin/displayselect b/.local/bin/displayselect
index 51dd468..c132b7a 100755
--- a/.local/bin/displayselect
+++ b/.local/bin/displayselect
@@ -15,20 +15,13 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
tail -n 1 | awk '{print $1}')
- res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
- tail -n 1 | awk '{print $1}')
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
- res_int_x=$(echo "$res_internal" | sed 's/x.*//')
- res_int_y=$(echo "$res_internal" | sed 's/.*x//')
-
- scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
- scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
xrandr --output "$external" --auto --scale 1.0x1.0 \
--output "$internal" --auto --same-as "$external" \
- --scale "$scale_x"x"$scale_y"
+ --scale-from "${res_ext_x}x${res_ext_y}"
else
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")

View file

@ -0,0 +1,13 @@
diff --git a/notes b/notes
index 3351903..34364bf 100755
--- a/notes
+++ b/notes
@@ -14,7 +14,7 @@ set -e
readonly NOTES_DIRECTORY="${NOTES_DIRECTORY:-${HOME}/notes}"
readonly NOTES_EDITOR="${EDITOR}"
-readonly NOTES_FILE="$(date +%Y-%m).txt"
+readonly NOTES_FILE="$(date +%Y-%m-%d).txt"
readonly NOTES_PATH="${NOTES_DIRECTORY}/${NOTES_FILE}"
if [ ! -d "${NOTES_DIRECTORY}" ]; then

27
pkgs/notes/default.nix Normal file
View file

@ -0,0 +1,27 @@
{ pkgs, ... }:
with pkgs;
stdenv.mkDerivation rec {
pname = "notes";
version = "0.3.0";
src = fetchFromGitHub {
owner = "nickjj";
repo = "notes";
rev = "v${version}";
sha256 = "gyrsTWPT8w4DsRim3jlbjvpXwX/y+7SwLaM+3LVOJdU=";
};
buildInputs = [ bash ];
patches = [
./create-daily-notes.patch
];
installPhase = ''
mkdir -p $out/bin
cp notes $out/bin/notes
chmod +x $out/bin/notes
'';
}

30
pkgs/passmenu-otp.nix Normal file
View file

@ -0,0 +1,30 @@
{ pkgs, ... }:
with pkgs;
stdenv.mkDerivation {
pname = "passmenu-otp";
version = "0.1.0";
src = fetchFromGitHub {
owner = "petrmanek";
repo = "passmenu-otp";
rev = "master";
sha256 = "sha256-2EGomeK/p3uVfgho5xGR11ovJQ2q3cPZoFG+z88DyxA=";
};
buildInputs = [
pass
];
installPhase = ''
mkdir -p $out/bin
cp passmenu-otp $out/bin/passmenu-otp
chmod +x $out/bin/passmenu-otp
'';
meta = {
homepage = "https://github.com/petrmanek/passmenu-otp";
mainProgram = "passmenu-otp";
};
}

View file

@ -0,0 +1,15 @@
diff --git a/tmux-sessionizer b/tmux-sessionizer
index fa1bec5..c9094e7 100755
--- a/tmux-sessionizer
+++ b/tmux-sessionizer
@@ -12,7 +12,9 @@ has_session() {
}
hydrate() {
- if [ -f $2/.tmux-sessionizer ]; then
+ if [ -f $2/.tmux ]; then
+ tmux send-keys -t $1 "source $2/.tmux" c-M
+ elif [ -f $2/.tmux-sessionizer ]; then
tmux send-keys -t $1 "source $2/.tmux-sessionizer" c-M
elif [ -f $HOME/.tmux-sessionizer ]; then
tmux send-keys -t $1 "source $HOME/.tmux-sessionizer" c-M

View file

@ -0,0 +1,15 @@
diff --git a/tmux-sessionizer b/tmux-sessionizer
index fa1bec5..4d79e0b 100755
--- a/tmux-sessionizer
+++ b/tmux-sessionizer
@@ -22,9 +22,7 @@ hydrate() {
if [[ $# -eq 1 ]]; then
selected=$1
else
- # If someone wants to make this extensible, i'll accept
- # PR
- selected=$(find ~/ ~/personal ~/personal/dev/env/.config -mindepth 1 -maxdepth 1 -type d | fzf)
+ selected=$(find -L ~/Code ~/Code/os ~/Documents -maxdepth 1 -type d ! -name ".*" ! -name ".old" ! -name "_archive" | sort | fzf)
fi
if [[ -z $selected ]]; then

View file

@ -0,0 +1,33 @@
{ pkgs, ... }:
with pkgs;
stdenv.mkDerivation {
pname = "tmux-sessionizer";
version = "0.1.0";
src = fetchFromGitHub {
owner = "theprimeagen";
repo = "tmux-sessionizer";
rev = "master";
sha256 = "bZXt9TyMU1Ed/WR0/ahMQ4oyIi6yXLKnXKYPPNBt/s4=";
};
buildInputs = [
bash
fzf
tmux
];
patches = [
./move-default-script.patch
./add-tmux-file.patch
./configure-directories.patch
];
installPhase = ''
mkdir -p $out/bin
cp tmux-sessionizer $out/bin/tmux-sessionizer
chmod +x $out/bin/tmux-sessionizer
'';
}

View file

@ -0,0 +1,15 @@
diff --git a/tmux-sessionizer b/tmux-sessionizer
index fa1bec5..536d4b0 100755
--- a/tmux-sessionizer
+++ b/tmux-sessionizer
@@ -14,8 +14,8 @@ has_session() {
hydrate() {
if [ -f $2/.tmux-sessionizer ]; then
tmux send-keys -t $1 "source $2/.tmux-sessionizer" c-M
- elif [ -f $HOME/.tmux-sessionizer ]; then
- tmux send-keys -t $1 "source $HOME/.tmux-sessionizer" c-M
+ elif [ -f "$XDG_CONFIG_HOME/tmux-sessionizer/default" ]; then
+ tmux send-keys -t $1 "source $XDG_CONFIG_HOME/tmux-sessionizer/default" c-M
fi
}

11
pkgs/upload-to-files.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs }:
with pkgs;
writeShellApplication {
name = "upload-to-files";
text = ''
${pkgs.rsync}/bin/rsync -avz --info=progress2 "$1" ssh.oliverdavies.uk:/var/www/vhosts/files.oliverdavies.uk
'';
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
with pkgs;
vimUtils.buildVimPlugin {
name = "conf-vim";
src = fetchFromGitHub {
owner = "tjdevries";
repo = "conf.vim";
rev = "master";
sha256 = "AjiTJsoim0BAnyfqk1IQzNsa6jhFM2+A66E7q9sJqz0=";
};
}

View file

@ -0,0 +1,10 @@
{ callPackage }:
{
conf-vim = callPackage ./conf-vim.nix { };
edit-alternate-vim = callPackage ./edit-alternate-vim.nix { };
standard-vim = callPackage ./standard-vim.nix { };
vim-caser = callPackage ./vim-caser.nix { };
vim-textobj-indent = callPackage ./vim-textobj-indent.nix { };
vim-textobj-xmlattr = callPackage ./vim-textobj-xmlattr.nix { };
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
with pkgs;
vimUtils.buildVimPlugin {
name = "edit-alternate-vim";
src = fetchFromGitHub {
owner = "tjdevries";
repo = "edit_alternate.vim";
rev = "master";
sha256 = "mEKnqYAhgrdxPRoKf4S4yYecdFIHGg8bDxpqPuC1+S4=";
};
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
with pkgs;
vimUtils.buildVimPlugin {
name = "standard-vim";
src = fetchFromGitHub {
owner = "tjdevries";
repo = "standard.vim";
rev = "master";
sha256 = "9VwkvV1Dv6cE4uDkPp36DozjWJOclDR883yDMYw000E=";
};
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
with pkgs;
vimUtils.buildVimPlugin {
name = "vim-caser";
src = fetchFromGitHub {
owner = "arthurxavierx";
repo = "vim-caser";
rev = "6bc9f41d170711c58e0157d882a5fe8c30f34bf6";
sha256 = "PXAY01O/cHvAdWx3V/pyWFeiV5qJGvLcAKhl5DQc0Ps=";
};
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
with pkgs;
vimUtils.buildVimPlugin {
name = "vim-textobj-indent";
src = fetchFromGitHub {
owner = "kana";
repo = "vim-textobj-indent";
rev = "deb76867c302f933c8f21753806cbf2d8461b548";
sha256 = "oFzUPG+IOkbKZ2gU/kduQ3G/LsLDlEjFhRP0BHBE+1Q=";
};
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
with pkgs;
vimUtils.buildVimPlugin {
name = "vim-textobj-xmlattr";
src = fetchFromGitHub {
owner = "whatyouhide";
repo = "vim-textobj-xmlattr";
rev = "694a297f1d75fd527e87da9769f3c6519a87ebb1";
sha256 = "+91FVP95oh00flINdltqx6qJuijYo56tHIh3J098G2Q=";
};
}