Closed80

m1 mac 式年遷宮 ver.2025

mikanmikan

ghqのバックアップどこに移動させよう

mikanmikan

仕事のために最低限必要なソフトウェア

  • jetbrains-toolbox
    • Android Studio
  • karabiner-elements
  • XCode
  • notion
  • notion-calendar
  • keepassxc
mikanmikan

パッケージマネージャーはnixを試そうと思ってる

mikanmikan
  • home-manager
  • nix-darwin
    が必要になるらしい
mikanmikan

部屋の掃除を始めてしまった。。

mikanmikan

結局USBメモリは見つからなかったのでコンビニでSDカード買ってきた

mikanmikan

SDカードに移している者たち

  • リカバリーコード
  • Rectangleのコンフィグ
    • エクスポートを自動化したい
    • UserDefaultsに出力してるだけってあったからそっちから引っこ抜く方法を考えればいいんかな
  • scripts
    • git管理するまでもない書き捨てスクリプトたち
  • AndroidStudioProjects
mikanmikan

業務リポジトリに溜め込まれたスタッシュどうしよう

mikanmikan

スタッシュ47個は流石に多いってw

mikanmikan

古い記憶すぎて思い出す気にもなれないから、もう1回やり直してもいいよね

mikanmikan

じゃあいよいよOSクリーンインストールに入ろうかな

mikanmikan

今後は1ヶ月に1回のペースでクリーンインストールできるようにしていきたい

mikanmikan

SDカードに移すべきファイルがどれかっていうのを探すのだるいから$HOME/localに全部突っ込むようにしようかな
そうすればバックアップ作業はこのディレクトリをガッと持っていくだけで済むもんね

mikanmikan

システム設定>一般>転送またはリセット>すべてのコンテンツと設定を消去
を実行

mikanmikan

Safariでzennを開いて今これを書いている

mikanmikan

nixをインストールする

sh <(curl -L https://nixos.org/nix/install)
mikanmikan
This installation tool will set up your computer with the Nix package
manager. This will happen in a few stages:

1. Make sure your computer doesn't already have Nix. If it does, I will show you instructions on how to clean up your old install.

2. Show you what I am going to install and where. Then I will ask if you are ready to continue.

3. Create the system users (uids [351..382]) and groups (gid 350) that the Nix daemon uses to run builds. To create system users in a different range, exit and run this tool again with NIX_FIRST_BUILD_UID set.

4. Perform the basic installation of the Nix files daemon.

5. Configure your shell to import special Nix Profile files, so you can use Nix.

6. Start the Nix daemon.

Would you like to see a more detailed list of what I will do?
[y/n]
mikanmikan
error: failed to bootstrap /nix
If you enabled FileVault after booting, this is likely a known issue
with macOS that you'll have to reboot to fix. If you didn't enable FV,
though, please open an issue describing how the system that you see
this error on was set up.

We'd love to help if you need it.

You can open an issue at
https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md

Or get in touch with the community: https://nixos.org/community
mikanmikan

nix-shell経由でneofetchを動かしてみる
インストールが長い。。

mikanmikan

なんかすごい勢いでstore内のファイルが捨てられた

nix-store --gc
mikanmikan

nixの設定を置く場所を決める
君に決めた

mkdir nix
cd nix
pwd
# $HOME/nix
mikanmikan

おもむろにnix-darwinをインストールする

nix flake init -t nix-darwin --extra-experimental-features "nix-command flakes"
  • --extra-experimental-features "nix-command flakes" ってなんだろう?
mikanmikan

ちょこっとだけいじった

{
  description = "mikan m1 mac-book-pro nix-darwin system flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-darwin.url = "github:LnL7/nix-darwin";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, nix-darwin, nixpkgs }:
  let
    configuration = { pkgs, ... }: {
      # List packages installed in system profile. To search by name, run:
      # $ nix-env -qaP | grep wget
      environment.systemPackages =
        [ pkgs.vim
        ];

      # Necessary for using flakes on this system.
      nix.settings.experimental-features = "nix-command flakes";

      # Enable alternative shell support in nix-darwin.
      # programs.fish.enable = true;

      # Set Git commit hash for darwin-version.
      system.configurationRevision = self.rev or self.dirtyRev or null;

      # Used for backwards compatibility, please read the changelog before changing.
      # $ darwin-rebuild changelog
      system.stateVersion = 5;

      # The platform the configuration will be used on.
      nixpkgs.hostPlatform = "aarch64-darwin";
    };
  in
  {
    # Build darwin flake using:
    # $ darwin-rebuild build --flake .#mikan
    darwinConfigurations."mikan" = nix-darwin.lib.darwinSystem {
      modules = [ configuration ];
    };
  };
}
mikanmikan

nix-darwinをいざインストール

nix run nix-darwin --extra-experimental-features "nix-command flakes" -- switch --flake ~/nix#mikan
mikanmikan

flake.nixの変更を適用

darwin-rebuild switch --flake ~/nix#mikan
mikanmikan

あ、tabになってるし
nvimでtabを展開するやつどうするんやったっけ?

mikanmikan

nixpkgs経由でGUIを入れるとspotlight検索に引っかからない位置に置かれてしまう
/Application/Nix\ App/...

mikanmikan

まだ仕事できる環境にはなってないので明日早起きしてから作業する

mikanmikan

weztermのインストールを試みる
nixpkgs経由でインストールしたやつは豆腐になってる。。
設定変えれば直るらしいけどめんどくさいな

mikanmikan

inputsに追加

nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";

ouputsに追加

modules = [
  configuration
  nix-homebrew.darwinModules.nix-homebrew
  {
    nix-home-brew {
      enable = true;
      enableRosetta = true;
      user = "mikan";
      autoMigrate = true;
    };
  }
];
mikanmikan

なぜかここに作られた

which brew
# /opt/homebrew/bin/brew
mikanmikan

Rosettaのインストールを求められた

softwareupdate --install-rosetta
mikanmikan

Command Line Toolsのインストールを求められた

xcode-select --install
mikanmikan

一旦仕事に必要な道具を準備してからまた夜クリーンインストールしよう

mikanmikan

nix-installerの方が便利らしいから次はこれ使おう

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
mikanmikan

homebrewで管理してたやつは一通り入れた

mikanmikan

skkの辞書ってどうやって入れたんだっけ?

mikanmikan

masonでイントールするLSPはものによっては前提条件を求められるからめんどくさいな

mikanmikan

ghq getをインストールスクリプトに入れたいんだけどどう書こう?

mikanmikan

ghq listの結果をgit管理することにした

mikanmikan

やっぱ怖いからgit管理に入れるのはやめた
~/localに置くことにする

mikanmikan

uninstall

homebrew

brew uninstall --force $(brew list)

nix-darwin

nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller --no-confirm

nix store

nix-store --gc

nix

/nix/nix-installer uninstall --no-confirm
mikanmikan

これしたら動くようになった

git remote set-branches origin '*'
mikanmikan

git approveコマンドが失われてしまった
あれってgit管理してなかったっけ?

mikanmikan

思い出したscriptディレクトリに置いてたんだ
git-hogeって名前の実行可能なスクリプトファイルにパスを通せばgit hogeでできるのを利用してたんだった

mikanmikan

シェルスクリプトの引数のどれがどれか一生覚えられる気がしない

mikanmikan

IdeaVim入れたらなんか言われた

ApplePressAndHoldEnabledが0に設定されてしまうのか
覚えておこう

mikanmikan

nixに慣れてきたので本格的に入門してみようと思う

このスクラップは2025/01/12にクローズされました