feat: add support for darwin

This commit is contained in:
ryan4yin
2023-05-25 18:51:34 +08:00
parent ab1ecc49ed
commit d86aae96ff
5 changed files with 100 additions and 5 deletions

View File

@@ -37,6 +37,13 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # 使用 nixos-unstable 分支 for nix flakes
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05"; # unstable branch may be broken sometimes, use stable branch when necessary
# for macos
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.05-darwin";
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs-darwin";
}
# nix users repository
# used to install some packages not in nixpkgs
# e.g. wechat-uos/qqmusic/dingtalk
@@ -74,6 +81,7 @@
outputs = inputs@{
self,
nixpkgs,
darwin,
home-manager,
...
}: {
@@ -94,7 +102,7 @@
# 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数
home-manager.extraSpecialArgs = inputs;
home-manager.users.ryan = import ./home;
home-manager.users.ryan = import ./home/home-wayland.nix;
}
];
};
@@ -115,12 +123,33 @@
# 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数
home-manager.extraSpecialArgs = inputs;
home-manager.users.ryan = import ./home;
home-manager.users.ryan = import ./home/home-wayland.nix;
}
];
};
};
darwinConfigurations."harmonica" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = inputs;
modules = [
./hosts/harmonica
# home-manager 作为 nixos 的一个 module
# 这样在 nixos-rebuild switch 时home-manager 也会被自动部署,不需要额外执行 home-manager switch 命令
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数
home-manager.extraSpecialArgs = inputs;
home-manager.users.ryan = import ./home/home-darwin.nix;
}
];
};
# generate qcow2 & iso image from nixos configuration
# https://github.com/nix-community/nixos-generators
# packages.x86_64-linux = {

28
home/home-darwin.nix Normal file
View File

@@ -0,0 +1,28 @@
{ config, pkgs, ... }:
{
imports = [
./programs
./shell
];
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
username = "admin";
homeDirectory = "/Users/admin";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
stateVersion = "22.11";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

View File

@@ -1,13 +1,10 @@
{ config, pkgs, ... }:
{
imports = [
./fcitx5
./hyprland
# ./i3
./programs
./rofi
./shell
];

31
home/home-x11.nix Normal file
View File

@@ -0,0 +1,31 @@
{ config, pkgs, ... }:
{
imports = [
./fcitx5
./i3
./programs
./rofi
./shell
];
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
username = "ryan";
homeDirectory = "/home/ryan";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
stateVersion = "22.11";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

View File

@@ -0,0 +1,10 @@
{ config, pkgs, home-manager, ... } @ args:
{
imports = [
../../modules/fhs-fonts.nix
../../modules/system.nix
];
}