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.
This commit is contained in:
Luke Granger-Brown 2020-11-23 07:22:00 -08:00
parent 0f86867d05
commit 80e85feede
5 changed files with 42 additions and 11 deletions

1
home-manager-ext.nix Normal file
View file

@ -0,0 +1 @@
(import ./. {}).ops.home-manager-ext

View file

@ -6,4 +6,6 @@ args: {
nixos = import ./nixos args; nixos = import ./nixos args;
maint = import ./maint args; maint = import ./maint args;
secrets = import ./secrets args; secrets = import ./secrets args;
home-manager-ext = import ./home-manager-ext.nix args;
} }

13
ops/home-manager-ext.nix Normal file
View file

@ -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;
}

View file

@ -1,4 +1,7 @@
{ depot, lib, pkgs, ... }: { depot, lib, pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux;
in
{ {
imports = [ ./common.nix ]; imports = [ ./common.nix ];
@ -13,7 +16,6 @@
}; };
}; };
programs.direnv.enable = true; programs.direnv.enable = true;
programs.bash.enableVteIntegration = true;
programs.vim = { programs.vim = {
plugins = (with pkgs.vimPlugins; [ plugins = (with pkgs.vimPlugins; [
vim-go vim-go
@ -35,15 +37,16 @@
ssh-add -q -l >/dev/null || ssh-add -c -q ssh-add -q -l >/dev/null || ssh-add -c -q
''; '';
home.packages = lib.mkAfter (with pkgs; [ home.packages = lib.mkAfter (with pkgs; ([
depot.nix.pkgs.copybara
iftop iftop
htop htop
iotop
go go
gopls gopls
goimports goimports
graphicsmagick-imagemagick-compat graphicsmagick-imagemagick-compat
youtube-dl youtube-dl
]); ] ++ lib.optionals isLinux [
depot.nix.pkgs.copybara
iotop
]));
} }

View file

@ -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.username = "lukegb";
home.homeDirectory = "/home/lukegb"; home.homeDirectory = if isDarwin then "/Users/lukegb" else "/home/lukegb";
home.file = { home.file = {
".hgrc".source = ./hgrc; ".hgrc".source = ./hgrc;
}; };
@ -32,7 +35,7 @@
programs.bash = { programs.bash = {
enable = true; enable = true;
enableVteIntegration = true; enableVteIntegration = !isDarwin;
initExtra = '' initExtra = ''
function join_by { local IFS="$1"; shift; echo "$*"; } function join_by { local IFS="$1"; shift; echo "$*"; }
@ -68,11 +71,20 @@
}; };
programs.vim.enable = true; programs.vim.enable = true;
home.packages = (with pkgs; [ home.packages = (with pkgs; ([
ripgrep ripgrep
whois whois
dnsutils 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"; home.stateVersion = "20.09";
} }