Move some (all) files around

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-07-08 20:01:55 +03:00
parent 9dfbe1203d
commit 7ab40e3493
103 changed files with 202 additions and 217 deletions

View File

@@ -0,0 +1,31 @@
{
user ? throw "user argument is required",
}:
{
config,
lib,
pkgs,
...
}:
{
home-manager.users.${user.name}.systemd.user.services.mpris-proxy = {
Unit = {
Description = "MPRIS proxy";
Requires = [ "sound.target" ];
After = [
"network.target"
"sound.target"
];
};
Service.ExecStart = lib.meta.getExe (
pkgs.writeShellApplication {
name = "init-mpris-proxy";
runtimeInputs = with pkgs; [ bluez ];
text = "exec mpris-proxy";
}
);
Install.WantedBy = [ "default.target" ];
};
}

View File

@@ -0,0 +1,7 @@
{
user ? throw "user argument is required",
}:
{ lib, pkgs, ... }:
{
home-manager.users.${user.name}.home.packages = with pkgs; [ brightnessctl ];
}

View File

@@ -0,0 +1,19 @@
{
user ? throw "user argument is required",
}:
{ ... }:
{
home-manager.users.${user.name}.programs.btop = {
enable = true;
settings = {
theme_background = false;
presets = "";
vim_keys = true;
shown_boxes = "cpu mem net proc gpu0 gpu1";
update_ms = 1000;
proc_tree = true;
cpu_single_graph = true;
disks_filter = "/ /nix /persist /cache";
};
};
}

View File

@@ -0,0 +1,3 @@
git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
--in-place "$1"

View File

