# 安装nixos后要做的事情


## 更新channel源

```shell
sudo nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-24.11 nixos
sudo nix-channel --update
```

> 注意修改`nixos-24.11`到匹配的版本

## 启用flatpak

1. 在`/etc/nixos/configuration.nix`中添加如下代码，启用flatpak

```nix
  # flatpak support
  xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-kde ];
  xdg.portal.enable = true;
  services.flatpak.enable = true;
```

2. 启用蓝牙
   
  ```nix
  hardware.bluetooth.enable = true; # enables support for Bluetooth
  hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot
  ```

3. 启用系统级工具
   
  ```nix
  environment.systemPackages = with pkgs; [
    vim
    wget
    pkgs.git
    pkgs.nodejs_20
    pkgs.texliveSmall
    cpkgs.hexo-cli
    pkgs.pandoc
    pkgs.vscode
    pkgs.microsoft-edge
    pkgs.texliveSmall

  ];
  ```

4. 安装字体及输入法

  ```nix
  i18n.inputMethod = {
      
      enable = true;    
      type = "fcitx5";
      fcitx5.addons = with pkgs; [
        fcitx5-gtk             # alternatively, kdePackages.fcitx5-qt
        fcitx5-chinese-addons  # table input method support
        fcitx5-nord            # a color theme
        fcitx5-fluent
        fcitx5-material-color
        rime-data
        fcitx5-rime
      ];

    };

    fonts = {
      packages = with pkgs; [
        noto-fonts
        noto-fonts-cjk-sans
        noto-fonts-cjk-serif
        source-code-pro
        hack-font
        jetbrains-mono
      ];
    };

```

5. 配置网络

  ``` nix
    # Enable networking
    networking.networkmanager.enable = true;
    networking.networkmanager.dns = "none";
    networking.nameservers = [
      "223.5.5.5"
      "8.8.8.8"
      "114.114.114.114"
    ];

  ```

6. 更新系统
执行`sudo nixos-rebuild switch`更新系统

7. 修改flatpak源，并安装常用软件

```shell
sudo flatpak remote-modify flathub --url=https://mirrors.ustc.edu.cn/flathub

flatpak install flathub md.obsidian.Obsidian

```

<!-- more -->
## 其他参考网站

### 包搜索

- https://search.nixos.org/packages
- https://flathub.org/

### 删除历史版本

```shell
nixos-rebuild list-generations
sudo nix-collect-garbage -d
sudo nixos-rebuild boot
```
