From a23bb49688f121e1d6416bb83ebbd7427df5d8c0 Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Tue, 2 Jan 2024 17:17:59 +0300 Subject: [PATCH] Revisiting dotfiles installation Signed-off-by: Ivan Bushchik --- README.md | 7 ++++--- common/default.nix | 2 +- common/dotfiles.nix | 40 ++++++++++++++++++++++++++++++++++++++++ common/git.nix | 3 --- common/user.nix | 2 ++ roles/media-client.nix | 17 +++++++++++++++-- 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 common/dotfiles.nix diff --git a/README.md b/README.md index 9f21a97..0a7e7da 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,11 @@ in { I "made" some shell in [shells/](./shells). -## Dotfiles (from `ivabus/dotfiles`) +## Dotfiles development -I install my dotfiles with prepared script +As I fully manage my dotfiles through home-manager and `fetchGit` they are readonly. + +To install normal version of them disable `my.users.ivabus.dotfiles.enable` and run this command (which installs and links dotfiles) ``` curl https://iva.bz/nix | sh @@ -71,7 +73,6 @@ curl https://iva.bz/nix | sh - [x] ивабус.рф (proxying not-Nix env) - Setup "secret" roles (I need them) - Setup router (in progress with `periculo`, aughhhhhhhhh it seems like I need to crosscompile it for 30 days straight, so no fast progress) -- Setup dotfiles properly with home-manager ## Copyright diff --git a/common/default.nix b/common/default.nix index a214c5f..a6cc9c6 100644 --- a/common/default.nix +++ b/common/default.nix @@ -1,7 +1,7 @@ { imports = [ ./base.nix - # ./dotfiles.nix unfinished yet + ./dotfiles.nix ./git.nix ./laptop.nix ./locale.nix diff --git a/common/dotfiles.nix b/common/dotfiles.nix new file mode 100644 index 0000000..2b25c19 --- /dev/null +++ b/common/dotfiles.nix @@ -0,0 +1,40 @@ +{ config, pkgs, lib, ... }: + +let + dotfiles = builtins.fetchGit { + url = "https://github.com/ivabus/dotfiles"; + rev = "a13b0d425230661e1942484fcdfb5646abb4fddb"; + }; + theme = builtins.fetchurl { + url = + "https://raw.githubusercontent.com/ivabus/ivabus-zsh-theme/master/ivabus.zsh-theme"; + }; + highlighting = builtins.fetchGit { + url = "https://github.com/zsh-users/zsh-syntax-highlighting.git"; + # Just install the latest and don't care about updating + ref = "master"; + }; +in { + # Option to disable dotfiles for development + options.my.users.ivabus.dotfiles.enable = + lib.mkEnableOption "Enable automatic dotfiles installation"; + config.my.users.ivabus.dotfiles.enable = lib.mkDefault true; + config.home-manager = lib.mkIf + (config.my.users.ivabus.enable && config.my.users.ivabus.dotfiles.enable) ({ + users.ivabus = { + home.file = { + ".config" = { + source = "${dotfiles}/configs"; + recursive = true; + }; + ".config/zsh/themes/ivabus.zsh-theme" = { source = theme; }; + ".config/zsh/plugins/zsh-syntax-highlighting/" = { + source = highlighting; + recursive = true; + }; + ".profile" = { source = "${dotfiles}/configs/.profile"; }; + ".zshrc" = { source = "${dotfiles}/configs/.zshrc"; }; + }; + }; + }); +} diff --git a/common/git.nix b/common/git.nix index 72a8780..2cd6048 100644 --- a/common/git.nix +++ b/common/git.nix @@ -5,8 +5,6 @@ in { options = { my.git.enable = lib.mkEnableOption "Enable git configuration"; }; config = lib.mkIf (cfg.enable && config.my.users.ivabus.enable) { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; home-manager.users.ivabus = { programs.git = { enable = true; @@ -16,7 +14,6 @@ in { signing.signByDefault = true; package = pkgs.gitAndTools.gitFull; }; - home.stateVersion = "23.05"; }; }; } diff --git a/common/user.nix b/common/user.nix index ea13e42..9e7bbf9 100644 --- a/common/user.nix +++ b/common/user.nix @@ -34,6 +34,7 @@ in rec { hashedPassword = secrets.hashed-password; }; programs.gnupg.agent.enable = true; + home-manager.users.ivabus.home.stateVersion = "24.05"; }) (lib.mkIf (cfg.user.enable) { @@ -52,6 +53,7 @@ in rec { openssh.authorizedKeys.keys = keys; password = "12345"; }; + home-manager.users.user.home.stateVersion = "24.05"; }) ({ diff --git a/roles/media-client.nix b/roles/media-client.nix index 5517754..a93e03e 100644 --- a/roles/media-client.nix +++ b/roles/media-client.nix @@ -7,7 +7,7 @@ in { config = lib.mkIf (cfg.enable) { nixpkgs.overlays = [ (self: super: { - mpv = super.wrapMpv (super.mpv.unwrapped.override { + mpv = (super.wrapMpv (super.mpv.unwrapped.override { cddaSupport = true; # No pulse today pulseSupport = false; @@ -18,11 +18,24 @@ in { # Sway only waylandSupport = config.my.roles.graphical.enable; javascriptSupport = false; - }) { }; + }) { }).override { scripts = [ self.mpvScripts.mpris ]; }; }) ]; environment.systemPackages = with pkgs; [ vlc yt-dlp ffmpeg mpv ]; + # Setting up only for ivabus user, because user user will use Firefox or anything else to play videos + home-manager.users.ivabus = lib.mkIf (config.my.users.ivabus.enable) { + programs.mpv = { + enable = true; + config = { + profile = "gpu-hq"; + ytdl-format = "bestvideo+bestaudio"; + sub-font = "JetBrains Mono"; + sub-scale = "0.6"; + }; + }; + }; + # Add support for CD/DVD/BD drives boot.initrd.availableKernelModules = [ "sr_mod" ]; };