Skip to content

Add devbox support#67

Draft
nick4eva wants to merge 10 commits into
masterfrom
add-devbox-support
Draft

Add devbox support#67
nick4eva wants to merge 10 commits into
masterfrom
add-devbox-support

Conversation

@nick4eva
Copy link
Copy Markdown
Owner

No description provided.

Comment thread Makefile Outdated
.PHONY: git

all: system git asdf terminal devops neovim ## Install and configure everything (default)
all: system nix devbox terminal #devops neovim ## Install and configure everything (default)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The all target depends on several other targets, including devbox and terminal. If any of these targets fail, the all target will also fail, but the error handling is not explicit. This can make it difficult to diagnose which part of the process failed.

Recommendation: Add explicit error handling or logging to each script being called to make it easier to diagnose failures. Alternatively, consider using a tool that provides better error reporting.

Comment thread Makefile Outdated
@./scripts/git.sh configure

terminal: zsh ohmyzsh bat-configure lsd fzf delta-configure ripgrep shellcheck lazygit win32yank navi ## Setup the terminal
terminal: zsh ohmyzsh git starship-configure bat-configure delta-configure #lsd fzf ripgrep shellcheck lazygit win32yank navi ## Setup the terminal
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminal target has a long list of dependencies, which can make it difficult to maintain and extend. If any of these dependencies are not required in all environments, it could lead to unnecessary complexity and longer execution times.

Recommendation: Break down the terminal target into smaller, more modular targets. This will improve maintainability and allow for more granular control over what gets executed.

Comment thread scripts/devbox.sh
fi

info "[devbox] Install"
bash -c "$(curl -fsSL https://get.jetify.com/devbox)" "" --force
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads and executes a remote script via curl and bash -c. This can be a significant security risk as it allows for the execution of potentially malicious code if the remote source is compromised.

Recommendation: Verify the integrity of the downloaded script before executing it. This can be done by checking the script's checksum or using a more secure method to install the software.

Comment thread scripts/nix.sh
fi

