From e70f7269f4ce4dbc0965cecc9df45c70a0fb80a5 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 20 Dec 2023 20:09:09 +0800 Subject: [PATCH] feat: new aarch64-darwin host - fern --- Makefile | 17 ++- flake.lock | 191 ++++++--------------------- flake.nix | 4 +- home/base/desktop/neovim/default.nix | 2 +- hosts/fern/default.nix | 24 ++++ hosts/harmonica/default.nix | 2 +- modules/darwin/apps.nix | 2 +- modules/darwin/nix-core.nix | 15 ++- systems/darwin.nix | 19 ++- systems/vars.nix | 10 ++ 10 files changed, 120 insertions(+), 166 deletions(-) create mode 100644 hosts/fern/default.nix diff --git a/Makefile b/Makefile index 06d8b742..03886c53 100644 --- a/Makefile +++ b/Makefile @@ -56,18 +56,25 @@ darwin-set-proxy: sudo python3 scripts/darwin_set_proxy.py sleep 1 +darwin-rollback: + ./result/sw/bin/darwin-rebuild rollback + ha: darwin-set-proxy nix build .#darwinConfigurations.harmonica.system ./result/sw/bin/darwin-rebuild switch --flake .#harmonica - sleep 1 - -ha-rollback: - ./result/sw/bin/darwin-rebuild rollback ha-debug: darwin-set-proxy nom build .#darwinConfigurations.harmonica.system --show-trace --verbose ./result/sw/bin/darwin-rebuild switch --flake .#harmonica --show-trace --verbose - sleep 1 + +fe: darwin-set-proxy + nix build .#darwinConfigurations.fern.system + ./result/sw/bin/darwin-rebuild switch --flake .#fern + +fe-debug: darwin-set-proxy + nom build .#darwinConfigurations.fern.system --show-trace --verbose + ./result/sw/bin/darwin-rebuild switch --flake .#fern --show-trace --verbose + ############################################################################ # diff --git a/flake.lock b/flake.lock index 09634000..f724fae8 100644 --- a/flake.lock +++ b/flake.lock @@ -1,49 +1,25 @@ { "nodes": { "agenix": { - "inputs": { - "agenix": "agenix_2", - "crane": "crane", - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ], - "rust-overlay": "rust-overlay" - }, - "locked": { - "lastModified": 1682237245, - "narHash": "sha256-xbBR7LNK+d5Yi/D6FXQGc1R6u2VV2nwr/Df5iaEbOEQ=", - "owner": "ryan4yin", - "repo": "ragenix", - "rev": "281f68c3d477904f79ff1cd5807a8c226cd80a50", - "type": "github" - }, - "original": { - "owner": "ryan4yin", - "repo": "ragenix", - "type": "github" - } - }, - "agenix_2": { "inputs": { "darwin": "darwin", "home-manager": "home-manager", "nixpkgs": [ - "agenix", "nixpkgs" ] }, "locked": { - "lastModified": 1701216516, - "narHash": "sha256-jKSeJn+7hZ1dZdiH1L+NWUGT2i/BGomKAJ54B9kT06Q=", + "lastModified": 1694733633, + "narHash": "sha256-/o/OubAsPMbxqru59tLlWzUI7LBNDaoW4rFwQ2Smxcg=", "owner": "ryantm", "repo": "agenix", - "rev": "13ac9ac6d68b9a0896e3d43a082947233189e247", + "rev": "54693c91d923fecb4cf04c4535e3d84f8dec7919", "type": "github" }, "original": { "owner": "ryantm", "repo": "agenix", + "rev": "54693c91d923fecb4cf04c4535e3d84f8dec7919", "type": "github" } }, @@ -86,27 +62,6 @@ } }, "crane": { - "inputs": { - "nixpkgs": [ - "agenix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1702956644, - "narHash": "sha256-6XxZSkhb/OkxIx705RHTTLYZ2qemmEC7tODD8f21gKw=", - "owner": "ipetkov", - "repo": "crane", - "rev": "537ebb11db883f9076e37d83e3c7ee69a4abb48c", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "crane_2": { "inputs": { "flake-compat": [ "lanzaboote", @@ -142,17 +97,16 @@ "darwin": { "inputs": { "nixpkgs": [ - "agenix", "agenix", "nixpkgs" ] }, "locked": { - "lastModified": 1673295039, - "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "lastModified": 1700795494, + "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", "type": "github" }, "original": { @@ -238,25 +192,7 @@ }, "flake-utils": { "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_3" + "systems": "systems_2" }, "locked": { "lastModified": 1681202837, @@ -272,9 +208,9 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_2": { "inputs": { - "systems": "systems_4" + "systems": "systems_3" }, "locked": { "lastModified": 1701680307, @@ -290,9 +226,9 @@ "type": "github" } }, - "flake-utils_4": { + "flake-utils_3": { "inputs": { - "systems": "systems_5" + "systems": "systems_4" }, "locked": { "lastModified": 1685518550, @@ -376,17 +312,16 @@ "home-manager": { "inputs": { "nixpkgs": [ - "agenix", "agenix", "nixpkgs" ] }, "locked": { - "lastModified": 1682203081, - "narHash": "sha256-kRL4ejWDhi0zph/FpebFYhzqlOBrk0Pl3dzGEKSAlEw=", + "lastModified": 1703026685, + "narHash": "sha256-AkualfMbc40HkDR2AZc6u71pcap50wDQOXFCY1ULDUA=", "owner": "nix-community", "repo": "home-manager", - "rev": "32d3e39c491e2f91152c84f8ad8b003420eab0a1", + "rev": "efc177c15f2a8bb063aeb250fe3c7c21e1de265e", "type": "github" }, "original": { @@ -422,7 +357,7 @@ "nixpkgs": [ "nixpkgs" ], - "systems": "systems_2", + "systems": "systems", "wlroots": "wlroots", "xdph": "xdph" }, @@ -483,15 +418,15 @@ }, "lanzaboote": { "inputs": { - "crane": "crane_2", + "crane": "crane", "flake-compat": "flake-compat", "flake-parts": "flake-parts_2", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ], "pre-commit-hooks-nix": "pre-commit-hooks-nix", - "rust-overlay": "rust-overlay_2" + "rust-overlay": "rust-overlay" }, "locked": { "lastModified": 1682802423, @@ -619,7 +554,7 @@ }, "nixos-rk3588": { "inputs": { - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_2", "mesa-panfork": "mesa-panfork", "nixpkgs": "nixpkgs_2", "pre-commit-hooks": "pre-commit-hooks" @@ -752,16 +687,16 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1692221125, - "narHash": "sha256-nKUDlbLL8/WW3Fpx9Y0sY+LliTqU3/GexvHU9BdA8Qk=", + "lastModified": 1702921762, + "narHash": "sha256-O/rP7gulApQAB47u6szEd8Pn8Biw0d84j5iuP2tcxzY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "214c9de8159b25f3cdc8374a80794d4d5787b4cf", + "rev": "d02ffbbe834b5599fc5f134e644e49397eb07188", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } @@ -771,11 +706,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1703048844, - "narHash": "sha256-uDF4s2Oz0eO53C7o6TcHtkm5w3QnnA7ImmaFpe9xYes=", + "lastModified": 1703077061, + "narHash": "sha256-6jmjEXJe9mXLiGj/KpuyWp3AIxIh7uM/bIwmm9BHKEU=", "owner": "ryan4yin", "repo": "nur-packages", - "rev": "5f13060c3ad4439d7700aa21b498d9192d6ef1b4", + "rev": "ad8927476f57f35db0e18ef0d80a4e6589582e0c", "type": "github" }, "original": { @@ -868,7 +803,7 @@ "pre-commit-hooks_2": { "inputs": { "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_3", "gitignore": "gitignore_3", "nixpkgs": [ "nixpkgs" @@ -913,31 +848,6 @@ } }, "rust-overlay": { - "inputs": { - "flake-utils": [ - "agenix", - "flake-utils" - ], - "nixpkgs": [ - "agenix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1703037971, - "narHash": "sha256-HzfW5MLt+I0DlfPM9sL+Vd1XrywoWiW0LSAez3wp23E=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "16ab5af8f23b63f34dd7a48a68ab3b50dc3dd2b6", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { "inputs": { "flake-utils": [ "lanzaboote", @@ -963,21 +873,6 @@ } }, "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", @@ -992,6 +887,21 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "systems_3": { "locked": { "lastModified": 1681028828, @@ -1022,21 +932,6 @@ "type": "github" } }, - "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "thead-kernel": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 0948b144..96b195f3 100644 --- a/flake.nix +++ b/flake.nix @@ -143,9 +143,9 @@ # secrets management agenix = { # lock with git commit at 0.14.0 - # url = "github:ryantm/agenix/54693c91d923fecb4cf04c4535e3d84f8dec7919"; + url = "github:ryantm/agenix/54693c91d923fecb4cf04c4535e3d84f8dec7919"; # replaced with a type-safe reimplementation to get a better error message and less bugs. - url = "github:ryan4yin/ragenix"; + # url = "github:ryan4yin/ragenix"; inputs.nixpkgs.follows = "nixpkgs"; }; diff --git a/home/base/desktop/neovim/default.nix b/home/base/desktop/neovim/default.nix index 2c3ea128..9524b092 100644 --- a/home/base/desktop/neovim/default.nix +++ b/home/base/desktop/neovim/default.nix @@ -47,7 +47,6 @@ checkmake gcc # c/c++ compiler, required by nvim-treesitter! llvmPackages.clang-unwrapped # c/c++ tools with clang-tools such as clangd - gdb lldb #-- python @@ -149,6 +148,7 @@ else [ #-- verilog / systemverilog verible + gdb ] ); }; diff --git a/hosts/fern/default.nix b/hosts/fern/default.nix new file mode 100644 index 00000000..924c72a9 --- /dev/null +++ b/hosts/fern/default.nix @@ -0,0 +1,24 @@ +{username, ...} @ args: +############################################################# +# +# Fern - MacBook Pro 2022 13-inch M2 16G, mainly for business. +# +############################################################# +let + hostname = "fern"; +in { + networking.hostName = hostname; + networking.computerName = hostname; + system.defaults.smb.NetBIOSName = hostname; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users."${username}" = { + home = "/Users/${username}"; + description = username; + + # set user's default shell back to zsh + # `chsh -s /bin/zsh` + # DO NOT change the system's default shell to nushell! it will break some apps! + # It's better to change only starship/alacritty/vscode's shell to nushell! + }; +} diff --git a/hosts/harmonica/default.nix b/hosts/harmonica/default.nix index ebc2c901..c16aa62d 100644 --- a/hosts/harmonica/default.nix +++ b/hosts/harmonica/default.nix @@ -1,7 +1,7 @@ {username, ...} @ args: ############################################################# # -# Harmonica - my MacBook Pro 2020 13-inch, mainly for business. +# Harmonica - my MacBook Pro 2020 13-inch, mainly for personal use # ############################################################# let diff --git a/modules/darwin/apps.nix b/modules/darwin/apps.nix index 889136c2..b8ac53dd 100644 --- a/modules/darwin/apps.nix +++ b/modules/darwin/apps.nix @@ -133,7 +133,7 @@ "microsoft-remote-desktop" # "anki" - "clashx" # proxy tool + "shadowsocksx-ng" # proxy tool "iina" # video player "openinterminal-lite" # open current folder in terminal "syncthing" # file sync diff --git a/modules/darwin/nix-core.nix b/modules/darwin/nix-core.nix index 628c971a..61c18aa4 100644 --- a/modules/darwin/nix-core.nix +++ b/modules/darwin/nix-core.nix @@ -11,13 +11,20 @@ # Fix: https://github.com/LnL7/nix-darwin/issues/149#issuecomment-1741720259 # nix is installed via DeterminateSystems's nix-installer. environment.etc."zshrc".knownSha256Hashes = [ - "b9902f2020c636aeda956a74b5ae11882d53e206d1aa50b3abe591a8144fa710" + "b9902f2020c636aeda956a74b5ae11882d53e206d1aa50b3abe591a8144fa710" # nix-installer on harmonica ]; environment.etc."bashrc".knownSha256Hashes = [ - "204d2a960b3ab80e51748d3db0b63d940347ba71119ae6f14cccfec35da56cce" - ]; + "204d2a960b3ab80e51748d3db0b63d940347ba71119ae6f14cccfec35da56cce" # nix-installer on harmonica + "6ffdf5a198ffe73fbcd17def767f52093b42b29149d4a3e911b49ebcb9785101" # nix-installer on fern + ]; environment.etc."zshenv".knownSha256Hashes = [ - "383a89c1f79c3bcfd2ff39a2b73b5103d0303161b3be9eac88fce83e0789f0b7" + "383a89c1f79c3bcfd2ff39a2b73b5103d0303161b3be9eac88fce83e0789f0b7" # nix-installer on harmonica + "0c544e42afe7836de9ba933d93f46043b12f58ae484ff8cfb02716353f1dba5f" # nix-installer on fern + ]; + + + environment.etc."shells".knownSha256Hashes = [ + "9d5aa72f807091b481820d12e693093293ba33c73854909ad7b0fb192c2db193" # nix-installer on fern ]; # Allow unfree packages diff --git a/systems/darwin.nix b/systems/darwin.nix index b1d33a94..0057c703 100644 --- a/systems/darwin.nix +++ b/systems/darwin.nix @@ -1,17 +1,28 @@ args: with args; let macosSystem = import ../lib/macosSystem.nix; - system = x64_darwin; - base_args = { - inherit nix-darwin home-manager system; + x64_args = { + inherit nix-darwin home-manager; + system = x64_darwin; specialArgs = x64_darwin_specialArgs; nixpkgs = nixpkgs-darwin; }; + aarch64_args = { + inherit nix-darwin home-manager; + system = aarch64_darwin; + specialArgs = aarch64_darwin_specialArgs; + nixpkgs = nixpkgs-darwin; + }; + in { # macOS's configuration, for work. darwinConfigurations = { harmonica = - macosSystem (base_args + macosSystem (x64_args // darwin_harmonica_modules); + + fern = + macosSystem (aarch64_args + // darwin_fern_modules); }; } diff --git a/systems/vars.nix b/systems/vars.nix index 61fb1c6b..fcb111fa 100644 --- a/systems/vars.nix +++ b/systems/vars.nix @@ -99,4 +99,14 @@ ]; home-module = import ../home/darwin; }; + darwin_fern_modules = { + darwin-modules = [ + ../hosts/fern + + ../modules/darwin + ../secrets/darwin.nix + ]; + home-module = import ../home/darwin; + }; + }