Skip to content

Commit c0d89dc

Browse files
committed
refactor packages, add apt support
1 parent d71bb7e commit c0d89dc

8 files changed

Lines changed: 67 additions & 31 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
packageOverrides:
2+
antigen:
3+
apt:
4+
name: zsh-antigen
5+
font-hack:
6+
darwin:
7+
type: cask
8+
iterm2:
9+
darwin:
10+
type: cask
11+
visual-studio-code:
12+
darwin:
13+
type: cask
14+
yq:
15+
linux:
16+
type: brew

home/.chezmoidata/packages.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ packages:
1010
iterm2:
1111
platforms:
1212
- darwin
13-
overrides:
14-
darwin:
15-
type: cask
1613
guiOnly: true
1714
jq:
1815
platforms:
@@ -22,9 +19,6 @@ packages:
2219
platforms:
2320
- darwin
2421
- linux
25-
overrides:
26-
darwin:
27-
type: cask
2822
guiOnly: true
2923
yq:
3024
platforms:
@@ -41,9 +35,6 @@ packages:
4135
platforms:
4236
- darwin
4337
- linux
44-
overrides:
45-
darwin:
46-
type: cask
4738
guiOnly: true
4839
direnv:
4940
platforms:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{ $packages := dict -}}
2+
{{ range $name, $pkg := $.packages -}}
3+
{{ $guiOnly := dig "guiOnly" false $pkg -}}
4+
{{ if and (mustHas $.chezmoi.os $pkg.platforms) (or ($.gui) (not $guiOnly)) -}}
5+
{{ $pkgDefaults := dict "type" $.defaultPkgType "name" $name -}}
6+
{{ $pkg = mustMergeOverwrite $pkgDefaults $pkg -}}
7+
8+
{{ with dig $name "" $.packageOverrides -}}
9+
{{ with dig $.chezmoi.os "" . -}}
10+
{{ $pkg = mustMergeOverwrite $pkg . -}}
11+
{{ end -}}
12+
{{ with dig $pkg.type "" . -}}
13+
{{ $pkg = mustMergeOverwrite $pkg . -}}
14+
{{ end -}}
15+
{{ end -}}
16+
{{ $packages = set $packages $name $pkg -}}
17+
{{ end -}}
18+
{{ end -}}
19+
20+
{{ toYaml $packages -}}

home/private_dot_bashrc.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export PS1="\u@\h:\e[0;34m\w\e[m\n\$ "
77

88
source_if_exists ".aliases"
99

10-
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8.0)"
11-
1210
if [[ -n $SSH_CONNECTION ]]; then
1311
export EDITOR='vim'
1412
else

home/private_dot_zshrc.tmpl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,16 @@ unset ibrew_bin mbrew_bin ibrew_default_bin mbrew_default_bin
120120
eval "$({{ joinPath $.brewPrefix "bin" "brew" | quote }} shellenv zsh)"
121121
{{ end -}}
122122

123-
{{ if $.brewPrefix -}}
123+
{{ $linuxAntigenPath := "/usr/share/zsh-antigen/antigen.zsh" -}}
124+
{{ if stat $linuxAntigenPath -}}
125+
source {{ quote $linuxAntigenPath }}
126+
{{ else if $.brewPrefix -}}
124127
source "$HOMEBREW_PREFIX/share/antigen/antigen.zsh"
125128
{{ end -}}
126-
if has_cmd antigen; then
127-
antigen use oh-my-zsh
128-
antigen theme agnoster
129-
antigen apply
130-
fi
129+
130+
antigen use oh-my-zsh
131+
antigen theme agnoster
132+
antigen apply
131133

132134
zstyle ':omz:update' mode auto # update automatically without asking
133135

@@ -147,7 +149,7 @@ fi
147149
# Krew
148150
add_to_path "${KREW_ROOT:-$HOME/.krew}/bin"
149151

150-
{{ template "includeIfExists.tmpl" (joinPath $.chezmoi.homeDir ".zshrc.local") -}}
152+
{{ includeTemplate "includeIfExists.tmpl" (joinPath $.chezmoi.homeDir ".zshrc.local") -}}
151153

152154
# We finished init, set up completions (OMZ does this above, but we add our own, so do it again)
153155
autoload -Uz compinit
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{ if eq .chezmoi.os "linux" -}}
2+
{{ $packages := list -}}
3+
{{ range $name, $pkg := (includeTemplate "packages.tmpl" $ | fromYaml) -}}
4+
{{ if eq $pkg.type "apt" -}}
5+
{{ $packages = mustAppend $packages $pkg.name -}}
6+
{{ end -}}
7+
{{ end -}}
8+
9+
{{ if $packages -}}
10+
#!/bin/bash
11+
sudo apt install \
12+
{{ join " \\\n " $packages }}
13+
{{ end -}}
14+
{{ end -}}

home/run_onchange_brew-install-packages.sh.tmpl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
#!/bin/bash
33

44
brew bundle --file=/dev/stdin <<EOF
5-
{{ range $name, $pkg := .packages -}}
6-
{{ if mustHas $.chezmoi.os $pkg.platforms -}}
7-
{{ with dig "overrides" $.chezmoi.os "" $pkg -}}
8-
{{ $pkg = mustMergeOverwrite $pkg . -}}
9-
{{ end -}}
10-
{{ $pkgType := dig "type" $.defaultPkgType $pkg -}}
11-
{{ $pkgName := dig "name" $name $pkg -}}
12-
{{ if eq $pkgType "brew" -}}
13-
brew {{ $pkgName | quote }}
14-
{{ else if eq $pkgType "cask" -}}
15-
cask {{ $pkgName | quote }}
16-
{{ end -}}
5+
{{ range $name, $pkg := (includeTemplate "packages.tmpl" $ | fromYaml) -}}
6+
{{ if eq $pkg.type "brew" -}}
7+
brew {{ $pkg.name | quote }}
8+
{{ else if eq $pkg.type "cask" -}}
9+
cask {{ $pkg.name | quote }}
1710
{{ end -}}
1811
{{ end -}}
1912
EOF

install.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
./scripts/chezmoi-install.sh init --apply linuxdaemon
4+
SCRIPT_URL="https://github.com/linuxdaemon/dotfiles/raw/refs/heads/master/scripts/chezmoi-install.sh"
5+
6+
sh -c "$(curl -fsLS $SCRIPT_URL)" -- init --apply linuxdaemon

0 commit comments

Comments
 (0)