info "[nix] Install"
sh <(curl -L https://nixos.org/nix/install) --daemon --yes
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads and executes a remote script directly using curl and sh. This is a significant security risk as the remote script could be modified by a malicious actor, leading to potential system compromise.

Recommendation: Download the script first, verify its integrity (e.g., using a checksum), and then execute it. This reduces the risk of executing malicious code.

Comment thread scripts/ohmyzsh.sh
@@ -37,7 +36,6 @@ do_configure() {
done
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop that iterates over the plugins array does not perform any actions. This is likely an oversight and could lead to confusion or errors in the future.

Recommended Solution:
Ensure that the loop performs the intended actions, or remove it if it is not needed.

Comment thread scripts/starship.sh
set -e

# shellcheck source=../scripts/util.sh
source "$(pwd)/scripts/util.sh"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source "$(pwd)/scripts/util.sh" command assumes that the script is always run from the same directory where it is located. This can lead to issues if the script is executed from a different directory. A more robust approach would be to use the script's directory to construct the path to util.sh.

Comment thread scripts/starship.sh
do_configure "$@"
;;
*)
error "$(basename "$0"): '$command' is not a valid command"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error function is called when an invalid command is provided, but there is no definition or sourcing of an error function in the provided code. This will result in a command not found error. Ensure that the error function is defined or sourced from another script.

Comment thread scripts/system.sh
Comment on lines 19 to 21
export DEBIAN_FRONTEND=noninteractive
sudo apt-add-repository -y ppa:git-core/ppa
sudo apt-get update -qq
sudo apt-get install -qq -y "${packages[@]}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting DEBIAN_FRONTEND=noninteractive can suppress important prompts and error messages from apt-get, which might lead to silent failures or missed configurations. It's crucial to ensure that this behavior is intended and that any potential issues are logged or handled appropriately. Consider adding error handling or logging to capture any issues that might arise during the package installation process.

Comment thread scripts/zsh.sh

do_configure() {
info "[zsh] Install"
sudo apt-get install -qq -y zsh
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of sudo apt-get install -qq -y zsh assumes that the script is being run with sufficient privileges and on a Debian-based system. This can lead to issues if the script is run on a different distribution or without the necessary permissions. Consider adding checks to verify the operating system and user privileges before attempting to install the package. Additionally, provide a fallback or informative message if the conditions are not met.

Comment thread zsh/zshrc

# Apply sensisble zsh settings
source ~/dotfiles/zsh/zshopt
source $HOME/dotfiles/zsh/zshopt
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source $HOME/dotfiles/zsh/zshopt command does not check if the file exists before sourcing it. This could lead to errors if the file is missing.

Recommended Solution: Add a check to ensure the file exists before sourcing it, similar to the check used for extras on line 78.

Comment thread scripts/devbox.sh
fi

info "[devbox] Install"
bash -c "$(curl -fsSL https://get.jetify.com/devbox)" "" --force
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads and executes a remote script via curl and bash -c. This can be a significant security risk as it allows for the execution of potentially malicious code if the remote source is compromised.

Recommendation: Verify the integrity of the downloaded script before executing it. This can be done by checking the script's checksum or using a more secure method to install the software.

Comment thread scripts/devbox.sh
fi

info "[devbox] Install"
bash -c "$(curl -fsSL https://get.jetify.com/devbox)" "" --force
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads and executes a remote script via curl and bash -c. This can be a significant security risk as it allows for the execution of potentially malicious code if the remote source is compromised.

Recommendation: Verify the integrity of the downloaded script before executing it. This can be done by checking the script's checksum or using a more secure method to install the software.

Comment thread scripts/system.sh
Comment on lines 20 to 22
export DEBIAN_FRONTEND=noninteractive
sudo apt-add-repository -y ppa:git-core/ppa
sudo apt-get update -qq
sudo apt-get install -qq -y "${packages[@]}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting DEBIAN_FRONTEND=noninteractive can suppress important prompts and error messages from apt-get, which might lead to silent failures or missed configurations. It's crucial to ensure that this behavior is intended and that any potential issues are logged or handled appropriately. Consider adding error handling or logging to capture any issues that might arise during the package installation process.

Comment thread scripts/devbox.sh

bash
info "[devbox] Install"
bash -c "$(curl -fsSL https://get.jetify.com/devbox)" "" --force
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads and executes a remote script via curl and bash -c. This can be a significant security risk as it allows for the execution of potentially malicious code if the remote source is compromised.

Recommendation: Verify the integrity of the downloaded script before executing it. This can be done by checking the script's checksum or using a more secure method to install the software.

Comment thread Makefile Outdated
@./scripts/git.sh configure

terminal: zsh ohmyzsh bat-configure lsd fzf delta-configure ripgrep shellcheck lazygit win32yank navi ## Setup the terminal
terminal: zsh ohmyzsh git starship-configure bat-configure delta-configure direnv-configure #lsd fzf ripgrep shellcheck lazygit win32yank navi ## Setup the terminal
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminal target has a long list of dependencies, which can make it difficult to maintain and extend. If any of these dependencies are not required in all environments, it could lead to unnecessary complexity and longer execution times.

Recommendation: Break down the terminal target into smaller, more modular targets. This will improve maintainability and allow for more granular control over what gets executed.

Comment thread scripts/direnv.sh
set -e

# shellcheck source=../scripts/util.sh
source "$(pwd)/scripts/util.sh"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcing a script using an absolute path constructed with pwd can lead to issues if the script is run from a different directory. This can make the script less portable and harder to use in different environments.

Recommended Solution:
Use a relative path or determine the script's directory dynamically using ${BASH_SOURCE[0]} to make the script more robust and portable.

Comment thread scripts/direnv.sh
do_configure "$@"
;;
*)
error "$(basename "$0"): '$command' is not a valid command"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error function is used to handle invalid commands, but it is not defined within this script. This will lead to a runtime error if an invalid command is passed.

Recommended Solution:
Ensure that the error function is defined in the sourced util.sh script or define it within this script to handle errors gracefully.

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Oct 11, 2024

CI Failure Feedback 🧐

(Checks updated until commit bde9301)

Action: test (ubuntu-22.04)

Failed stage: [❌]

Failure summary:

The action failed due to the following reasons:

  • A symbolic link creation failed with the error ln: failed to create symbolic link
    '/etc/resolv.conf': Device or resource busy.
  • There was a failure to open a connection to the "system" message bus with the error Failed to
    connect to socket /var/run/dbus/system_bus_socket: No such file or directory.
  • The operation was ultimately canceled, as indicated by the message ##[error]The operation was
    canceled.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    516:  #7 11.57 Setting up systemd-timesyncd (245.4-4ubuntu3.24) ...
    517:  #7 12.30 Created symlink /etc/systemd/system/dbus-org.freedesktop.timesync1.service → /lib/systemd/system/systemd-timesyncd.service.
    518:  #7 12.30 Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service → /lib/systemd/system/systemd-timesyncd.service.
    519:  #7 12.31 Setting up systemd (245.4-4ubuntu3.24) ...
    520:  #7 12.33 Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service → /lib/systemd/system/getty@.service.
    521:  #7 12.33 Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target → /lib/systemd/system/remote-fs.target.
    522:  #7 12.33 Created symlink /etc/systemd/system/dbus-org.freedesktop.resolve1.service → /lib/systemd/system/systemd-resolved.service.
    523:  #7 12.33 Created symlink /etc/systemd/system/multi-user.target.wants/systemd-resolved.service → /lib/systemd/system/systemd-resolved.service.
    524:  #7 12.37 ln: failed to create symbolic link '/etc/resolv.conf': Device or resource busy
    ...
    
    1002:  #7 24.40 Setting up gsettings-desktop-schemas (3.36.0-1ubuntu1) ...
    1003:  #7 24.40 Setting up python3-requests-unixsocket (0.2.0-2) ...
    1004:  #7 24.50 Setting up glib-networking:amd64 (2.64.2-1ubuntu0.1) ...
    1005:  #7 24.51 Setting up libsoup2.4-1:amd64 (2.70.0-1) ...
    1006:  #7 24.51 Setting up libappstream4:amd64 (0.12.10-2) ...
    1007:  #7 24.51 Setting up packagekit (1.1.13-2ubuntu1.1) ...
    1008:  #7 24.54 invoke-rc.d: could not determine current runlevel
    1009:  #7 24.54 invoke-rc.d: policy-rc.d denied execution of force-reload.
    1010:  #7 24.54 Failed to open connection to "system" message bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    ...
    
    1031:  #7 29.05 Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
    1032:  #7 29.21 Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
    1033:  #7 29.32 Hit:5 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease
    1034:  #7 29.46 Reading package lists...
    1035:  #7 30.32 Reading package lists...
    1036:  #7 31.15 Building dependency tree...
    1037:  #7 31.32 Reading state information...
    1038:  #7 31.46 The following additional packages will be installed:
    1039:  #7 31.46   git-man libasn1-8-heimdal libcurl3-gnutls liberror-perl libgssapi3-heimdal
    ...
    
    1042:  #7 31.46   libnghttp2-14 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules-db
    1043:  #7 31.46   libssh-4 libwind0-heimdal
    1044:  #7 31.46 Suggested packages:
    1045:  #7 31.46   gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui
    1046:  #7 31.46   gitk gitweb git-cvs git-mediawiki git-svn
    1047:  #7 31.46 Recommended packages:
    1048:  #7 31.46   less ssh-client libsasl2-modules
    1049:  #7 31.51 The following NEW packages will be installed:
    1050:  #7 31.51   git git-man libasn1-8-heimdal libcurl3-gnutls liberror-perl
    ...
    
    1067:  #7 32.37 Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsasl2-modules-db amd64 2.1.27+dfsg-2ubuntu0.1 [14.7 kB]
    1068:  #7 32.37 Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsasl2-2 amd64 2.1.27+dfsg-2ubuntu0.1 [49.3 kB]
    1069:  #7 32.38 Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libldap-common all 2.4.49+dfsg-2ubuntu1.10 [16.5 kB]
    1070:  #7 32.38 Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libldap-2.4-2 amd64 2.4.49+dfsg-2ubuntu1.10 [155 kB]
    1071:  #7 32.40 Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libnghttp2-14 amd64 1.40.0-1ubuntu0.3 [79.9 kB]
    1072:  #7 32.41 Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-2build1 [54.9 kB]
    1073:  #7 32.45 Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libssh-4 amd64 0.9.3-2ubuntu2.5 [171 kB]
    1074:  #7 32.46 Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcurl3-gnutls amd64 7.68.0-1ubuntu2.24 [233 kB]
    1075:  #7 32.48 Get:18 http://archive.ubuntu.com/ubuntu focal/main amd64 liberror-perl all 0.17029-1 [26.5 kB]
    ...
    
    1145:  #7 48.49 Preparing to unpack .../14-librtmp1_2.4+20151223.gitfa8646d.1-2build1_amd64.deb ...
    1146:  #7 48.49 Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2build1) ...
    1147:  #7 48.51 Selecting previously unselected package libssh-4:amd64.
    1148:  #7 48.51 Preparing to unpack .../15-libssh-4_0.9.3-2ubuntu2.5_amd64.deb ...
    1149:  #7 48.51 Unpacking libssh-4:amd64 (0.9.3-2ubuntu2.5) ...
    1150:  #7 48.54 Selecting previously unselected package libcurl3-gnutls:amd64.
    1151:  #7 48.54 Preparing to unpack .../16-libcurl3-gnutls_7.68.0-1ubuntu2.24_amd64.deb ...
    1152:  #7 48.54 Unpacking libcurl3-gnutls:amd64 (7.68.0-1ubuntu2.24) ...
    1153:  #7 48.57 Selecting previously unselected package liberror-perl.
    1154:  #7 48.57 Preparing to unpack .../17-liberror-perl_0.17029-1_all.deb ...
    1155:  #7 48.57 Unpacking liberror-perl (0.17029-1) ...
    ...
    
    1157:  #7 48.59 Preparing to unpack .../18-git-man_1%3a2.47.0-0ppa1~ubuntu20.04.1_all.deb ...
    1158:  #7 48.59 Unpacking git-man (1:2.47.0-0ppa1~ubuntu20.04.1) ...
    1159:  #7 48.68 Selecting previously unselected package git.
    1160:  #7 48.68 Preparing to unpack .../19-git_1%3a2.47.0-0ppa1~ubuntu20.04.1_amd64.deb ...
    1161:  #7 48.69 Unpacking git (1:2.47.0-0ppa1~ubuntu20.04.1) ...
    1162:  #7 49.26 Setting up libnghttp2-14:amd64 (1.40.0-1ubuntu0.3) ...
    1163:  #7 49.26 Setting up libldap-common (2.4.49+dfsg-2ubuntu1.10) ...
    1164:  #7 49.27 Setting up libsasl2-modules-db:amd64 (2.1.27+dfsg-2ubuntu0.1) ...
    1165:  #7 49.27 Setting up liberror-perl (0.17029-1) ...
    ...
    
    1867:  Selecting previously unselected package zsh.
    1868:  Preparing to unpack .../zsh_5.8-3ubuntu1.1_amd64.deb ...
    1869:  Unpacking zsh (5.8-3ubuntu1.1) ...
    1870:  Setting up zsh-common (5.8-3ubuntu1.1) ...
    1871:  Setting up zsh (5.8-3ubuntu1.1) ...
    1872:  �[36m[zsh] Configure�[0m
    1873:  �[36m[zsh][configure] Create empty config if config is missing�[0m
    1874:  �[36m[zsh][configure] Set as default shell�[0m
    1875:  ##[error]The operation was canceled.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    Comment thread scripts/devbox.sh
    Comment on lines +24 to +28
    ln -fs "$(pwd)/devbox/devbox.json" "$DEVBOX_GLOBAL_DIR/devbox.json"
    # echo "eval '$(devbox global shellenv)'" >> ~/.zshrc
    # source ~/.zshrc
    # temporarily add the global packages to the current shell (this is already configured in oh-my-zsh)
    source <(devbox global shellenv --init-hook)
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    The script assumes the existence and correct setup of certain files and directories (e.g., devbox.json and ~/.zshrc). This can lead to failures in environments where these are not present or have restricted permissions.

    Recommendation: Add checks to ensure that necessary files and directories exist before attempting to use them. Provide clear error messages if the expected conditions are not met. This will enhance the robustness and user-friendliness of the script.

    Comment thread scripts/devbox.sh
    do_configure "$@"
    ;;
    *)
    error "$(basename "$0"): '$command' is not a valid command"
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    The error handling in the main function does not provide guidance on valid commands if an invalid command is entered. This could lead to user confusion.

    Recommendation: Enhance the error message in line 45 to include a list of valid commands. This will improve the user experience by providing immediate guidance on how to correct the input.

    Comment thread scripts/zsh.sh
    @@ -6,7 +6,12 @@ set -e
    source "$(pwd)/scripts/util.sh"
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    The use of source "$(pwd)/scripts/util.sh" introduces a security risk by dynamically constructing the path to the sourced script based on the current working directory. This could lead to sourcing an unintended script if the working directory is not as expected. To mitigate this risk, consider using a fixed path relative to the script itself or validating the path before sourcing.

    Recommended Solution:
    Use a more reliable method to determine the script's directory, such as:

    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
    source "$DIR/util.sh"

    Comment thread scripts/zsh.sh
    Comment on lines +13 to +14
    # TODO add check to create empty config only if config is missing
    echo "# Empty config created by dotfiles (will be replaced by oh-my-zsh)" >> ~/.zshrc
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    The script directly appends an empty configuration to ~/.zshrc without checking if the file already exists or if the configuration is present. This could lead to multiple redundant entries or unintended overwriting of user configurations.

    Recommended Solution:
    Implement the check as indicated by the TODO comment to ensure that the configuration is only added if it does not exist. This can be achieved using a simple conditional check:

    if [ ! -f ~/.zshrc ]; then
      echo "# Empty config created by dotfiles (will be replaced by oh-my-zsh)" >> ~/.zshrc
    fi

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant