1 # This script was inspired by the ArchLinux User Repository package:
3 # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=oh-my-zsh-git
4 { lib, stdenv, fetchFromGitHub, nixosTests, writeScript, common-updater-scripts
5 , git, nix, nixfmt-classic, jq, coreutils, gnused, curl, cacert, bash }:
7 stdenv.mkDerivation rec {
8 version = "2024-07-03";
11 src = fetchFromGitHub {
14 rev = "057f3ec67e65661d3c01b757ec5cad0a3718453e";
15 sha256 = "sha256-gRQ1F13/CZaxLmDT5L+seUPldP7pBy3n3AcnfBnpcO8=";
19 buildInputs = [ bash ];
24 outdir=$out/share/oh-my-zsh
25 template=templates/zshrc.zsh-template
36 # Change the path to oh-my-zsh dir and disable auto-updating.
37 sed -i -e "s#ZSH=\$HOME/.oh-my-zsh#ZSH=$outdir#" \
38 -e 's/\# \(DISABLE_AUTO_UPDATE="true"\)/\1/' \
43 # Both functions expect oh-my-zsh to be in ~/.oh-my-zsh and try to
44 # modify the directory.
45 cat >> oh-my-zsh.sh <<- EOF
47 # Undefine functions that don't work on Nix.
48 unfunction uninstall_oh_my_zsh
49 unfunction upgrade_oh_my_zsh
52 # Look for .zsh_variables, .zsh_aliases, and .zsh_funcs, and source
54 cat >> $template <<- EOF
57 if [ -f ~/.zsh_variables ]; then
62 if [ -f ~/.zsh_funcs ]; then
67 if [ -f ~/.zsh_aliases ]; then
76 tests = { inherit (nixosTests) oh-my-zsh; };
78 updateScript = writeScript "update.sh" ''
83 common-updater-scripts
95 oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion oh-my-zsh" | tr -d '"')"
96 latestSha="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits\?sha\=master\&since\=$oldVersion | jq -r '.[0].sha')"
98 if [ ! "null" = "$latestSha" ]; then
99 nixpkgs="$(git rev-parse --show-toplevel)"
100 default_nix="$nixpkgs/pkgs/shells/zsh/oh-my-zsh/default.nix"
101 latestDate="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits/$latestSha | jq '.commit.committer.date' | sed 's|"\(.*\)T.*|\1|g')"
102 update-source-version oh-my-zsh "$latestDate" --rev="$latestSha"
103 nixfmt "$default_nix"
105 echo "${pname} is already up-to-date"
111 description = "Framework for managing your zsh configuration";
113 Oh My Zsh is a framework for managing your zsh configuration.
115 To copy the Oh My Zsh configuration file to your home directory, run
116 the following command:
118 $ cp -v $(nix-env -q --out-path oh-my-zsh | cut -d' ' -f3)/share/oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
120 homepage = "https://ohmyz.sh/";
121 license = licenses.mit;
122 platforms = platforms.all;
123 maintainers = with maintainers; [ nequissimus ];