diff --git a/home/packages.nix b/home/packages.nix index fa1e2cd..39c4f14 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -7,17 +7,18 @@ with pkgs; [ # System tools dmenu + networkmanager_dmenu - dmenu-custom-scripts - custom-update-system - custom-push-etckeeper - custom-backup + (callPackage ./packages/custom/dmenu-scripts { }) + (callPackage ./packages/custom/update-system { }) + (callPackage ./packages/custom/push-etckeeper { }) + (callPackage ./packages/custom/backup { }) dunst i3blocks st ncdu tree - rst2pdf + (callPackage ./packages/rst2pdf { }) espeak bc @@ -52,7 +53,7 @@ with pkgs; [ # Use in conjuncion with https://github.com/autozimu/LanguageClient-neovim # rnix-lsp - custom-customer-project + (callPackage ./packages/custom/customer-project { }) # Communication signal-desktop diff --git a/overlays/composer1/composer.nix b/home/packages/composer1/composer.nix similarity index 100% rename from overlays/composer1/composer.nix rename to home/packages/composer1/composer.nix diff --git a/overlays/composer1/default.nix b/home/packages/composer1/default.nix similarity index 100% rename from overlays/composer1/default.nix rename to home/packages/composer1/default.nix diff --git a/home/packages/custom/backup/default.nix b/home/packages/custom/backup/default.nix new file mode 100644 index 0000000..110154f --- /dev/null +++ b/home/packages/custom/backup/default.nix @@ -0,0 +1,27 @@ +{ + writeShellApplication, + borgbackup, + git, + rsync +}: + +writeShellApplication { + name = "custom-backup"; + + text = '' + ${borgbackup}/bin/borg create \ + -v \ + --progress \ + --stats \ + --exclude-from ~/.config/borg/exclude \ + /media/daniels/Backup/borg::"$(date +%F-%R)" \ + ~/ + + ${rsync}/bin/rsync -az ~/.config/nixpkgs /media/daniels/Backup/ + + sudo ${rsync}/bin/rsync -az /etc/.git /media/daniels/Backup/etc/ + sudo chown daniels:daniels -R /media/daniels/Backup/etc/ + cd /media/daniels/Backup/etc/ + ${git}/bin/git reset --hard master + ''; +} diff --git a/home/packages/custom/customer-project/default.nix b/home/packages/custom/customer-project/default.nix new file mode 100644 index 0000000..5cfa378 --- /dev/null +++ b/home/packages/custom/customer-project/default.nix @@ -0,0 +1,182 @@ +{ + stdenv, + bash, + gnused, + mycli, + tmux +}: + +let + tmuxBin = "${tmux}/bin/tmux"; + mycliBin = "${mycli}/bin/mycli"; + sedBin = "${gnused}/bin/sed"; + source = '' + #!${bash}/bin/bash + + # This script will create a new tmux session (or attach existing) + + # TODO/NOTE: mysql is still coming from Ubuntu system, same goes for docker-compose + # TODO/NOTE: Does not yet start nix shells, something for future once I figured it out. + + # Initialize some variables + domain="$(echo $1 | ${sedBin} 's/\./-/g')" + session="project-$domain" + projectName="$(pwd)/$1" + projectRoot="$(pwd)/$1" + url="https://$domain.$(basename $(pwd) | ${sedBin} 's/\-//g').localhost/" + editorPath="$projectRoot" + + # Only create session if not already exists + ${tmuxBin} has-session -t "$session" + if [ $? != 0 ] + then + windowId=0 + databaseName=$(basename $projectName) + databaseName="$(basename $(dirname $projectName))_"$databaseName + databaseName=''${databaseName//-/} + + # Support legacy variant with underscrore in db name + if ! mysql -u admin "$databaseName" -e exit > /dev/null 2>&1 ; then + databaseName=$(basename $projectName) + # Replace - with _ for project name + databaseName=''${databaseName//-/_} + databaseName="$(basename $(dirname $projectName))_"$databaseName + # Replace - with nothing for customer name, which was added right above + databaseName=''${databaseName//-/} + fi + + # Support legacy variant without customer prefix for now + if ! mysql -u admin "$databaseName" -e exit > /dev/null 2>&1 ; then + databaseName=$(basename $projectName) + databaseName=''${databaseName//-/_} + fi + + editorPath="$projectRoot" + if [ -d "$projectRoot/project" ]; then + editorPath="$projectRoot/project" + elif [ -d "$projectRoot/htdocs" ]; then + editorPath="$projectRoot/htdocs" + fi + + # Open Editor + ${tmuxBin} new-session -s "$session" -n editor -d + ${tmuxBin} send-keys "export TYPO3_BASE=$url TYPO3_COMPOSER_AUTOLOAD=1 SOLR_HOST=localhost SOLR_PORT=8983 SOLR_SCHEME=http SOLR_CORE=core_de" C-m + ${tmuxBin} send-keys "export typo3DatabaseName=testing typo3DatabaseHost=localhost typo3DatabaseUsername=testing typo3DatabasePassword=testing" C-m + ${tmuxBin} send-keys " renice -n 5 \$\$" C-m + ${tmuxBin} send-keys " cd $editorPath" C-m + ${tmuxBin} send-keys C-l + ${tmuxBin} send-keys " nvim" C-m + let "windowId+=1" + + # Open Shell + ${tmuxBin} new-window -n project -t "$session" + ${tmuxBin} send-keys -t "$session:$windowId" "cd $editorPath" C-m + ${tmuxBin} send-keys " renice -n 5 \$\$" C-m + ${tmuxBin} send-keys "export TYPO3_BASE=$url TYPO3_COMPOSER_AUTOLOAD=1 SOLR_HOST=localhost SOLR_PORT=8983 SOLR_SCHEME=http SOLR_CORE=core_de" C-m + ${tmuxBin} send-keys "export typo3DatabaseName=testing typo3DatabaseHost=localhost typo3DatabaseUsername=testing typo3DatabasePassword=testing" C-m + ${tmuxBin} send-keys C-l + if [ "$databaseName" != "" ]; then + ${tmuxBin} send-keys "export TYPO3_DATABASE=$databaseName" C-m + ${tmuxBin} send-keys C-l + else + ${tmuxBin} send-keys "export TYPO3_DATABASE=" + fi + let "windowId+=1" + ${tmuxBin} select-pane -t 0 + + # Connect to database + ${tmuxBin} new-window -n database -t "$session" + ${tmuxBin} send-keys -t "$session:$windowId" "cd $editorPath" C-m + ${tmuxBin} send-keys " renice -n 5 \$\$" C-m + + if [ "$databaseName" != "" ]; then + ${tmuxBin} send-keys "${mycliBin} -u admin -D $databaseName" C-m + else + ${tmuxBin} send-keys "${mycliBin} -u admin -D " + fi + ${tmuxBin} send-keys C-l + + ${tmuxBin} select-pane -t 0 + let "windowId+=1" + + # Open export folder + # This step is specific to one customer + if [ -d "$projectRoot/project/typo3export/files/export-edit/" ]; then + ${tmuxBin} new-window -n export -t "$session" + ${tmuxBin} send-keys -t "$session:$windowId" "cd $projectRoot/project/typo3export/files/export-edit/" C-m + ${tmuxBin} send-keys C-l + + let "windowId+=1" + fi + + # TODO: Build dynamically, check each folder for docker-compose.yml and execute?! + # Or at least define array of folder names to check + + # Start solr docker container + if [ -d "$projectRoot/solr/" ]; then + solrPath="$projectRoot/solr/" + + ${tmuxBin} new-window -n docker -t "$session" + ${tmuxBin} send-keys -t "$session:$windowId" "cd $solrPath" C-m + ${tmuxBin} send-keys C-l + # Missing C-m at end, because we don't want to submit. + # We often don't need solr running to do our job. + ${tmuxBin} send-keys -t "$session:$windowId" "docker-compose run --rm --service-ports solr" + + let "windowId+=1" + fi + # Start elastic container + if [ -d "$projectRoot/elastic/" ]; then + elasticPath="$projectRoot/elastic/" + + ${tmuxBin} new-window -n docker -t "$session" + ${tmuxBin} send-keys -t "$session:$windowId" "cd $elasticPath" C-m + ${tmuxBin} send-keys C-l + # Missing C-m at end, because we don't want to submit. + # We often don't need elastic running to do our job. + ${tmuxBin} send-keys -t "$session:$windowId" "docker-compose run --rm --service-ports elastic" + + let "windowId+=1" + fi + # Start mysql docker container + if [ -d "$projectRoot/mysql/" ]; then + mysqlPath="$projectRoot/mysql/" + ${tmuxBin} split-window + ${tmuxBin} send-keys "cd $mysqlPath" C-m + ${tmuxBin} send-keys C-l + ${tmuxBin} send-keys "docker-compose run --rm mysql" C-m + fi + # Start mongodb container + if [ -d "$projectRoot/mongodb/" ]; then + mongodbPath="$projectRoot/mongodb/" + + ${tmuxBin} new-window -n docker -t "$session" + ${tmuxBin} send-keys -t "$session:$windowId" "cd $mongodbPath" C-m + ${tmuxBin} send-keys C-l + # Missing C-m at end, because we don't want to submit. + # We often don't need mongodb running to do our job. + ${tmuxBin} send-keys -t "$session:$windowId" "docker-compose run --rm --service-ports mongodb" + + let "windowId+=1" + fi + + # Activate shell + ${tmuxBin} select-window -t 1 + fi + # Attach to existing or created session + ${tmuxBin} attach -t "$session" + ''; +in +stdenv.mkDerivation { + name = "custom-customer-project"; + + src = source; + + dontUnpack = true; + + installPhase = '' + mkdir -p "$out/bin" + printf "%s" "$src" > "$out/bin/customerProject" + chmod ug+x $out/bin/customerProject + ''; +} diff --git a/home/packages/custom/dmenu-scripts/default.nix b/home/packages/custom/dmenu-scripts/default.nix new file mode 100644 index 0000000..cb3679e --- /dev/null +++ b/home/packages/custom/dmenu-scripts/default.nix @@ -0,0 +1,178 @@ +{ + writeShellApplication, + dmenu, + dunst, + bc +}: + +let + + # Still has many references to Ubuntu system tools. + # Will migrate step by step and update references. + + # For now it is cool to have a first custom package which can be installed. + + # It already uses nix dunst and dmenu. + # Also things like version switch should not be necessary once I managed nix shells. + + dmenu-custom-scripts-calc = writeShellApplication { + name = "dmenu-custom-scripts-calc"; + + runtimeInputs = [ + dmenu + bc + ]; + + text = '' + input=$(dmenu -i) + result=$(echo "$input" | scale=4 bc -l) + echo "$result" | dmenu -i -p "Result:" + ''; + }; + + dmenu-custom-scripts-notifications = writeShellApplication { + name = "dmenu-custom-scripts-notifications"; + + runtimeInputs = [ + dmenu + dunst + ]; + + text = '' + chosen=$(echo -e "pause\nresume" | dmenu -i) + case "$chosen" in + "pause") + dunstctl set-paused true + ;; + "resume") + dunstctl set-paused false + ;; + *) + exit 0 + ;; + esac + ''; + }; + + dmenu-custom-scripts-system = writeShellApplication { + name = "dmenu-custom-scripts-system"; + + runtimeInputs = [ + dmenu + dunst + ]; + + text = builtins.readFile ./system.sh; + }; + + dmenu-custom-scripts-docs-php = writeShellApplication { + name = "dmenu-custom-scripts-docs-php"; + + runtimeInputs = [ + dmenu + ]; + + text = '' + file=$(find ~/Projects/docs/php/ -maxdepth 1 -name '*.html' -printf "%f\n" | dmenu -i -l 20 -p "Search Term") + firefox --new-tab "http://php.docs.localhost/$file" + ''; + }; + + dmenu-custom-scripts-php-version = writeShellApplication { + name = "dmenu-custom-scripts-php-version"; + + runtimeInputs = [ + dmenu + ]; + + text = '' + chosen=$(update-alternatives --list php | dmenu -i -l 20 -p "$(php --version | head -1 | cut -d' ' -f2 | cut -d'.' -f1,2)") + sudo update-alternatives --set php "$chosen" > /dev/null + pkill -SIGRTMIN+10 i3blocks + notify-send "switching php version" "$(php --version)" + ''; + }; + + dmenu-custom-scripts-xdebug = writeShellApplication { + name = "dmenu-custom-scripts-xdebug"; + + runtimeInputs = [ + dmenu + ]; + + text = builtins.readFile ./xdebug.sh; + }; + + dmenu-custom-scripts-start-videorecording = writeShellApplication { + name = "dmenu-custom-scripts-start-videorecording"; + + runtimeInputs = [ + dmenu + ]; + + text = builtins.readFile ./start-videorecording.sh; + }; + + dmenu-custom-scripts-stop-videorecording = writeShellApplication { + name = "dmenu-custom-scripts-stop-videorecording"; + + text = '' + kill "$(cat /tmp/runningRecording.txt)" + rm /tmp/runningRecording.txt + notify-send "Stoped recording" + ''; + }; + +in +writeShellApplication { + name = "dmenu_selection"; + + # TODO: Find way to remove the nix prefixes from "files" + text = '' + scripts=() + scripts+=("${dmenu-custom-scripts-calc.name}") + scripts+=("${dmenu-custom-scripts-notifications.name}") + scripts+=("${dmenu-custom-scripts-system.name}") + scripts+=("${dmenu-custom-scripts-php-version.name}") + scripts+=("${dmenu-custom-scripts-docs-php.name}") + scripts+=("${dmenu-custom-scripts-xdebug.name}") + scripts+=("${dmenu-custom-scripts-start-videorecording.name}") + scripts+=("${dmenu-custom-scripts-stop-videorecording.name}") + + OIFS="$IFS" IFS=$'\n' + scriptsString="''${scripts[*]}" + IFS="$OIFS" + + action=$(echo -e "$scriptsString" | dmenu -i -l 20) + + case "$action" in + "${dmenu-custom-scripts-calc.name}") + bash "${dmenu-custom-scripts-calc}/bin/${dmenu-custom-scripts-calc.name}" || exit 0 + ;; + "${dmenu-custom-scripts-notifications.name}") + bash "${dmenu-custom-scripts-notifications}/bin/${dmenu-custom-scripts-notifications.name}" || exit 0 + ;; + "${dmenu-custom-scripts-system.name}") + bash "${dmenu-custom-scripts-system}/bin/${dmenu-custom-scripts-system.name}" || exit 0 + ;; + "${dmenu-custom-scripts-docs-php.name}") + bash "${dmenu-custom-scripts-docs-php}/bin/${dmenu-custom-scripts-docs-php.name}" || exit 0 + ;; + "${dmenu-custom-scripts-php-version.name}") + bash "${dmenu-custom-scripts-php-version}/bin/${dmenu-custom-scripts-php-version.name}" || exit 0 + ;; + "${dmenu-custom-scripts-xdebug.name}") + bash "${dmenu-custom-scripts-xdebug}/bin/${dmenu-custom-scripts-xdebug.name}" || exit 0 + ;; + "${dmenu-custom-scripts-start-videorecording.name}") + bash "${dmenu-custom-scripts-start-videorecording}/bin/${dmenu-custom-scripts-start-videorecording.name}" || exit 0 + ;; + "${dmenu-custom-scripts-stop-videorecording.name}") + bash "${dmenu-custom-scripts-stop-videorecording}/bin/${dmenu-custom-scripts-stop-videorecording.name}" || exit 0 + ;; + *) + exit 0 + ;; + esac + ''; +} diff --git a/overlays/dmenu-custom-scripts/start-videorecording.sh b/home/packages/custom/dmenu-scripts/start-videorecording.sh similarity index 100% rename from overlays/dmenu-custom-scripts/start-videorecording.sh rename to home/packages/custom/dmenu-scripts/start-videorecording.sh diff --git a/overlays/dmenu-custom-scripts/system.sh b/home/packages/custom/dmenu-scripts/system.sh similarity index 100% rename from overlays/dmenu-custom-scripts/system.sh rename to home/packages/custom/dmenu-scripts/system.sh diff --git a/overlays/dmenu-custom-scripts/xdebug.sh b/home/packages/custom/dmenu-scripts/xdebug.sh similarity index 100% rename from overlays/dmenu-custom-scripts/xdebug.sh rename to home/packages/custom/dmenu-scripts/xdebug.sh diff --git a/home/packages/custom/push-etckeeper/default.nix b/home/packages/custom/push-etckeeper/default.nix new file mode 100644 index 0000000..c0441ab --- /dev/null +++ b/home/packages/custom/push-etckeeper/default.nix @@ -0,0 +1,15 @@ +{ writeShellApplication }: + +writeShellApplication { + name = "custom-push-etckeeper"; + + text = '' + mkdir /tmp/etckeeper + cd /tmp/etckeeper + sudo cp -r /etc/.git . + sudo chown -R daniels:daniels . + git push + cd /tmp + rm -rf /tmp/etckeeper + ''; +} diff --git a/home/packages/custom/update-system/default.nix b/home/packages/custom/update-system/default.nix new file mode 100644 index 0000000..3eaedbf --- /dev/null +++ b/home/packages/custom/update-system/default.nix @@ -0,0 +1,18 @@ +{ writeShellApplication }: + +writeShellApplication { + name = "custom-update-system"; + + text = '' + nix-channel --update + home-manager switch + home-manager expire-generations '-30 days' + nix-env --delete-generations +5 + nix-index + oldVersion=$(home-manager generations | head -n 2 | tail -n 1 | cut -d' ' -f 7) + newVersion=$(home-manager generations | head -n 1 | cut -d' ' -f 7) + nvd diff "$oldVersion" "$newVersion" + nix store gc + nix store optimise + ''; +} diff --git a/overlays/mytop/default.nix b/home/packages/mytop/default.nix similarity index 100% rename from overlays/mytop/default.nix rename to home/packages/mytop/default.nix diff --git a/overlays/rst2pdf/rst2pdf.nix b/home/packages/rst2pdf/default.nix similarity index 100% rename from overlays/rst2pdf/rst2pdf.nix rename to home/packages/rst2pdf/default.nix diff --git a/overlays/custom-backup/default.nix b/overlays/custom-backup/default.nix deleted file mode 100644 index 9bc915b..0000000 --- a/overlays/custom-backup/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -self: super: - -{ - custom-backup = super.pkgs.writeShellApplication { - name = "custom-backup"; - - text = '' - ${super.pkgs.borgbackup}/bin/borg create \ - -v \ - --progress \ - --stats \ - --exclude-from ~/.config/borg/exclude \ - /media/daniels/Backup/borg::"$(date +%F-%R)" \ - ~/ - - ${super.pkgs.rsync}/bin/rsync -az ~/.config/nixpkgs /media/daniels/Backup/ - - sudo ${super.pkgs.rsync}/bin/rsync -az /etc/.git /media/daniels/Backup/etc/ - sudo chown daniels:daniels -R /media/daniels/Backup/etc/ - cd /media/daniels/Backup/etc/ - ${super.pkgs.git}/bin/git reset --hard master - ''; - }; -} diff --git a/overlays/custom-customer-project/default.nix b/overlays/custom-customer-project/default.nix deleted file mode 100644 index 8e803f4..0000000 --- a/overlays/custom-customer-project/default.nix +++ /dev/null @@ -1,177 +0,0 @@ -self: super: - -let - tmux = "${super.pkgs.tmux}/bin/tmux"; - mycli = "${super.pkgs.mycli}/bin/mycli"; - sed = "${super.pkgs.gnused}/bin/sed"; - source = '' - #!${super.pkgs.bash}/bin/bash - - # This script will create a new tmux session (or attach existing) - - # TODO/NOTE: mysql is still coming from Ubuntu system, same goes for docker-compose - # TODO/NOTE: Does not yet start nix shells, something for future once I figured it out. - - # Initialize some variables - domain="$(echo $1 | ${sed} 's/\./-/g')" - session="project-$domain" - projectName="$(pwd)/$1" - projectRoot="$(pwd)/$1" - url="https://$domain.$(basename $(pwd) | ${sed} 's/\-//g').localhost/" - editorPath="$projectRoot" - - # Only create session if not already exists - ${tmux} has-session -t "$session" - if [ $? != 0 ] - then - windowId=0 - databaseName=$(basename $projectName) - databaseName="$(basename $(dirname $projectName))_"$databaseName - databaseName=''${databaseName//-/} - - # Support legacy variant with underscrore in db name - if ! mysql -u admin "$databaseName" -e exit > /dev/null 2>&1 ; then - databaseName=$(basename $projectName) - # Replace - with _ for project name - databaseName=''${databaseName//-/_} - databaseName="$(basename $(dirname $projectName))_"$databaseName - # Replace - with nothing for customer name, which was added right above - databaseName=''${databaseName//-/} - fi - - # Support legacy variant without customer prefix for now - if ! mysql -u admin "$databaseName" -e exit > /dev/null 2>&1 ; then - databaseName=$(basename $projectName) - databaseName=''${databaseName//-/_} - fi - - editorPath="$projectRoot" - if [ -d "$projectRoot/project" ]; then - editorPath="$projectRoot/project" - elif [ -d "$projectRoot/htdocs" ]; then - editorPath="$projectRoot/htdocs" - fi - - # Open Editor - ${tmux} new-session -s "$session" -n editor -d - ${tmux} send-keys "export TYPO3_BASE=$url TYPO3_COMPOSER_AUTOLOAD=1 SOLR_HOST=localhost SOLR_PORT=8983 SOLR_SCHEME=http SOLR_CORE=core_de" C-m - ${tmux} send-keys "export typo3DatabaseName=testing typo3DatabaseHost=localhost typo3DatabaseUsername=testing typo3DatabasePassword=testing" C-m - ${tmux} send-keys " renice -n 5 \$\$" C-m - ${tmux} send-keys " cd $editorPath" C-m - ${tmux} send-keys C-l - ${tmux} send-keys " nvim" C-m - let "windowId+=1" - - # Open Shell - ${tmux} new-window -n project -t "$session" - ${tmux} send-keys -t "$session:$windowId" "cd $editorPath" C-m - ${tmux} send-keys " renice -n 5 \$\$" C-m - ${tmux} send-keys "export TYPO3_BASE=$url TYPO3_COMPOSER_AUTOLOAD=1 SOLR_HOST=localhost SOLR_PORT=8983 SOLR_SCHEME=http SOLR_CORE=core_de" C-m - ${tmux} send-keys "export typo3DatabaseName=testing typo3DatabaseHost=localhost typo3DatabaseUsername=testing typo3DatabasePassword=testing" C-m - ${tmux} send-keys C-l - if [ "$databaseName" != "" ]; then - ${tmux} send-keys "export TYPO3_DATABASE=$databaseName" C-m - ${tmux} send-keys C-l - else - ${tmux} send-keys "export TYPO3_DATABASE=" - fi - let "windowId+=1" - ${tmux} select-pane -t 0 - - # Connect to database - ${tmux} new-window -n database -t "$session" - ${tmux} send-keys -t "$session:$windowId" "cd $editorPath" C-m - ${tmux} send-keys " renice -n 5 \$\$" C-m - - if [ "$databaseName" != "" ]; then - ${tmux} send-keys "${mycli} -u admin -D $databaseName" C-m - else - ${tmux} send-keys "${mycli} -u admin -D " - fi - ${tmux} send-keys C-l - - ${tmux} select-pane -t 0 - let "windowId+=1" - - # Open export folder - # This step is specific to one customer - if [ -d "$projectRoot/project/typo3export/files/export-edit/" ]; then - ${tmux} new-window -n export -t "$session" - ${tmux} send-keys -t "$session:$windowId" "cd $projectRoot/project/typo3export/files/export-edit/" C-m - ${tmux} send-keys C-l - - let "windowId+=1" - fi - - # TODO: Build dynamically, check each folder for docker-compose.yml and execute?! - # Or at least define array of folder names to check - - # Start solr docker container - if [ -d "$projectRoot/solr/" ]; then - solrPath="$projectRoot/solr/" - - ${tmux} new-window -n docker -t "$session" - ${tmux} send-keys -t "$session:$windowId" "cd $solrPath" C-m - ${tmux} send-keys C-l - # Missing C-m at end, because we don't want to submit. - # We often don't need solr running to do our job. - ${tmux} send-keys -t "$session:$windowId" "docker-compose run --rm --service-ports solr" - - let "windowId+=1" - fi - # Start elastic container - if [ -d "$projectRoot/elastic/" ]; then - elasticPath="$projectRoot/elastic/" - - ${tmux} new-window -n docker -t "$session" - ${tmux} send-keys -t "$session:$windowId" "cd $elasticPath" C-m - ${tmux} send-keys C-l - # Missing C-m at end, because we don't want to submit. - # We often don't need elastic running to do our job. - ${tmux} send-keys -t "$session:$windowId" "docker-compose run --rm --service-ports elastic" - - let "windowId+=1" - fi - # Start mysql docker container - if [ -d "$projectRoot/mysql/" ]; then - mysqlPath="$projectRoot/mysql/" - ${tmux} split-window - ${tmux} send-keys "cd $mysqlPath" C-m - ${tmux} send-keys C-l - ${tmux} send-keys "docker-compose run --rm mysql" C-m - fi - # Start mongodb container - if [ -d "$projectRoot/mongodb/" ]; then - mongodbPath="$projectRoot/mongodb/" - - ${tmux} new-window -n docker -t "$session" - ${tmux} send-keys -t "$session:$windowId" "cd $mongodbPath" C-m - ${tmux} send-keys C-l - # Missing C-m at end, because we don't want to submit. - # We often don't need mongodb running to do our job. - ${tmux} send-keys -t "$session:$windowId" "docker-compose run --rm --service-ports mongodb" - - let "windowId+=1" - fi - - # Activate shell - ${tmux} select-window -t 1 - fi - # Attach to existing or created session - ${tmux} attach -t "$session" - ''; -in { - custom-customer-project = super.stdenv.mkDerivation { - name = "custom-customer-project"; - - src = source; - - dontUnpack = true; - - installPhase = '' - mkdir -p "$out/bin" - printf "%s" "$src" > "$out/bin/customerProject" - chmod ug+x $out/bin/customerProject - ''; - }; -} diff --git a/overlays/custom-push-etckeeper/default.nix b/overlays/custom-push-etckeeper/default.nix deleted file mode 100644 index 986d2d7..0000000 --- a/overlays/custom-push-etckeeper/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -self: super: - -{ - custom-push-etckeeper = super.pkgs.writeShellApplication { - name = "custom-push-etckeeper"; - - text = '' - mkdir /tmp/etckeeper - cd /tmp/etckeeper - sudo cp -r /etc/.git . - sudo chown -R daniels:daniels . - git push - cd /tmp - rm -rf /tmp/etckeeper - ''; - }; -} diff --git a/overlays/custom-update-system/default.nix b/overlays/custom-update-system/default.nix deleted file mode 100644 index ce5a486..0000000 --- a/overlays/custom-update-system/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -self: super: - -{ - custom-update-system = super.pkgs.writeShellApplication { - name = "custom-update-system"; - - text = '' - nix-channel --update - home-manager switch - home-manager expire-generations '-30 days' - nix-env --delete-generations +5 - nix-index - nix store gc - nix store optimise - ''; - }; -} diff --git a/overlays/dmenu-custom-scripts/default.nix b/overlays/dmenu-custom-scripts/default.nix deleted file mode 100644 index 58088e2..0000000 --- a/overlays/dmenu-custom-scripts/default.nix +++ /dev/null @@ -1,173 +0,0 @@ -self: super: -let - - # Still has many references to Ubuntu system tools. - # Will migrate step by step and update references. - - # For now it is cool to have a first custom package which can be installed. - - # It already uses nix dunst and dmenu. - # Also things like version switch should not be necessary once I managed nix shells. - - dmenu-custom-scripts-calc = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-calc"; - - runtimeInputs = [ - super.pkgs.dmenu - super.pkgs.bc - ]; - - text = '' - input=$(dmenu -i) - result=$(echo "$input" | scale=4 bc -l) - echo "$result" | dmenu -i -p "Result:" - ''; - }; - - dmenu-custom-scripts-notifications = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-notifications"; - - runtimeInputs = [ - super.pkgs.dmenu - super.pkgs.dunst - ]; - - text = '' - chosen=$(echo -e "pause\nresume" | dmenu -i) - case "$chosen" in - "pause") - dunstctl set-paused true - ;; - "resume") - dunstctl set-paused false - ;; - *) - exit 0 - ;; - esac - ''; - }; - - dmenu-custom-scripts-system = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-system"; - - runtimeInputs = [ - super.pkgs.dmenu - super.pkgs.dunst - ]; - - text = builtins.readFile ./system.sh; - }; - - dmenu-custom-scripts-docs-php = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-docs-php"; - - runtimeInputs = [ - super.pkgs.dmenu - ]; - - text = '' - file=$(find ~/Projects/docs/php/ -maxdepth 1 -name '*.html' -printf "%f\n" | dmenu -i -l 20 -p "Search Term") - firefox --new-tab "http://php.docs.localhost/$file" - ''; - }; - - dmenu-custom-scripts-php-version = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-php-version"; - - runtimeInputs = [ - super.pkgs.dmenu - ]; - - text = '' - chosen=$(update-alternatives --list php | dmenu -i -l 20 -p "$(php --version | head -1 | cut -d' ' -f2 | cut -d'.' -f1,2)") - sudo update-alternatives --set php "$chosen" > /dev/null - pkill -SIGRTMIN+10 i3blocks - notify-send "switching php version" "$(php --version)" - ''; - }; - - dmenu-custom-scripts-xdebug = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-xdebug"; - - runtimeInputs = [ - super.pkgs.dmenu - ]; - - text = builtins.readFile ./xdebug.sh; - }; - - dmenu-custom-scripts-start-videorecording = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-start-videorecording"; - - runtimeInputs = [ - super.pkgs.dmenu - ]; - - text = builtins.readFile ./start-videorecording.sh; - }; - - dmenu-custom-scripts-stop-videorecording = super.pkgs.writeShellApplication { - name = "dmenu-custom-scripts-stop-videorecording"; - - text = '' - kill "$(cat /tmp/runningRecording.txt)" - rm /tmp/runningRecording.txt - notify-send "Stoped recording" - ''; - }; - -in { - dmenu-custom-scripts = super.pkgs.writeShellApplication { - name = "dmenu_selection"; - - # TODO: Find way to remove the nix prefixes from "files" - text = '' - scripts=() - scripts+=("${dmenu-custom-scripts-calc.name}") - scripts+=("${dmenu-custom-scripts-notifications.name}") - scripts+=("${dmenu-custom-scripts-system.name}") - scripts+=("${dmenu-custom-scripts-php-version.name}") - scripts+=("${dmenu-custom-scripts-docs-php.name}") - scripts+=("${dmenu-custom-scripts-xdebug.name}") - scripts+=("${dmenu-custom-scripts-start-videorecording.name}") - scripts+=("${dmenu-custom-scripts-stop-videorecording.name}") - - OIFS="$IFS" IFS=$'\n' - scriptsString="''${scripts[*]}" - IFS="$OIFS" - - action=$(echo -e "$scriptsString" | dmenu -i -l 20) - - case "$action" in - "${dmenu-custom-scripts-calc.name}") - bash "${dmenu-custom-scripts-calc}/bin/${dmenu-custom-scripts-calc.name}" || exit 0 - ;; - "${dmenu-custom-scripts-notifications.name}") - bash "${dmenu-custom-scripts-notifications}/bin/${dmenu-custom-scripts-notifications.name}" || exit 0 - ;; - "${dmenu-custom-scripts-system.name}") - bash "${dmenu-custom-scripts-system}/bin/${dmenu-custom-scripts-system.name}" || exit 0 - ;; - "${dmenu-custom-scripts-docs-php.name}") - bash "${dmenu-custom-scripts-docs-php}/bin/${dmenu-custom-scripts-docs-php.name}" || exit 0 - ;; - "${dmenu-custom-scripts-php-version.name}") - bash "${dmenu-custom-scripts-php-version}/bin/${dmenu-custom-scripts-php-version.name}" || exit 0 - ;; - "${dmenu-custom-scripts-xdebug.name}") - bash "${dmenu-custom-scripts-xdebug}/bin/${dmenu-custom-scripts-xdebug.name}" || exit 0 - ;; - "${dmenu-custom-scripts-start-videorecording.name}") - bash "${dmenu-custom-scripts-start-videorecording}/bin/${dmenu-custom-scripts-start-videorecording.name}" || exit 0 - ;; - "${dmenu-custom-scripts-stop-videorecording.name}") - bash "${dmenu-custom-scripts-stop-videorecording}/bin/${dmenu-custom-scripts-stop-videorecording.name}" || exit 0 - ;; - *) - exit 0 - ;; - esac - ''; - }; -} diff --git a/overlays/rst2pdf/default.nix b/overlays/rst2pdf/default.nix deleted file mode 100644 index ebc06fa..0000000 --- a/overlays/rst2pdf/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -self: super: { - rst2pdf = self.callPackage ./rst2pdf.nix { }; -} diff --git a/readme.md b/readme.md index 837d567..cd4870d 100644 --- a/readme.md +++ b/readme.md @@ -97,8 +97,6 @@ Todos Migration: -* Custom scripts from overlay to packages which are called from home/packages.nix? - * Migrate PGP? * Right now I've installed gnupg2, gnupg, gpg on ubuntu