@@ -0,0 +1,44 @@
{
user ? throw "user argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
hmConfig = config.home-manager.users.${user.name};
in
{
home-manager.users.${user.name} = {
programs.git = {
enable = true;
lfs.enable = true;
userName = user.fullName;
userEmail = user.email;
signing = {
signByDefault = true;
key = null;
};
extraConfig = {
credential.helper = "store";
push.autoSetupRemote = true;
};
hooks = {
commit-msg = lib.meta.getExe (
pkgs.writeShellApplication {
name = "git-commit-msg-hook";
runtimeInputs = with pkgs; [ git ];
text = builtins.readFile ./commit-msg.sh;
}
);
};
};
sops.secrets."git".path = "${hmConfig.xdg.configHome}/git/credentials";
};
}

View File

@@ -0,0 +1,75 @@
{
user ? throw "user argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
hmConfig = config.home-manager.users.${user.name};
gpgPath = "${hmConfig.xdg.dataHome}/gnupg";
in
{
home-manager.users.${user.name} = {
programs.gpg = {
enable = true;
homedir = gpgPath;
};
services.gpg-agent = {
enable = true;
defaultCacheTtl = 31536000;
maxCacheTtl = 31536000;
};
systemd.user = {
services.gpg-agent-import =
let
init = lib.meta.getExe (
pkgs.writeShellApplication {
name = "import-gpg-keys";
runtimeInputs = with pkgs; [
coreutils
gnugrep
gnupg
];
runtimeEnv = {
GNUPGHOME = gpgPath;
HOME = user.home;
};
text = builtins.readFile ./import-gpg-keys.sh;
}
);
in
{
Unit = {
Description = "Auto-import GPG keys";
Requires = [
"sops-nix.service"
"gpg-agent.socket"
];
After = [
"sops-nix.service"
"gpg-agent.socket"
];
};
Service = {
Type = "oneshot";
ExecStart = init;
};
Install.WantedBy = [ "default.target" ];
};
tmpfiles.rules = [ "d ${gpgPath} 0700 ${user.name} users -" ];
};
sops.secrets = {
"gpg-agent/pgp.key" = { };
"gpg-agent/pgp.pass" = { };
};
};
}

View File

@@ -0,0 +1,16 @@
for keyfile in "$HOME"/.config/sops-nix/secrets/gpg-agent/*.key; do
passfile="${keyfile%.key}.pass"
if [ -f "$passfile" ]; then
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
else
gpg2 --batch --yes --import "$keyfile"
fi
gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
echo "$KEY_ID:6:" >> "$GNUPGHOME"/otrust.txt
done
done
gpg2 --import-ownertrust "$GNUPGHOME"/otrust.txt
rm "$GNUPGHOME"/otrust.txt

View File

@@ -0,0 +1,26 @@
{
user ? throw "user argument is required",
}:
{ config, inputs, ... }:
{
imports = [
inputs.home-manager.nixosModules.default
];
programs.dconf.enable = true;
home-manager = {
extraSpecialArgs = {
inherit inputs;
};
backupFileExtension = "bak";
useGlobalPkgs = true;
users.${user.name} = {
home.stateVersion = "24.05";
systemd.user.startServices = "sd-switch";
nix.settings = config.nix.settings;
nixpkgs.config = config.nixpkgs.config;
};
};
}

View File

@@ -0,0 +1,21 @@
{
user ? throw "user argument is required",
}:
{ ... }:
{
home-manager.users.${user.name} = {
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraConfig = ''
set tabstop=2
set shiftwidth=2
set expandtab
set smartindent
'';
};
};
}

View File

@@ -0,0 +1,30 @@
{
user ? throw "user argument is required",
}:
{
config,
inputs,
lib,
...
}:
{
programs.fuse.userAllowOther = true;
systemd.tmpfiles.rules = (
[
"d /persist/home 0755 root root -"
"d /cache/home 0755 root root -"
"d /persist${user.home} 0700 ${user.name} users -"
"d /cache${user.home} 0700 ${user.name} users -"
]
);
home-manager.users.${user.name} = {
imports = [ inputs.impermanence.nixosModules.home-manager.impermanence ];
home.persistence = {
"/persist${user.home}".allowOther = true;
"/cache${user.home}".allowOther = true;
};
};
}

View File

@@ -0,0 +1,13 @@
{
user ? throw "user argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user.name} = {
home.packages = with pkgs; [
wireplumber
playerctl
];
services.playerctld.enable = true;
};
}

View File

@@ -0,0 +1,24 @@
{
user ? throw "user argument is required",
}:
{
config,
inputs,
lib,
...
}:
let
sopsKeyPath = ".config/sops-nix/key.txt";
in
{
home-manager.users.${user.name} = {
imports = [ inputs.sops-nix.homeManagerModules.sops ];
sops.age.keyFile = "/persist${user.home}/${sopsKeyPath}";
home = {
persistence."/persist${user.home}".files = [ sopsKeyPath ];
sessionVariables.SOPS_AGE_KEY_FILE = "${user.home}/${sopsKeyPath}";
};
};
}

View File

@@ -0,0 +1,35 @@
{
user ? throw "user argument is required",
}:
{ config, ... }:
{
networking.firewall = {
allowedTCPPorts = [ 22000 ];
allowedUDPPorts = [
21027
22000
];
};
sops.secrets = {
# openssl ecparam -name prime256v1 -genkey -noout -out key.pem
"syncthing/key" = {
owner = user.name;
group = "users";
};
# openssl req -new -x509 -key key.pem -out cert.pem -days 3650
"syncthing/cert" = {
owner = user.name;
group = "users";
};
};
home-manager.users.${user.name}.services.syncthing = {
enable = true;
key = config.sops.secrets."syncthing/key".path;
cert = config.sops.secrets."syncthing/cert".path;
extraOptions = [ "-no-default-folder" ];
settings.options.urAccepted = -1;
};
}

View File

@@ -0,0 +1,34 @@
{
user ? throw "user argument is required",
}:
{ config, lib, ... }:
{
home-manager.users.${user.name} = {
imports = [ ./options.nix ];
xdg = {
enable = true;
mimeApps.enable = true;
userDirs = {
enable = true;
extraConfig = {
XDG_VM_DIR = "${user.home}/VMs";
XDG_GIT_DIR = "${user.home}/git";
};
};
};
home.persistence."/persist${user.home}".directories = [
"Desktop" # userDirs.desktop
"Documents" # userDirs.documents
"Downloads" # userDirs.download
"Music" # userDirs.music
"Pictures" # userDirs.pictures
"Templates" # userDirs.templates
"Videos" # userDirs.videos
"VMs"
"git"
];
};
}

View File

@@ -0,0 +1,42 @@
{ config, lib, ... }:
let
cfg = config.xdg;
in
{
options.xdg =
with lib;
with types;
{
relativeCacheHome = mkOption {
type = str;
default = ".cache";
description = "Relative path to directory holding application caches.";
};
cacheHome = mkOption { default = "${config.home.homeDirectory}/${cfg.relativeCacheHome}"; };
relativeConfigHome = mkOption {
type = str;
default = ".config";
description = "Relative path to directory holding application configurations.";
};
configHome = mkOption { default = "${config.home.homeDirectory}/${cfg.relativeConfigHome}"; };
relativeDataHome = mkOption {
type = str;
default = ".local/share";
description = "Relative path to directory holding application data.";
};
dataHome = mkOption { default = "${config.home.homeDirectory}/${cfg.relativeDataHome}"; };
relativeStateHome = mkOption {
type = str;
default = ".local/state";
description = "Relative path to directory holding application states.";
};
stateHome = mkOption { default = "${config.home.homeDirectory}/${cfg.relativeStateHome}"; };
};
}

View File

@@ -0,0 +1,25 @@
{
user ? throw "user argument is required",
}:
{ config, ... }:
let
hmConfig = config.home-manager.users.${user.name};
in
{
home-manager.users.${user.name} = {
programs.zsh = {
enable = true;
dotDir = "${hmConfig.xdg.relativeConfigHome}/zsh";
autocd = true;
history = {
path = "${hmConfig.xdg.dataHome}/zsh/history";
expireDuplicatesFirst = true;
};
historySubstringSearch.enable = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
};
home.persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeDataHome}/zsh" ];
};
}