diff --git a/flake.nix b/flake.nix index 7ae198aa..de7836d7 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = { diff --git a/home/home-darwin.nix b/home/home-darwin.nix new file mode 100644 index 00000000..e793405c --- /dev/null +++ b/home/home-darwin.nix @@ -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; +} diff --git a/home/default.nix b/home/home-wayland.nix similarity index 97% rename from home/default.nix rename to home/home-wayland.nix index 91652e3a..efa1dfac 100644 --- a/home/default.nix +++ b/home/home-wayland.nix @@ -1,13 +1,10 @@ { config, pkgs, ... }: { - imports = [ ./fcitx5 ./hyprland - # ./i3 ./programs - ./rofi ./shell ]; diff --git a/home/home-x11.nix b/home/home-x11.nix new file mode 100644 index 00000000..281b12cb --- /dev/null +++ b/home/home-x11.nix @@ -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; +} diff --git a/hosts/harmonica/default.nix b/hosts/harmonica/default.nix new file mode 100644 index 00000000..d35d12e7 --- /dev/null +++ b/hosts/harmonica/default.nix @@ -0,0 +1,10 @@ +{ config, pkgs, home-manager, ... } @ args: + +{ + imports = [ + ../../modules/fhs-fonts.nix + ../../modules/system.nix + ]; +} + +