Skip to content

Commit

Permalink
Start to manage macOS specific configurations (#240)
Browse files Browse the repository at this point in the history
* Start to manage darwin specific dependencies

* Fix wrong? condition, and dynamic import of color schema

* Update from fakehash

* Update iterm2 config after imported and enabled OneHalfDark

Why modified even in another schema...?

* Add note

* Fix condition branch and merging for darwin
  • Loading branch information
kachick authored Aug 2, 2023
1 parent 7b29e80 commit 466f4b1
Show file tree
Hide file tree
Showing 5 changed files with 1,392 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ dist/
tmp/

.direnv

# macOS
**/AppSupport
26 changes: 26 additions & 0 deletions home-manager/darwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ pkgs, lib, ... }:

# FAQ
#
# A. can not found dot files in macOS finder
# Q. https://apple.stackexchange.com/a/250646, consider to use nix-darwin
# https://github.com/LnL7/nix-darwin/blob/16c07487ac9bc59f58b121d13160c67befa3342e/modules/system/defaults/finder.nix#L8-L14

# https://github.com/nix-community/home-manager/issues/414#issuecomment-427163925
lib.mkMerge [
(lib.mkIf pkgs.stdenv.isDarwin {
xdg.configFile."iterm2/com.googlecode.iterm2.plist".source = ../home/.config/iterm2/com.googlecode.iterm2.plist;

# Just putting the refererenced file to easy import, applying should be done via GUI and saving to plist
xdg.configFile."iterm2/OneHalfDark.itermcolors".text = builtins.readFile (
pkgs.fetchFromGitHub
{
owner = "mbadolato";
repo = "iTerm2-Color-Schemes";
rev = "3f8a0791ed9a99c10054026c1a8285459117e0f2";
sha256 = "sha256-ixryDwSNdVtD1H+V72V+hbFiL/JNLU4qpKXWflPQwrQ=";
}
+ "/schemes/OneHalfDark.itermcolors"
);
})
]
9 changes: 6 additions & 3 deletions home-manager/home.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{ config, pkgs, lib, ... }:

# FAQ
# - How to get sha256? => assume by `lib.fakeSha256`
#
# A. How to get sha256?
# Q. Assume by `lib.fakeSha256` at first, you can get the hash with an error message

{
imports = [
Expand All @@ -10,11 +12,12 @@
./zsh.nix
./fish.nix
./git.nix
./darwin.nix # Omit needless parts for Linux in the file
];

home.username = lib.mkDefault "kachick";
# TODO: How to cover lima? The default is /home/kachick.local
home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}";
home.homeDirectory = if pkgs.stdenv.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}";

# https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix
xdg.enable = true;
Expand Down Expand Up @@ -55,7 +58,7 @@

# This also changes xdg? Official manual sed this config is better for non NixOS Linux
# https://github.com/nix-community/home-manager/blob/559856748982588a9eda6bfb668450ebcf006ccd/modules/targets/generic-linux.nix#L16
targets.genericLinux.enable = if pkgs.stdenv.hostPlatform.isDarwin then false else true;
targets.genericLinux.enable = if pkgs.stdenv.isDarwin then false else true;

# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
Expand Down
2 changes: 1 addition & 1 deletion home-manager/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
# pkgs.img2pdf
# pkgs.ocrmypdf
] ++ (
if pkgs.stdenv.hostPlatform.isDarwin then
if pkgs.stdenv.isDarwin then
[ ]
else
[
Expand Down
Loading

0 comments on commit 466f4b1

Please sign in to comment.