From 80e85feede431728fc3b293a6baa56976318e808 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Mon, 23 Nov 2020 07:22:00 -0800 Subject: [PATCH] home-manager-ext: init To allow using my home-manager config on Darwin (and other non-NixOS machines), I introduce the concept of home-manager-ext, which gives me a much easier hook to import my config elsewhere. --- home-manager-ext.nix | 1 + ops/default.nix | 2 ++ ops/home-manager-ext.nix | 13 +++++++++++++ ops/nixos/lib/home-manager/client.nix | 13 ++++++++----- ops/nixos/lib/home-manager/common.nix | 24 ++++++++++++++++++------ 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 home-manager-ext.nix create mode 100644 ops/home-manager-ext.nix diff --git a/home-manager-ext.nix b/home-manager-ext.nix new file mode 100644 index 0000000000..af4a6037f1 --- /dev/null +++ b/home-manager-ext.nix @@ -0,0 +1 @@ +(import ./. {}).ops.home-manager-ext diff --git a/ops/default.nix b/ops/default.nix index 219e52433f..e369afdcde 100644 --- a/ops/default.nix +++ b/ops/default.nix @@ -6,4 +6,6 @@ args: { nixos = import ./nixos args; maint = import ./maint args; secrets = import ./secrets args; + + home-manager-ext = import ./home-manager-ext.nix args; } diff --git a/ops/home-manager-ext.nix b/ops/home-manager-ext.nix new file mode 100644 index 0000000000..b5ff5c5bce --- /dev/null +++ b/ops/home-manager-ext.nix @@ -0,0 +1,13 @@ +{ depot, ... }@args: +let + cfg = configName: configPath: { ... }: { + _module.args = args // { + inherit configName; + }; + imports = [ configPath ]; + }; +in +{ + base = cfg "base" nixos/lib/home-manager/common.nix; + client = cfg "client" nixos/lib/home-manager/client.nix; +} diff --git a/ops/nixos/lib/home-manager/client.nix b/ops/nixos/lib/home-manager/client.nix index c4ed0e0d23..a6adfa475f 100644 --- a/ops/nixos/lib/home-manager/client.nix +++ b/ops/nixos/lib/home-manager/client.nix @@ -1,4 +1,7 @@ { depot, lib, pkgs, ... }: +let + inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux; +in { imports = [ ./common.nix ]; @@ -13,7 +16,6 @@ }; }; programs.direnv.enable = true; - programs.bash.enableVteIntegration = true; programs.vim = { plugins = (with pkgs.vimPlugins; [ vim-go @@ -35,15 +37,16 @@ ssh-add -q -l >/dev/null || ssh-add -c -q ''; - home.packages = lib.mkAfter (with pkgs; [ - depot.nix.pkgs.copybara + home.packages = lib.mkAfter (with pkgs; ([ iftop htop - iotop go gopls goimports graphicsmagick-imagemagick-compat youtube-dl - ]); + ] ++ lib.optionals isLinux [ + depot.nix.pkgs.copybara + iotop + ])); } diff --git a/ops/nixos/lib/home-manager/common.nix b/ops/nixos/lib/home-manager/common.nix index 773b36f360..f48ebcd4da 100644 --- a/ops/nixos/lib/home-manager/common.nix +++ b/ops/nixos/lib/home-manager/common.nix @@ -1,9 +1,12 @@ -{ depot, lib, pkgs, ... }: +{ config, configName, depot, lib, pkgs, ... }: +let + inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux; +in { - programs.home-manager.enable = true; + programs.home-manager.enable = !isDarwin; home.username = "lukegb"; - home.homeDirectory = "/home/lukegb"; + home.homeDirectory = if isDarwin then "/Users/lukegb" else "/home/lukegb"; home.file = { ".hgrc".source = ./hgrc; }; @@ -32,7 +35,7 @@ programs.bash = { enable = true; - enableVteIntegration = true; + enableVteIntegration = !isDarwin; initExtra = '' function join_by { local IFS="$1"; shift; echo "$*"; } @@ -68,11 +71,20 @@ }; programs.vim.enable = true; - home.packages = (with pkgs; [ + home.packages = (with pkgs; ([ ripgrep whois dnsutils - ]); + ] ++ lib.optionals isDarwin [ + (writeShellScriptBin "home-manager" '' + #!/bin/sh + exec "${home-manager}/bin/home-manager" -f "${config.home.homeDirectory}/depot/home-manager-ext.nix" -A "${configName}" "$@" + '') + rxvt_unicode.terminfo tmux rsync libarchive tcpdump restic + (mercurial.overridePythonAttrs (origAttrs: { + propagatedBuildInputs = origAttrs.propagatedBuildInputs ++ [python3Packages.hg-evolve depot.nix.pkgs.hg-git]; + })) + ])); home.stateVersion = "20.09"; }