modularize home manager config

This commit is contained in:
Thilo Billerbeck 2023-08-21 02:24:55 +02:00
parent 8a8ecceaf5
commit d973d78d98
7 changed files with 242 additions and 149 deletions

View file

@ -1,71 +0,0 @@
{ config, pkgs, lib, ... }:
{
nixpkgs.config.allowUnfree = true;
news.display = "silent";
imports = [
./../programs/alacritty.nix
./../programs/bat.nix
./../programs/beets.nix
./../programs/command-not-found.nix
./../programs/dircolors.nix
./../programs/direnv.nix
./../programs/fzf.nix
./../programs/git.nix
./../programs/htop.nix
./../programs/neovim.nix
./../programs/starship.nix
./../programs/topgrade.nix
./../programs/yt-dlp.nix
./../programs/zsh.nix
./../programs/go.nix
./../packages.nix
];
home = {
username = "thilo";
homeDirectory = "/home/thilo";
stateVersion = "22.11";
file = {
".config/nano/nanorc".text = ''
set linenumbers
include "/usr/share/nano/*.nanorc"
'';
".ssh/config".source = ./../dotfiles/ssh-config;
".gitignore".source = ./../dotfiles/.gitignore;
};
sessionVariables = {
};
activation = {
linkDesktopApplications = {
after = [ "writeBoundary" "createXdgUserDirectories" ];
before = [ ];
data = ''
for dir in ${config.home.homeDirectory}/.nix-profile/share/applications/*; do
chmod +x $(realpath $dir) -v
done
'';
};
setNodeGlobalDir = {
after = [ "writeBoundary" "createXdgUserDirectories" ];
before = [ ];
data = ''
mkdir -p ${config.home.homeDirectory}/.node-global
${pkgs.nodejs}/bin/npm config set prefix ${config.home.homeDirectory}/.node-global
'';
};
};
sessionPath = [ "${config.home.homeDirectory}/.node-global/bin" ];
};
programs.home-manager.enable = true;
nix = {
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
}

View file

@ -1,29 +1,16 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let {
chromeArgs = lib.strings.concatStringsSep " " [
"--force-dark-mode"
"--enable-features=WebUIDarkMode"
"--enable-smooth-scrolling"
"--ozone-platform-hint=auto"
"--ignore-gpu-blocklist"
"--enable-gpu-rasterization"
"--enable-zero-copy"
"--force-device-scale-factor=1.0"
"--use-gl=desktop"
];
in {
imports = [ imports = [
./common.nix ./../modules/machine.nix
]; ];
gtk = { machine = {
enable = true; username = "thilo";
theme = { isGeneric = false;
name = "adw-gtk3-dark"; nixPackage = pkgs.nixUnstable;
package = pkgs.adw-gtk3; isGnome = true;
noiseSuppression.enable = true;
isGraphical = true;
}; };
};
news.display = "silent";
} }

View file

@ -17,13 +17,4 @@ in {
./common.nix ./common.nix
./../wrappers/fedora.nix ./../wrappers/fedora.nix
]; ];
targets.genericLinux.enable = true;
news.display = "silent";
programs.alacritty.package = (nixGLWrap pkgs.alacritty);
home.packages = with pkgs; [
];
} }

148
modules/machine.nix Normal file
View file

@ -0,0 +1,148 @@
{ lib, pkgs, config, ... }:
with lib;
{
imports = [
./../programs/alacritty.nix
./../programs/bat.nix
./../programs/beets.nix
./../programs/command-not-found.nix
./../programs/dircolors.nix
./../programs/direnv.nix
./../programs/fzf.nix
./../programs/git.nix
./../programs/htop.nix
./../programs/neovim.nix
./../programs/starship.nix
./../programs/topgrade.nix
./../programs/yt-dlp.nix
./../programs/zsh.nix
./../programs/go.nix
./packages.nix
];
options = {
machine = {
username = mkOption {
type = types.str;
default = "thilo";
description = "The username of the user";
};
isGeneric = mkOption {
type = types.bool;
default = false;
description = "Whether the system is generic or not";
};
nixPackage = mkOption {
type = types.package;
default = pkgs.nixUnstable;
description = "The version of nix to use";
};
isGraphical = mkOption {
type = types.bool;
default = false;
description = "Whether the system is graphical or not";
};
isGnome = mkOption {
type = types.bool;
default = false;
description = "Whether the system is gnome or not";
};
noiseSuppression.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable noise suppression or not";
};
};
};
config = {
nixpkgs.config.allowUnfree = true;
news.display = "silent";
targets.genericLinux.enable = config.machine.isGeneric;
home = {
username = "${config.machine.username}";
homeDirectory = "/home/${config.machine.username}";
stateVersion = "22.11";
file = {
".config/nano/nanorc".text = ''
set linenumbers
include "/usr/share/nano/*.nanorc"
'';
".ssh/config".source = ./../dotfiles/ssh-config;
".gitignore".source = ./../dotfiles/.gitignore;
} // mkIf config.machine.noiseSuppression.enable {
".config/pipewire/pipewire.conf.d/99-noise-suppression.conf".text = ''
context.modules = [{
name = libpipewire-module-filter-chain
args = {
node.description = "Noise Canceling source"
media.name = "Noise Canceling source"
filter.graph = {
nodes = [{
type = ladspa
name = rnnoise
plugin = ${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so
label = noise_suppressor_stereo
control = {
"VAD Threshold (%)" 50.0
"VAD Grace Period (ms)" 200
"Retroactive VAD Grace (ms)" 0
}
}]
}
capture.props = {
node.name = "capture.rnnoise_source"
node.passive = true
audio.rate = 48000
}
playback.props = {
node.name = "rnnoise_source"
media.class = Audio/Source
audio.rate = 48000
}
}
}]
'';
};
activation = {
setNodeGlobalDir = {
after = [ "writeBoundary" "createXdgUserDirectories" ];
before = [ ];
data = ''
mkdir -p ${config.home.homeDirectory}/.node-global
${pkgs.nodejs}/bin/npm config set prefix ${config.home.homeDirectory}/.node-global
'';
};
} // mkIf config.machine.isGeneric {
linkDesktopApplications = {
after = [ "writeBoundary" "createXdgUserDirectories" ];
before = [ ];
data = ''
for dir in ${config.home.homeDirectory}/.nix-profile/share/applications/*; do
chmod +x $(realpath $dir) -v
done
'';
};
};
sessionPath = [ "${config.home.homeDirectory}/.node-global/bin" ];
};
programs.home-manager.enable = true;
nix = {
package = config.machine.nixPackage;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
gtk = {
enable = config.machine.isGnome;
theme = {
name = "adw-gtk3-dark";
package = pkgs.adw-gtk3;
};
};
};
}

84
modules/packages.nix Normal file
View file

@ -0,0 +1,84 @@
{ config, pkgs, lib, ... }:
with lib;
let
nix-software-center = import (pkgs.fetchFromGitHub {
owner = "vlinkz";
repo = "nix-software-center";
rev = "0.1.2";
sha256 = "xiqF1mP8wFubdsAQ1BmfjzCgOD3YZf7EGWl9i69FTls=";
}) {};
in {
config = {
home.packages = with pkgs; [
up
rbenv
cargo-update
htop
rustup
nixfmt
nodejs
bun
deno
devbox
tldr
flutter
nurl
hcloud
tea
dgraph
nix-init
nodePackages.nodemon
pocketbase
# surrealdb
thefuck
hub
httpie
manix
(pkgs.writeShellScriptBin "ssh-fix-permissions"
(builtins.readFile ./../scripts/ssh-fix-permissions.sh))
(pkgs.writeShellScriptBin "yt-dlp-audio"
(builtins.readFile ./../scripts/yt-dlp-audio.sh))
(pkgs.writeShellScriptBin "nix-shell-init"
(builtins.readFile ./../scripts/nix-shell-init.sh))
(callPackage ./../pkgs/docker-craft-cms-dev-env.nix {
inherit lib;
})
(import (fetchTarball
"https://github.com/cachix/devenv/archive/v0.6.2.tar.gz")).default
nixpkgs-fmt
toolbox
distrobox
] ++ (if config.machine.isGraphical then [
(pkgs.nerdfonts.override {
fonts = [ "JetBrainsMono" "FiraCode" "FiraMono" ];
})
anki
corefonts
vistafonts
jetbrains.webstorm
element-desktop
ludusavi
dbeaver
insomnia
onlyoffice-bin
nix-software-center
spotify
(lutris.override {
extraPkgs = pkgs: [
wineWowPackages.full
winetricks
];
})
google-chrome
vscode
discord
] else [ ]) ++ (if config.machine.isGnome then [
gnomeExtensions.blur-my-shell
gnomeExtensions.dash-to-panel
gnomeExtensions.user-themes
gnomeExtensions.vitals
gnomeExtensions.custom-accent-colors
] else [ ]);
};
}

View file

@ -1,46 +0,0 @@
{ config, pkgs, lib, ... }:
{
home.packages = with pkgs;
[
up
rbenv
cargo-update
htop
rustup
nixfmt
nodejs
bun
deno
devbox
tldr
flutter
nurl
hcloud
tea
dgraph
nix-init
nodePackages.nodemon
pocketbase
# surrealdb
thefuck
corefonts
vistafonts
hub
httpie
manix
anki
] ++ [
(import (fetchTarball
"https://github.com/cachix/devenv/archive/v0.6.2.tar.gz")).default
(pkgs.nerdfonts.override {
fonts = [ "JetBrainsMono" "FiraCode" "FiraMono" ];
})
(pkgs.writeShellScriptBin "ssh-fix-permissions"
(builtins.readFile ./scripts/ssh-fix-permissions.sh))
(pkgs.writeShellScriptBin "yt-dlp-audio"
(builtins.readFile ./scripts/yt-dlp-audio.sh))
(pkgs.writeShellScriptBin "nix-shell-init"
(builtins.readFile ./scripts/nix-shell-init.sh))
(callPackage pkgs/docker-craft-cms-dev-env.nix { inherit lib; })
];
}

View file

@ -24,8 +24,8 @@ in {
enable = true; enable = true;
enableAutosuggestions = true; enableAutosuggestions = true;
enableCompletion = true; enableCompletion = true;
enableSyntaxHighlighting = true;
enableVteIntegration = true; enableVteIntegration = true;
syntaxHighlighting.enable = true;
shellAliases = { shellAliases = {
pub-ipv4 = "curl ip4.clerie.de"; pub-ipv4 = "curl ip4.clerie.de";
serve = "python -m SimpleHTTPServer 8080"; serve = "python -m SimpleHTTPServer 8080";