This commit is contained in:
Sense T 2023-06-18 20:41:10 +08:00
commit 45253ce21e
6 changed files with 224 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.DS_Store

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# 个人用的 macos 与 Nix 的集成配置
需要安装 [nix-darwin](https://github.com/lnl7/nix-darwin)
构建命令
```bash
darwin-rebuild switch --flake '.#mbp'
```

49
darwin-configuration.nix Normal file
View File

@ -0,0 +1,49 @@
{ lib, config, pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs;[
vim
wget
curl
axel
htop
];
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
# environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# nix.package = pkgs.nix;
nixpkgs.config = {
allowUnfree = true;
allowUnsupportedSystem = true;
};
nix.settings = {
auto-optimise-store = true;
substituters = lib.mkForce [
"https://mirrors.ustc.edu.cn/nix-channels/store" # 中科大
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" #清华
"https://mirrors.bfsu.edu.cn/nix-channels/store" # 北外
"https://mirror.sjtu.edu.cn/nix-channels/store" #交大
"https://cache.nixos.org/"
];
};
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
# programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
users.users.tonychyi = {
name = "tonychyi";
home = "/Users/tonychyi";
};
}

71
flake.lock generated Normal file
View File

@ -0,0 +1,71 @@
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1686307493,
"narHash": "sha256-R4VEFnDn7nRmNxAu1LwNbjns5DPM8IBsvnrWmZ8ymPs=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "7c16d31383a90e0e72ace0c35d2d66a18f90fb4f",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1687041925,
"narHash": "sha256-Zfn/SphInZ9PEIHWdQk+wGQ0XGlwAgRUp/Qso+8vDOY=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a8d549351d4b87ab80665f35e57bee2a04201245",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.05",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1687008202,
"narHash": "sha256-V5mlLY/s4Vt3I7JeyqAuuinep/haMlPLWFpeLFsF8uA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a44bf9484215c9dbd5acbf937e5c1be582b30fc6",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-23.05-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

23
flake.nix Normal file
View File

@ -0,0 +1,23 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-23.05-darwin";
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-23.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, darwin, nixpkgs, home-manager }: {
darwinConfigurations."mbp" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
./darwin-configuration.nix
home-manager.darwinModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.tonychyi = import ./home.nix;
}
];
};
};
}

71
home.nix Normal file
View File

@ -0,0 +1,71 @@
{pkgs, config, ...}: {
home = {
stateVersion = "23.05";
homeDirectory = "/Users/tonychyi";
packages = with pkgs; [
bat
thefuck
ranger
coreutils
icdiff
podman
coreutils
gnutar
gnused
jdk17
kubectl
kubernetes-helm
arduino-cli
];
shellAliases = {
cao = "fuck";
nixos-rebuild = "darwin-rebuild";
top = "htop";
pip = "pip3";
ls = "ls --color=auto";
cat = "bat -p --paging=never -u";
diff="icdiff";
};
sessionVariables = {
HOMEBREW_API_DOMAIN = "https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api";
HOMEBREW_BOTTLE_DOMAIN = "https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles";
HOMEBREW_BREW_GIT_REMOTE = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git";
HOMEBREW_CORE_GIT_REMOTE = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git";
};
sessionPath = [
"$HOME/.local/bin"
"$HOME/.cargo/bin"
"$GOPATH/bin"
];
};
programs = {
home-manager.enable = true;
timidity.enable = true;
vim = {
enable = true;
defaultEditor = true;
};
go = {
enable = true;
goPath = ".gopath";
};
zsh = {
enable = true;
enableSyntaxHighlighting = true;
oh-my-zsh = {
enable = true;
plugins = [ "sudo" "git" "golang" "thefuck" "kubectl" "emoji" "pip" "npm" "yarn" "vscode" ];
theme = "agnoster";
};
};
};
}