From b2d730087b4cee34e9daf5d193d8e146ba77bdc2 Mon Sep 17 00:00:00 2001 From: "gang.liu" <14845458+stringang@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:51:31 +0800 Subject: [PATCH] wip home-manager see: https://github.com/nix-community/home-manager/issues/4026 --- .gitignore | 3 ++- .idea/.gitignore | 8 ++++++++ .idea/dotfiles-darwin.iml | 9 +++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ flake.lock | 33 +++++++++++++++++++++++++++------ flake.nix | 34 ++++++++++++++++++++++++++++++---- home/default.nix | 21 +++++++++++++++++++++ 8 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/dotfiles-darwin.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 home/default.nix diff --git a/.gitignore b/.gitignore index 9ef2115..f8653ab 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/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/dotfiles-darwin.iml b/.idea/dotfiles-darwin.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/dotfiles-darwin.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ab3a0cc --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/flake.lock b/flake.lock index 34d7547..4fe3e58 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "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 +27,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 +42,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,6 +58,7 @@ }, "root": { "inputs": { + "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs" } 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