aboutsummaryrefslogtreecommitdiffhomepage
path: root/mitamae/default.rb
blob: 9a614fc3a568dc34af9e18d3621d23bd047aacb9 (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
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"

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}/.config/git" do
  to "#{home}/dotfiles/.config/git"
end
link "#{home}/.config/nvim" do
  to "#{home}/dotfiles/.config/nvim"
end
directory "#{home}/.config/fish"
link "#{home}/.config/fish/completions" do
  to "#{home}/dotfiles/.config/fish/completions"
end

# SKK
directory "#{home}/.config/skk"

# Rust
execute "rustup: install nightly toolchain" do
  command "rustup toolchain install nightly"
  not_if "rustup toolchain list | grep nightly"
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