Refactor Home Manager common module

This commit is contained in:
Andrew Kvalheim 2022-06-09 15:05:58 -07:00
parent e14b61f033
commit 1733c39222
4 changed files with 54 additions and 66 deletions

View file

@ -1,25 +1,28 @@
{ config, lib, pkgs, ... }:
let
add-words = pkgs.callPackage ../packages/add-words.nix { };
# Module
host = config.host;
# Resources
palette = import ./palette.nix;
words = builtins.toFile "words" (
(builtins.readFile ./words.txt) +
(builtins.readFile (host.local + "/words.txt"))
);
# Packages
add-words = pkgs.callPackage ../packages/add-words.nix { };
darktable-heif = pkgs.callPackage ../packages/darktable-heif.nix {
inherit (pkgs.gnome) zenity;
};
git-diff-image = pkgs.callPackage ../packages/git-diff-image.nix { };
gopass-await = pkgs.callPackage ../packages/gopass-await.nix {
inherit (pkgs.gnome) zenity;
};
iosevka-custom = pkgs.callPackage ../packages/iosevka-custom.nix { };
mozjpeg-simple = pkgs.callPackage ../packages/mozjpeg-simple.nix { };
off = pkgs.callPackage ../packages/off.nix { };
palette = import ./palette.nix;
in
{
imports = [
@ -27,6 +30,11 @@ in
./local/home.nix
];
options.host = {
firefoxProfile = lib.mkOption { type = lib.types.str; };
local = lib.mkOption { type = lib.types.path; };
};
config = {
# Home manager
programs.home-manager.enable = true;
@ -37,6 +45,13 @@ in
# User
home.file.".face".source = ./andrew.jpg;
xdg.configFile."Yubico/u2f_keys".source = host.local + "/andrew.u2f";
# Keyboard
# TODO: Clear `~/.compose-cache` and `~/.cache/gtk-3.0/compose` on change
home.file.".XCompose".text =
(builtins.readFile ./Compose) +
(builtins.readFile (host.local + "/Compose"));
# Applications
home.packages = with pkgs; [
@ -330,7 +345,7 @@ in
vscode = {
enable = true;
package = pkgs.vscodium;
userSettings = import ./vscode.nix { inherit lib; };
userSettings = import ./vscode.nix { inherit lib; inherit words; };
keybindings = [
{ key = "ctrl+j"; command = "-workbench.action.togglePanel"; }
{ key = "ctrl+j"; command = "editor.action.joinLines"; }
@ -452,6 +467,7 @@ in
};
};
};
home.file.".mozilla/firefox/${host.firefoxProfile}/chrome/userChrome.css".source = ./userChrome.css;
# File type associations
xdg.mimeApps = {
@ -490,6 +506,14 @@ in
};
xdg.configFile."mimeapps.list".force = true; # Workaround for nix-community/home-manager#1213
# Spell check
home.file.".mozilla/firefox/${host.firefoxProfile}/persdict.dat".source = words;
home.file.".cspell.json".text = builtins.toJSON {
dictionaries = [ "custom" ];
dictionaryDefinitions = [{ name = "custom"; path = words; }];
enableFiletypes = [ "haml" "nix" "ruby" "shellscript" ];
};
# Environment
home.sessionVariables = rec {
ANSIBLE_NOCOWS = true;

View file

@ -1,4 +1,4 @@
{ lib, ... }:
{ lib, words, ... }:
let
palette = import ./palette.nix;
@ -264,7 +264,7 @@ in
# Spelling
"cSpell.minWordLength" = 2;
"cSpell.customDictionaries" = {
custom = { path = ./words.txt; };
custom = { path = words; };
custom-css = { path = ./words-css.txt; };
custom-nix = { path = ./words-nix.txt; };
custom-rust = { path = ./words-rust.txt; };

View file

@ -1,23 +1,17 @@
{ config, lib, pkgs, ... }:
let
# Packages
attachments = (pkgs.yarn2nix-moretea.mkYarnWorkspace {
src = /home/ak/akorg/project/current/andrew.kvalhe.im/andrew.kvalhe.im;
}).attachments;
decompiler-mc = (pkgs.callPackage ../../packages/decompiler-mc.nix { });
# Workaround for https://github.com/Gubaer/josm-scripting-plugin/issues/95
josm = pkgs.josm.override { extraJavaOpts = "--add-opens java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-opens java.desktop/sun.awt.X11=ALL-UNNAMED"; };
mcaselector = (pkgs.callPackage ../../packages/mcaselector.nix { });
nbt-explorer = (pkgs.callPackage ../../packages/nbt-explorer.nix { });
wordsPath = builtins.toFile "words" (
(builtins.readFile ../../common/words.txt) +
(builtins.readFile ./local/words.txt)
);
decompiler-mc = pkgs.callPackage ../../packages/decompiler-mc.nix { };
josm = pkgs.josm.override {
# Workaround for https://github.com/Gubaer/josm-scripting-plugin/issues/95
extraJavaOpts = "--add-opens java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-opens java.desktop/sun.awt.X11=ALL-UNNAMED";
};
mcaselector = pkgs.callPackage ../../packages/mcaselector.nix { };
nbt-explorer = pkgs.callPackage ../../packages/nbt-explorer.nix { };
in
{
imports = [
@ -27,14 +21,11 @@ in
# Nix
home.stateVersion = "21.05"; # Permanent
# Authentication
xdg.configFile."Yubico/u2f_keys".source = ./local/andrew.u2f;
# Keyboard
# TODO: Clear `~/.compose-cache` and `~/.cache/gtk-3.0/compose` on change
home.file.".XCompose".text =
(builtins.readFile ../../common/Compose) +
(builtins.readFile ./local/Compose);
# Host parameters
host = {
firefoxProfile = "ahrdm58c.default";
local = ./local;
};
# Applications
home.packages = with pkgs; [
@ -65,7 +56,6 @@ in
wireshark
youtube-dl
];
home.file.".mozilla/firefox/ahrdm58c.default/chrome/userChrome.css".source = ../../common/userChrome.css;
home.file.".rubocop.yml".text = lib.generators.toYAML {} {
inherit_mode.merge = [ "Include" ];
AllCops.NewCops = "enable";
@ -78,15 +68,6 @@ in
"x-scheme-handler/mailto" = "firefox.desktop";
};
# Spell check (TODO: dedup)
home.file.".mozilla/firefox/ahrdm58c.default/persdict.dat".source = wordsPath;
programs.vscode.userSettings."cSpell.customDictionaries".custom.path = lib.mkForce wordsPath;
home.file.".cspell.json".text = lib.mkForce (builtins.toJSON {
dictionaries = [ "custom" ];
dictionaryDefinitions = [ { name = "custom"; path = wordsPath; } ];
enableFiletypes = [ "haml" "nix" "ruby" "shellscript" ];
});
# Environment
home.sessionPath = [ "$HOME/.cargo/bin" ];
home.sessionVariables.ATTACHMENTS_ENV = "/home/ak/.attachments.env";

View file

@ -1,17 +1,13 @@
{ config, lib, pkgs, ... }:
let
# Packages
pretty-whois = writeShellScriptBin "pretty-whois" ''
set -Eeuo pipefail
${whois}/bin/whois "$@" \
| ${ack}/bin/ack --color-match 'bold blue' --passthru '[-\w.!$%+=]+@[-\w.]+'
'';
wordsPath = builtins.toFile "words" (
(builtins.readFile ../../common/words.txt) +
(builtins.readFile ./local/words.txt)
);
in
{
imports = [
@ -22,14 +18,11 @@ in
# Nix
home.stateVersion = "21.11"; # Permanent
# Authentication
xdg.configFile."Yubico/u2f_keys".source = ./local/andrew.u2f;
# Keyboard
# TODO: Clear `~/.compose-cache` and `~/.cache/gtk-3.0/compose` on change
home.file.".XCompose".text =
(builtins.readFile ../../common/Compose) +
(builtins.readFile ./local/Compose);
# Host parameters
host = {
firefoxProfile = "f2y424q1.default";
local = ./local;
};
# Applications
home.packages = with pkgs; [
@ -42,20 +35,10 @@ in
thunderbird
tor-browser-bundle-bin
];
home.file.".mozilla/firefox/f2y424q1.default/chrome/userChrome.css".source = ../../common/userChrome.css;
programs.zsh.shellAliases.w = "pretty-whois";
# File type associations
xdg.mimeApps.defaultApplications = {
"x-scheme-handler/mailto" = "thunderbird.desktop";
};
# Spell check (TODO: dedup)
home.file.".mozilla/firefox/f2y424q1.default/persdict.dat".source = wordsPath;
programs.vscode.userSettings."cSpell.customDictionaries".custom.path = lib.mkForce wordsPath;
home.file.".cspell.json".text = lib.mkForce (builtins.toJSON {
dictionaries = [ "custom" ];
dictionaryDefinitions = [ { name = "custom"; path = wordsPath; } ];
enableFiletypes = [ "haml" "nix" "ruby" "shellscript" ];
});
}