aboutsummaryrefslogtreecommitdiffhomepage
path: root/mitamae/default.rb
blob: 7efb3f3564162e683aa21308ef66cce2414c6515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
http_request ".bootstrap/nix-install" do
  url "https://nixos.org/nix/install"
end

execute "nix-install" do
  command "sh .bootstrap/nix-install --daemon"
  not_if "test -d /nix"
end

file "/etc/nix/nix.conf" do
  action :edit
  block do |content|
    content + "experimental-features = nix-command flakes\n"
  end
  not_if "grep -q 'nix-command flakes' /etc/nix/nix.conf"
end

home = ENV['HOME']

directory "#{home}/.local/state/nix/profiles"

# XDG Base Directories
directory "#{home}/.config"
directory "#{home}/.cache"
directory "#{home}/.local/share"
directory "#{home}/.local/state"

directory "#{home}/bin"

execute "home-manager" do
  command "nix run 'nixpkgs#home-manager' -- switch --flake '.##{node[:name]}'"
  not_if "type home-manager"
end

# These dotfiles are not managed by home-manager for now.

link "#{home}/.vimrc" do
  to "#{home}/dotfiles/.vimrc"
end
link "#{home}/.config/alacritty" do
  to "#{home}/dotfiles/.config/alacritty"
end
link "#{home}/.config/git" do
  to "#{home}/dotfiles/.config/git"
end
link "#{home}/.config/nvim" do
  to "#{home}/dotfiles/.config/nvim"
end

# Go
execute "go" do
  command "go build -o bin/gitalias/git-extract-issue src/gitalias/git-extract-issue.go"
  not_if "test -f bin/gitalias/git-extract-issue"
end
execute "go" do
  command "go build -o bin/gitalias/git-sw src/gitalias/git-sw.go"
  not_if "test -f bin/gitalias/git-sw"
end

directory "#{home}/bin/gitalias"

link "#{home}/bin/gitalias/git-extract-issue" do
  to "#{home}/dotfiles/bin/gitalias/git-extract-issue"
end
link "#{home}/bin/gitalias/git-sw" do
  to "#{home}/dotfiles/bin/gitalias/git-sw"
end
link "#{home}/bin/tmux-pane-idx" do
  to "#{home}/dotfiles/bin/tmux-pane-idx"
end

directory "#{home}/.local/state/zsh"

# SKK
directory "#{home}/.config/skk"
http_request "#{home}/.config/skk/SKK-JISYO.L.unannotated.gz" do
  url "https://skk-dev.github.io/dict/SKK-JISYO.L.unannotated.gz"
end
execute "unzip skk" do
  command "gunzip -cd #{home}/.config/skk/SKK-JISYO.L.unannotated.gz > #{home}/.config/skk/jisyo.L"
  not_if "test -f #{home}/.config/skk/jisyo.L"
end

link "#{home}/.config/alacritty/alacritty.local.yml" do
  is_macos = node[:targetArch].include?("darwin")
  to "#{home}/.config/alacritty/alacritty.#{is_macos ? "macos" : "linux"}.yml"
end

# Rust
execute "rustup: install nightly toolchain" do
  command "rustup toolchain install nightly"
  not_if "rustup toolchain list | grep nightly"
end
execute "cargo: install hgrep" do
  command "cargo install hgrep"
  not_if "type hgrep"
end

if node[:profile] == "private"
  package "pkg-config"
  package "libssl-dev"

  execute "cargo: install cargo-compete" do
    envs = {
      CFLAGS: "-I/usr/include",
      OPENSSL_LIB_DIR: "/usr/lib/x86_64-linux-gnu",
      OPENSSL_INCLUDE_DIR: "/usr/include/x86_64-linux-gnu",
    }
    command "#{envs.map{"#{_1}=#{_2}"}.join(" ")} cargo install cargo-compete"
    not_if "type cargo-compete"
  end
end

execute "home-manager switch" do
  command "home-manager switch --flake '.##{node[:name]}'"
end