diff --git a/.gitignore b/.gitignore index 9ef2115..b13ef03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp -result* \ No newline at end of file +result* +.idea/ \ No newline at end of file diff --git a/flake.lock b/flake.lock index 34d7547..a8580b7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,43 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713906585, + "narHash": "sha256-fv84DCOkBtjF6wMATt0rfovu7e95L8rdEkSfNbwKR3U=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "bfa7c06436771e3a0c666ccc6ee01e815d4c33aa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -7,11 +45,11 @@ ] }, "locked": { - "lastModified": 1713492497, - "narHash": "sha256-FifiHvYmHL7BEOaQorHjHRaW3SJj2qYCdxUmCETAQl4=", + "lastModified": 1713543876, + "narHash": "sha256-olEWxacm1xZhAtpq+ZkEyQgR4zgfE7ddpNtZNvubi3g=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "eb25dc61a62efcdf47efce6cb17cd5cb3c8f2719", + "rev": "9e7c20ffd056e406ddd0276ee9d89f09c5e5f4ed", "type": "github" }, "original": { @@ -22,11 +60,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713442664, - "narHash": "sha256-LoExypse3c/uun/39u4bPTN4wejIF7hNsdITZO41qTw=", + "lastModified": 1713805509, + "narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d764f230634fa4f86dc8d01c6af9619c7cc5d225", + "rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4", "type": "github" }, "original": { @@ -38,9 +76,26 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", + "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index abb2977..bad7b0c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,11 +3,21 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - nix-darwin.url = "github:LnL7/nix-darwin"; - nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + + flake-utils.url = "github:numtide/flake-utils"; + + nix-darwin = { + url = "github:LnL7/nix-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs@{ self, nix-darwin, nixpkgs }: + outputs = inputs@{ self, nixpkgs, flake-utils, nix-darwin, home-manager, ...}: let configuration = { pkgs, ... }: { # List packages installed in system profile. To search by name, run: @@ -42,7 +52,23 @@ # Build darwin flake using: # $ darwin-rebuild build --flake .#gangliu-MacBook-Pro darwinConfigurations."gangliu-MacBook-Pro" = nix-darwin.lib.darwinSystem { - modules = [ configuration ]; + system = "x86_64-darwin"; + modules = [ + # `nix-darwin` main config + configuration + # `home-manager` module config + home-manager.darwinModules.home-manager + { + # hardcode see: https://github.com/nix-community/home-manager/issues/4026 + users.users."gang.liu".home = "/Users/gang.liu"; + + home-manager.verbose = true; + home-manager.backupFileExtension = "hm_bak~"; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users."gang.liu" = import ./home; + } + ]; }; # Expose the package set, including overlays, for convenience. diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..34e75c1 --- /dev/null +++ b/home/default.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the + # paths it should manage. +# home.username = "gang.liu"; +# home.homeDirectory = "/Users/gang.liu"; + + # 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. + home.stateVersion = "23.11"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} \ No newline at end of file