nixos: start using home-manager

This commit is contained in:
Luke Granger-Brown 2020-10-25 11:36:16 +00:00
parent 9599a84a1c
commit 29fa1e35fd
8 changed files with 235 additions and 103 deletions

View file

@ -2,20 +2,15 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
{ pkgs, depot, lib, ... }: { pkgs, config, depot, lib, ... }:
let let
inherit (lib) mkBefore; inherit (lib) mkBefore;
in in
{ {
nix.gc.automatic = false; imports = [ ../../../third_party/home-manager/nixos ];
users.users.lukegb.packages = mkBefore (with pkgs; [ config = {
depot.nix.pkgs.copybara my.home-manager.imports = lib.mkAfter [ ./home-manager/client.nix ];
direnv nix.gc.automatic = false;
git };
go
graphicsmagick-imagemagick-compat
ripgrep
whois
]);
} }

View file

@ -2,11 +2,21 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
{ pkgs, depot, lib, rebuilder, ... }: { pkgs, config, depot, lib, rebuilder, ... }@args:
let let
inherit (lib) mkDefault; inherit (lib) mkDefault;
in in
{ {
options.my.home-manager.imports = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [ ./home-manager/common.nix ];
};
options.my.home-manager.system = lib.mkOption {
type = lib.types.nullOr lib.types.anything;
default = null;
};
config = {
hardware.enableRedistributableFirmware = true; hardware.enableRedistributableFirmware = true;
nix = { nix = {
@ -79,13 +89,26 @@ in
kernel.sysctl."net.core.default_qdisc" = "fq_codel"; kernel.sysctl."net.core.default_qdisc" = "fq_codel";
}; };
system.activationScripts.lukegb-hgrc = lib.stringAfter [ "users" "groups" ] ''
ln -sfn ${./hgrc} /home/lukegb/.hgrc
'';
# Clean up daily. # Clean up daily.
nix.gc = { nix.gc = {
automatic = lib.mkDefault true; automatic = lib.mkDefault true;
dates = "*-*-* 05:00:00"; dates = "*-*-* 05:00:00";
}; };
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
systemd.services."home-manager-lukegb" = {
before = [ "display-manager.service" ];
wantedBy = [ "multi-user.target" ];
};
home-manager.users.lukegb = { pkgs, ... }: ({
imports = [ ({
_module.args = args;
})] ++ config.my.home-manager.imports ++ (
lib.optional (config.my.home-manager.system != null) config.my.home-manager.system
);
});
};
} }

View file

@ -11,6 +11,9 @@ in
./client.nix ./client.nix
]; ];
config = {
my.home-manager.imports = lib.mkAfter [ ./home-manager/graphical-client.nix ];
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs; [
iosevka iosevka
]; ];
@ -31,4 +34,5 @@ in
xclip xclip
yubioath-desktop yubioath-desktop
]); ]);
};
} }

View file

@ -0,0 +1,38 @@
{ depot, lib, pkgs, ... }:
{
imports = [ ./common.nix ];
programs.git = {
enable = true;
package = pkgs.gitAndTools.gitFull;
extraConfig = {
user.name = "Luke Granger-Brown";
user.email = "git@lukegb.com";
pull.ff = "only";
};
};
programs.direnv.enable = true;
programs.bash.enableVteIntegration = true;
programs.vim = {
plugins = (with pkgs.vimPlugins; [
vim-go
]);
extraConfig = ''
source $VIMRUNTIME/defaults.vim
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:go_fmt_command='goimports'
set mouse=
'';
};
home.packages = lib.mkAfter (with pkgs; [
depot.nix.pkgs.copybara
go
gopls
goimports
graphicsmagick-imagemagick-compat
]);
}

View file

@ -0,0 +1,55 @@
{ depot, pkgs, ... }:
{
programs.home-manager.enable = true;
home.username = "lukegb";
home.homeDirectory = "/home/lukegb";
home.file = {
".hgrc".source = ./hgrc;
};
programs.bash = {
enable = true;
enableVteIntegration = true;
initExtra = ''
function join_by { local IFS="$1"; shift; echo "$*"; }
if [[ -z "$LAUNCH_SHLVL" ]]; then
export LAUNCH_SHLVL="$SHLVL"
fi
export LAUNCH_DEPTH="$(expr $SHLVL - $LAUNCH_SHLVL)"
export LAUNCH_DEPTH_STR=""
if [[ "$LAUNCH_DEPTH" > 0 ]]; then
if [[ "$PATH" == /nix/store/* ]]; then
declare -a RECENT_PKGS
while read -rd: pathseg; do
if [[ "$pathseg" != /nix/store/* ]]; then
break
fi
RECENT_PKGS+=("$(echo "$pathseg" | sed -E -e 's,^/nix/store/[a-z0-9]+-,,' -e 's,/.*$,,' -e 's,-[0-9.]+$,,')")
done <<< $PATH
RECENT_PKG="$(join_by ":" "''${RECENT_PKGS[@]}")"
if [[ "''${#RECENT_PKG}" > 32 ]]; then
RECENT_PKGS="''${RECENT_PKGS[0]}"
fi
if [[ ! -z "$RECENT_PKG" ]]; then
LAUNCH_DEPTH_STR="[$RECENT_PKG] "
fi
fi
if [[ -z "$LAUNCH_DEPTH_STR" ]]; then
LAUNCH_DEPTH_STR="[$LAUNCH_DEPTH] "
fi
fi
export PS1="\n\[\033[1;32m\]$LAUNCH_DEPTH_STR[\[\e]0;\u@\h: \w\a\]\u@\h:\w]\$ \[\033[0m\]"
'';
};
programs.vim.enable = true;
home.packages = (with pkgs; [
ripgrep
whois
]);
home.stateVersion = "20.09";
}

View file

@ -0,0 +1,15 @@
{ pkgs, ... }:
{
imports = [ ./client.nix ];
gtk = {
enable = true;
gtk3.extraConfig = {
gtk-application-prefer-dark-theme = 1;
};
};
qt = {
enable = true;
platformTheme = "gtk";
};
}

View file

@ -142,7 +142,9 @@ in {
# Define a user account. # Define a user account.
users.users.lukegb = { users.users.lukegb = {
extraGroups = [ "wheel" "networkmanager" ]; extraGroups = [ "wheel" "networkmanager" ];
packages = with pkgs; [ };
my.home-manager.system = {...}: {
home.packages = lib.mkAfter (with pkgs; [
(steam.override { extraProfile = nvidia-offload-profile; }) (steam.override { extraProfile = nvidia-offload-profile; })
(writeScriptBin "javaws" '' (writeScriptBin "javaws" ''
#!/bin/sh #!/bin/sh
@ -160,7 +162,7 @@ in {
iotop iotop
iw iw
vulkan-tools vulkan-tools
]; ]);
}; };
# github.com/target/lorri # github.com/target/lorri