diff --git a/darwin/hosts/Plato/default.nix b/darwin/hosts/Plato/default.nix index 4f13d6e..68f14fa 100644 --- a/darwin/hosts/Plato/default.nix +++ b/darwin/hosts/Plato/default.nix @@ -1,17 +1,15 @@ # iMac 18,3 (2017) {...}: { imports = [ - ../../profiles/core - ../../profiles/device-type/desktop + ../../profiles/desktop - ../../../users/guanranwang/darwin/profiles/core - ../../../users/guanranwang/darwin/profiles/device-type/desktop - ../../../users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix + ../../../users/guanranwang/darwin/profiles/desktop + ../../../users/guanranwang/darwin/profiles/common/opt-in/clash-meta-client.nix - ./hardware.configuration.nix - ../../hardware/apple/imac/18-3 + ./hardware-configuration.nix ]; networking.hostName = "Plato"; time.timeZone = "Asia/Shanghai"; + system.stateVersion = 4; } diff --git a/darwin/modules/default.nix b/darwin/modules/default.nix index 4245435..eed7124 100644 --- a/darwin/modules/default.nix +++ b/darwin/modules/default.nix @@ -1,5 +1 @@ -{...}: { - imports = [ - ./networking - ]; -} +_: {} diff --git a/darwin/modules/networking/default.nix b/darwin/modules/networking/default.nix deleted file mode 100755 index 5057fd7..0000000 --- a/darwin/modules/networking/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{...}: { - imports = [ - ./dns.nix - ]; -} diff --git a/darwin/modules/networking/dns.nix b/darwin/modules/networking/dns.nix deleted file mode 100644 index e59e788..0000000 --- a/darwin/modules/networking/dns.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.myFlake.networking.dns; -in { - options = { - myFlake.networking.dns = { - provider = lib.mkOption { - type = lib.types.enum ["dhcp" "google" "alidns"]; - default = - { - "Asia/Shanghai" = "alidns"; - } - .${config.time.timeZone} - or "google"; - example = "alidns"; - description = "Select desired DNS provider."; - }; - }; - }; - - config = { - networking.dns = - { - dhcp = []; - google = [ - ### Google DNS - "8.8.8.8" - "8.8.4.4" - "2001:4860:4860::8888" - "2001:4860:4860::8844" - ]; - alidns = [ - ### AliDNS - "223.5.5.5" - "223.6.6.6" - "2400:3200::1" - "2400:3200:baba::1" - ]; - } - .${cfg.provider}; - }; -} diff --git a/darwin/profiles/core/anti-features.nix b/darwin/profiles/common/core/anti-features.nix similarity index 100% rename from darwin/profiles/core/anti-features.nix rename to darwin/profiles/common/core/anti-features.nix diff --git a/darwin/profiles/core/default.nix b/darwin/profiles/common/core/default.nix similarity index 83% rename from darwin/profiles/core/default.nix rename to darwin/profiles/common/core/default.nix index 730ae57..f64240c 100644 --- a/darwin/profiles/core/default.nix +++ b/darwin/profiles/common/core/default.nix @@ -1,9 +1,10 @@ {inputs, ...}: { imports = [ - ../../modules ./nix ./anti-features.nix + ./networking.nix + inputs.self.darwinModules.default inputs.home-manager.darwinModules.home-manager ]; diff --git a/darwin/profiles/common/core/networking.nix b/darwin/profiles/common/core/networking.nix new file mode 100644 index 0000000..1145c44 --- /dev/null +++ b/darwin/profiles/common/core/networking.nix @@ -0,0 +1,9 @@ +_: { + networking.dns = [ + ### AliDNS + "223.5.5.5" + "223.6.6.6" + "2400:3200::1" + "2400:3200:baba::1" + ]; +} diff --git a/darwin/profiles/core/nix/default.nix b/darwin/profiles/common/core/nix/default.nix similarity index 100% rename from darwin/profiles/core/nix/default.nix rename to darwin/profiles/common/core/nix/default.nix diff --git a/darwin/profiles/core/nix/flake.nix b/darwin/profiles/common/core/nix/flake.nix similarity index 100% rename from darwin/profiles/core/nix/flake.nix rename to darwin/profiles/common/core/nix/flake.nix diff --git a/darwin/profiles/core/nix/gc.nix b/darwin/profiles/common/core/nix/gc.nix similarity index 100% rename from darwin/profiles/core/nix/gc.nix rename to darwin/profiles/common/core/nix/gc.nix diff --git a/darwin/profiles/core/nix/nix.nix b/darwin/profiles/common/core/nix/nix.nix similarity index 88% rename from darwin/profiles/core/nix/nix.nix rename to darwin/profiles/common/core/nix/nix.nix index ccc7e67..a4a1dec 100755 --- a/darwin/profiles/core/nix/nix.nix +++ b/darwin/profiles/common/core/nix/nix.nix @@ -32,8 +32,4 @@ # 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 = 4; } diff --git a/darwin/profiles/opt-in/gaming.nix b/darwin/profiles/common/opt-in/gaming.nix similarity index 100% rename from darwin/profiles/opt-in/gaming.nix rename to darwin/profiles/common/opt-in/gaming.nix diff --git a/darwin/profiles/device-type/desktop/default.nix b/darwin/profiles/desktop/default.nix similarity index 70% rename from darwin/profiles/device-type/desktop/default.nix rename to darwin/profiles/desktop/default.nix index fabed91..9497c65 100644 --- a/darwin/profiles/device-type/desktop/default.nix +++ b/darwin/profiles/desktop/default.nix @@ -1,5 +1,6 @@ {...}: { imports = [ + ../common/core ./packages ]; } diff --git a/darwin/profiles/device-type/desktop/packages/core.nix b/darwin/profiles/desktop/packages/core.nix similarity index 100% rename from darwin/profiles/device-type/desktop/packages/core.nix rename to darwin/profiles/desktop/packages/core.nix diff --git a/darwin/profiles/device-type/desktop/packages/default.nix b/darwin/profiles/desktop/packages/default.nix similarity index 100% rename from darwin/profiles/device-type/desktop/packages/default.nix rename to darwin/profiles/desktop/packages/default.nix diff --git a/darwin/profiles/device-type/desktop/packages/fonts.nix b/darwin/profiles/desktop/packages/fonts.nix similarity index 100% rename from darwin/profiles/device-type/desktop/packages/fonts.nix rename to darwin/profiles/desktop/packages/fonts.nix diff --git a/darwin/profiles/device-type/desktop/packages/homebrew.nix b/darwin/profiles/desktop/packages/homebrew.nix similarity index 100% rename from darwin/profiles/device-type/desktop/packages/homebrew.nix rename to darwin/profiles/desktop/packages/homebrew.nix diff --git a/flake.nix b/flake.nix index 437fab0..2f6f7d5 100755 --- a/flake.nix +++ b/flake.nix @@ -173,6 +173,7 @@ formatter = eachDefaultSystemMap (system: inputs.nixpkgs.legacyPackages.${system}.alejandra); packages = eachDefaultSystemMap (system: import ./pkgs inputs.nixpkgs.legacyPackages.${system}); nixosModules.default = ./nixos/modules; + darwinModules.default = ./darwin/modules; ### NixOS nixosConfigurations = { diff --git a/users/guanranwang/darwin/profiles/core/default.nix b/users/guanranwang/darwin/profiles/common/core/default.nix similarity index 76% rename from users/guanranwang/darwin/profiles/core/default.nix rename to users/guanranwang/darwin/profiles/common/core/default.nix index dd2f490..6a1441f 100644 --- a/users/guanranwang/darwin/profiles/core/default.nix +++ b/users/guanranwang/darwin/profiles/common/core/default.nix @@ -1,8 +1,4 @@ -{ - pkgs, - lib, - ... -}: { +{pkgs, ...}: { users = { knownUsers = ["guanranwang"]; users."guanranwang" = { @@ -15,6 +11,5 @@ }; ### Options - myFlake.networking.dns.provider = lib.mkDefault "alidns"; home-manager.users.guanranwang = import ./home; } diff --git a/users/guanranwang/darwin/profiles/core/home/default.nix b/users/guanranwang/darwin/profiles/common/core/home/default.nix similarity index 96% rename from users/guanranwang/darwin/profiles/core/home/default.nix rename to users/guanranwang/darwin/profiles/common/core/home/default.nix index 04537a4..7e66247 100644 --- a/users/guanranwang/darwin/profiles/core/home/default.nix +++ b/users/guanranwang/darwin/profiles/common/core/home/default.nix @@ -1,6 +1,6 @@ {...}: { imports = [ - ../../../../home-manager + ../../../../../home-manager ]; # https://github.com/mathiasbynens/dotfiles/blob/main/.macos diff --git a/users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix b/users/guanranwang/darwin/profiles/common/opt-in/clash-meta-client.nix similarity index 100% rename from users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix rename to users/guanranwang/darwin/profiles/common/opt-in/clash-meta-client.nix diff --git a/users/guanranwang/darwin/profiles/device-type/desktop/default.nix b/users/guanranwang/darwin/profiles/common/opt-in/gaming/default.nix similarity index 100% rename from users/guanranwang/darwin/profiles/device-type/desktop/default.nix rename to users/guanranwang/darwin/profiles/common/opt-in/gaming/default.nix diff --git a/users/guanranwang/darwin/profiles/opt-in/gaming/home/default.nix b/users/guanranwang/darwin/profiles/common/opt-in/gaming/home/default.nix similarity index 100% rename from users/guanranwang/darwin/profiles/opt-in/gaming/home/default.nix rename to users/guanranwang/darwin/profiles/common/opt-in/gaming/home/default.nix diff --git a/users/guanranwang/darwin/profiles/opt-in/gaming/default.nix b/users/guanranwang/darwin/profiles/desktop/default.nix similarity index 66% rename from users/guanranwang/darwin/profiles/opt-in/gaming/default.nix rename to users/guanranwang/darwin/profiles/desktop/default.nix index e5bfab2..f4e70c2 100644 --- a/users/guanranwang/darwin/profiles/opt-in/gaming/default.nix +++ b/users/guanranwang/darwin/profiles/desktop/default.nix @@ -1,4 +1,7 @@ _: { + imports = [ + ../common/core + ]; ### home-manager home-manager.users.guanranwang = import ./home; } diff --git a/users/guanranwang/darwin/profiles/device-type/desktop/home/default.nix b/users/guanranwang/darwin/profiles/desktop/home/default.nix similarity index 96% rename from users/guanranwang/darwin/profiles/device-type/desktop/home/default.nix rename to users/guanranwang/darwin/profiles/desktop/home/default.nix index 45cc101..e94603d 100644 --- a/users/guanranwang/darwin/profiles/device-type/desktop/home/default.nix +++ b/users/guanranwang/darwin/profiles/desktop/home/default.nix @@ -4,7 +4,7 @@ lib, ... }: { - imports = map (n: ../../../../../home-manager/applications/${n}) [ + imports = map (n: ../../../../home-manager/applications/${n}) [ # Terminal "alacritty" diff --git a/users/guanranwang/home-manager/applications/gpg/default.nix b/users/guanranwang/home-manager/applications/gpg/default.nix index 2ad02d1..09df20a 100644 --- a/users/guanranwang/home-manager/applications/gpg/default.nix +++ b/users/guanranwang/home-manager/applications/gpg/default.nix @@ -1,11 +1,16 @@ -{config, ...}: { +{ + config, + lib, + pkgs, + ... +}: { programs.gpg = { enable = true; homedir = "${config.xdg.dataHome}/gnupg"; }; services.gpg-agent = { - enable = true; + enable = lib.mkIf (!pkgs.stdenv.hostPlatform.isDarwin) true; pinentryFlavor = "gnome3"; }; }