diff --git a/configuration.nix b/configuration.nix index de9300d5..71e25444 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,12 +1,4 @@ -{ config -, pkgs -, unstable -, lib -, home-manager -, username -, isDevMode ? false -, ownPackages -, ... +{ config, pkgs, unstable, lib, home-manager, isDevMode ? false, ownPackages, ... }: { # Nix configuration @@ -87,14 +79,12 @@ # Global packages environment = { systemPackages = with pkgs; [ vim htop direnv bash polkit_gnome ]; - variables = - let projectConfigDir = "/home/wittano/projects/config"; - in - { - EDITOR = "vim"; - DOTFILES = "${projectConfigDir}/dotfiles"; - NIX_DOTFILES = "${projectConfigDir}/nix-dotfiles"; - }; + variables = let projectConfigDir = "/home/wittano/projects/config"; + in { + EDITOR = "vim"; + DOTFILES = "${projectConfigDir}/dotfiles"; + NIX_DOTFILES = "${projectConfigDir}/nix-dotfiles"; + }; shells = with pkgs; [ bash ]; }; @@ -123,7 +113,7 @@ hardware.trackpoint.emulateWheel = true; #User settings - users.users."${username}" = { + users.users.wittano = { isNormalUser = true; extraGroups = [ "wheel" ]; }; diff --git a/flake.lock b/flake.lock index a793928f..eeef0a93 100644 --- a/flake.lock +++ b/flake.lock @@ -6,11 +6,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1704342238, - "narHash": "sha256-2d63iphcIcaQrQu9u0F3C4cDwpoHY+cFbVVhz0gROa8=", + "lastModified": 1705115634, + "narHash": "sha256-2OfahRpUHakXCg7R4pAYWXzcoec18DaQcJ2MCQlLpGs=", "owner": "ezKEa", "repo": "aagl-gtk-on-nix", - "rev": "3b5835a631d9957fc2427f12684835a2e31edf95", + "rev": "787d726b1fb52f0756de8b0bdaccddf04e3b600a", "type": "github" }, "original": { @@ -92,11 +92,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1705049510, - "narHash": "sha256-+r3i5b9QsQX5lew62aHvPWw9cf02Mzf/d0n4URhPBV8=", + "lastModified": 1705109607, + "narHash": "sha256-JCwZRYaef6io0R+SxDN9l2HnyqLSBRYIfaBk4uwjMqQ=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "fcd7c360c3f73ec91da70155df6d9a413e4bd128", + "rev": "9e423719e0c85a4624813489080636f4d696fa3e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 440e3fe2..56c51de6 100644 --- a/flake.nix +++ b/flake.nix @@ -20,40 +20,27 @@ }; }; - outputs = - { self - , nixpkgs - , home-manager - , ... - }@inputs: + outputs = { self, nixpkgs, home-manager, ... }@inputs: let system = "x86_64-linux"; lib = nixpkgs.lib.extend (sefl: super: { hm = home-manager.lib.hm; - my = import ./lib { - inherit lib system inputs; - }; + my = import ./lib { inherit lib system inputs; }; }); - in - { - nixosConfigurations = - let - inherit (lib.attrsets) mapAttrs' nameValuePair; - inherit (lib.my.hosts) mkHost; + in { + nixosConfigurations = let + inherit (lib.attrsets) mapAttrs' nameValuePair; + inherit (lib.my.hosts) mkHost; - hosts = builtins.readDir ./hosts; - devHosts = mapAttrs' - (n: v: - let devName = "${n}-dev"; - in - nameValuePair (devName) (mkHost { - name = devName; - isDevMode = true; - })) - hosts; - normalHosts = builtins.mapAttrs (n: v: mkHost { name = n; }) hosts; - in - normalHosts // devHosts; + hosts = builtins.readDir ./hosts; + devHosts = mapAttrs' (n: v: + let devName = "${n}-dev"; + in nameValuePair (devName) (mkHost { + name = devName; + isDevMode = true; + })) hosts; + normalHosts = builtins.mapAttrs (n: v: mkHost { name = n; }) hosts; + in normalHosts // devHosts; }; } diff --git a/home/pc/default.nix b/home/pc/default.nix index 54aa68ef..51b3e71c 100644 --- a/home/pc/default.nix +++ b/home/pc/default.nix @@ -26,8 +26,7 @@ let signal-desktop discord ]; -in -{ +in { home = { username = "wittano"; homeDirectory = "/home/wittano"; diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index 5237c886..31caa288 100644 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -1,43 +1,39 @@ -{ config, pkgs, isDevMode ? false, username ? "wittano", ... }: { +{ config, pkgs, isDevMode ? false, ... }: { imports = [ ./hardware.nix ./networking.nix ]; home-manager.users.wittano = ./../../home/pc; - modules = - let - enableWithDevMode = { + modules = let + enableWithDevMode = { + enable = true; + enableDevMode = isDevMode; + }; + in { + desktop = { qtile = enableWithDevMode; }; + editors.neovim.enable = true; + dev = { + goland.enable = true; + clion.enable = true; + }; + hardware = { + sound.enable = true; + grub.enable = true; + wifi.enable = true; + virtualization = { enable = true; - enableDevMode = isDevMode; - }; - in - { - desktop = { - qtile = enableWithDevMode; - }; - editors.neovim.enable = true; - dev = { - goland.enable = true; - clion.enable = true; + enableDocker = true; }; - hardware = { - sound.enable = true; - grub.enable = true; - wifi.enable = true; - virtualization = { - enable = true; - enableDocker = true; - }; - nvidia.enable = true; - }; - services = { - backup = { - enable = true; - backupDir = "/mnt/backup/wittano.nixos"; - }; - syncthing.enable = true; - redshift.enable = true; + nvidia.enable = true; + }; + services = { + backup = { + enable = true; + backupDir = "/mnt/backup/wittano.nixos"; }; + syncthing.enable = true; + redshift.enable = true; }; + }; } diff --git a/hosts/pc/configuration.nix b/hosts/pc/configuration.nix index 206a5424..456e28ad 100644 --- a/hosts/pc/configuration.nix +++ b/hosts/pc/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, isDevMode ? false, username ? "wittano", ... }: { +{ config, pkgs, isDevMode ? false, ... }: { imports = [ ./hardware.nix ./networking.nix ]; @@ -24,44 +24,42 @@ programs.droidcam.enable = true; - modules = - let - enableWithDevMode = { + modules = let + enableWithDevMode = { + enable = true; + enableDevMode = isDevMode; + }; + in { + desktop = { + qtile = enableWithDevMode; + gaming = { enable = true; - enableDevMode = isDevMode; - }; - in - { - desktop = { - qtile = enableWithDevMode; - gaming = { - enable = true; - enableAdditionalDisk = true; - enableMihoyoGames = true; - }; - }; - dev.jvm.enable = true; - editors.neovim.enable = true; - hardware = { - sound.enable = true; - grub.enable = true; - wacom.enable = true; - virtualization.enable = true; - nvidia.enable = true; - bluetooth.enable = true; + enableAdditionalDisk = true; + enableMihoyoGames = true; }; - services = { - boinc.enable = true; - backup = { - enable = true; - backupDir = "/mnt/backup/wittano.nixos"; - }; - ssh.enable = true; - syncthing.enable = true; - redshift.enable = true; - prometheus.enable = true; - filebot.enable = true; + }; + dev.jvm.enable = true; + editors.neovim.enable = true; + hardware = { + sound.enable = true; + grub.enable = true; + wacom.enable = true; + virtualization.enable = true; + nvidia.enable = true; + bluetooth.enable = true; + }; + services = { + boinc.enable = true; + backup = { + enable = true; + backupDir = "/mnt/backup/wittano.nixos"; }; + ssh.enable = true; + syncthing.enable = true; + redshift.enable = true; + prometheus.enable = true; + filebot.enable = true; }; + }; } diff --git a/hosts/pc/hardware.nix b/hosts/pc/hardware.nix index 8255cd8c..a40b0ad6 100644 --- a/hosts/pc/hardware.nix +++ b/hosts/pc/hardware.nix @@ -13,7 +13,5 @@ fsType = "ext4"; }; }; - swapDevices = [{ - device = "/dev/disk/by-label/SWAP"; - }]; + swapDevices = [{ device = "/dev/disk/by-label/SWAP"; }]; } diff --git a/hosts/pc/networking.nix b/hosts/pc/networking.nix index 8f37b0fe..b4d02a2a 100644 --- a/hosts/pc/networking.nix +++ b/hosts/pc/networking.nix @@ -1,10 +1,9 @@ { config, ... }: { - assertions = [ - { - assertion = !config.networking.networkmanager.enable; - message = "NetworkManager cannot be enable, causes problem with spotify interent connection"; - } - ]; + assertions = [{ + assertion = !config.networking.networkmanager.enable; + message = + "NetworkManager cannot be enable, causes problem with spotify interent connection"; + }]; networking = { diff --git a/hosts/vm/configuration.nix b/hosts/vm/configuration.nix index f3f6e17e..e6ac42bc 100644 --- a/hosts/vm/configuration.nix +++ b/hosts/vm/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, isDevMode ? false, username ? "wittano", ... }: { +{ config, pkgs, isDevMode ? false, ... }: { imports = [ ./hardware.nix ]; @@ -12,7 +12,7 @@ security.rtkit.enable = true; - users.users."${username}" = { + users.users.wittano = { isNormalUser = true; description = "virt"; extraGroups = [ "networkmanager" "wheel" ]; diff --git a/hosts/vm/hardware.nix b/hosts/vm/hardware.nix index 98f00c14..acd73250 100644 --- a/hosts/vm/hardware.nix +++ b/hosts/vm/hardware.nix @@ -1,14 +1,13 @@ -{ config, lib, modulesPath, username ? "wittano", ... }: { - imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; +{ config, lib, modulesPath, ... }: { + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; boot = { initrd.availableKernelModules = [ "virtio_pci" "virtio_blk" ]; loader.systemd-boot.enable = true; }; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; networking = { networkmanager.enable = true; @@ -27,7 +26,7 @@ # This mounting works only for KVM virtualization. # Before start VM, you have to add a Filesystem to your virutal machine. # I didn't test this configuration on other hypervisor like e.g. Virutalbox, so I don't know it's will be worked - "/home/${username}/projects/config/nix-dotfiles" = { + "/home/wittano/projects/config/nix-dotfiles" = { device = "/share"; fsType = "9p"; }; diff --git a/lib/apps.nix b/lib/apps.nix index dc4f8cac..db98e917 100644 --- a/lib/apps.nix +++ b/lib/apps.nix @@ -1,5 +1,15 @@ { lib, pkgs, dotfiles, home-manager, ownPackages, unstable, ... }: { - importApp = cfg: name: - import (./../modules/desktop/apps + "/${name}.nix") { inherit cfg pkgs lib dotfiles home-manager ownPackages unstable; }; + desktopApps = config: cfg: + let + sourceDir = ./../modules/desktop/apps; + appFiles = lib.attrsets.filterAttrs + (n: v: ((lib.strings.hasSuffix ".nix" n) && v == "regular")) + (builtins.readDir sourceDir); + in lib.attrsets.mapAttrs' (n: v: { + name = builtins.replaceStrings [ ".nix" ] [ "" ] n; + value = import "${sourceDir}/${n}" { + inherit cfg ownPackages pkgs dotfiles home-manager unstable config lib; + }; + }) appFiles; } diff --git a/lib/default.nix b/lib/default.nix index 5c147e18..841c3ae9 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,8 +1,4 @@ -{ lib -, system -, inputs -, ... -}: +{ lib, system, inputs, ... }: let ownPackages = inputs.wittano-repo.packages.x86_64-linux; mkPkgs = p: @@ -21,11 +17,14 @@ let dotfiles = mapper.mapDirToAttrs inputs.wittano-dotfiles; home-manager = inputs.home-manager; -in -{ +in { inherit mapper imports; - hosts = import ./hosts.nix { inherit lib system pkgs unstable dotfiles inputs ownPackages imports; }; + hosts = import ./hosts.nix { + inherit lib system pkgs unstable dotfiles inputs ownPackages imports; + }; link = import ./link.nix { inherit lib; }; - apps = import ./apps.nix { inherit lib home-manager pkgs dotfiles ownPackages unstable; }; + apps = import ./apps.nix { + inherit lib home-manager pkgs dotfiles ownPackages unstable; + }; } diff --git a/lib/hosts.nix b/lib/hosts.nix index e786a548..75e29527 100644 --- a/lib/hosts.nix +++ b/lib/hosts.nix @@ -1,28 +1,25 @@ { lib, system, pkgs, unstable, dotfiles, ownPackages, inputs, imports, ... }: { - mkHost = { name, isDevMode ? false, username ? "wittano" }: + mkHost = { name, isDevMode ? false }: inputs.nixpkgs.lib.nixosSystem rec { inherit system; specialArgs = { - inherit pkgs unstable lib dotfiles isDevMode username inputs ownPackages; - hostName = name; + inherit pkgs unstable lib dotfiles isDevMode inputs ownPackages; + hostname = name; # TODO Set option for other keys for diffrent hosts secretsFile = ./../secrets/syncthing.age; }; - modules = - let - hostName = builtins.replaceStrings [ "-dev" ] [ "" ] name; - in - [ - ./../configuration.nix - ./../hosts/${hostName}/configuration.nix + modules = let hostname = builtins.replaceStrings [ "-dev" ] [ "" ] name; + in [ + ./../configuration.nix + ./../hosts/${hostname}/configuration.nix - inputs.filebot.nixosModules."filebot" - inputs.agenix.nixosModules.default - inputs.nixvim.nixosModules.nixvim - inputs.aagl.nixosModules.default - inputs.home-manager.nixosModules.home-manager - ] ++ (imports.importModulesPath ./../modules); + inputs.filebot.nixosModules."filebot" + inputs.agenix.nixosModules.default + inputs.nixvim.nixosModules.nixvim + inputs.aagl.nixosModules.default + inputs.home-manager.nixosModules.home-manager + ] ++ (imports.importModulesPath ./../modules); }; } diff --git a/lib/imports.nix b/lib/imports.nix index 6be9595f..84f231ce 100644 --- a/lib/imports.nix +++ b/lib/imports.nix @@ -4,20 +4,13 @@ inherit (lib.strings) hasSuffix hasPrefix; importModulesPath = path: - let - ignoredDir = [ "apps" "utils" "plugins" ]; - in - builtins.filter (e: e != null) - (flatten (mapAttrsToList - (n: v: - let - newPath = "${path}/${n}"; - in - if v == "regular" - then - if hasSuffix "nix" newPath - then newPath - else null - else importModulesPath newPath) - (filterAttrs (n: _: all (x: x != n) ignoredDir) (builtins.readDir path)))); + let ignoredDir = [ "apps" "utils" "plugins" ]; + in builtins.filter (e: e != null) (flatten (mapAttrsToList (n: v: + let newPath = "${path}/${n}"; + in if v == "regular" then + if hasSuffix "nix" newPath then newPath else null + else + importModulesPath newPath) + (filterAttrs (n: _: all (x: x != n) ignoredDir) + (builtins.readDir path)))); } diff --git a/lib/link.nix b/lib/link.nix index 57721605..50eb2c0e 100644 --- a/lib/link.nix +++ b/lib/link.nix @@ -52,14 +52,21 @@ let unlink ${dest} || echo "Warning: File the path: ${dest}, cannot be removed" fi ''; -in { - createMutableLinkActivation = { internalPath, isDevMode ? false }: +in +{ + createMutableLinkActivation = cfg: path: let - src = "$DOTFILES/${internalPath}"; - dest = "$HOME/${internalPath}"; - activationScript = if isDevMode then createMutableLink src dest else removeMutableLink dest; + src = "$DOTFILES/${path}"; + dest = "$HOME/${path}"; + isDevMode = cfg ? enableDevMode && cfg.enableDevMode; + activationScript = + if isDevMode then + createMutableLink src dest + else + removeMutableLink dest; in - if isDevMode - then lib.hm.dag.entryAfter [ "writeBoundary" ] activationScript - else lib.hm.dag.entryBefore [ "checkFilesChanged" ] activationScript; + if isDevMode then + lib.hm.dag.entryAfter [ "writeBoundary" ] activationScript + else + lib.hm.dag.entryBefore [ "checkFilesChanged" ] activationScript; } diff --git a/lib/mapper.nix b/lib/mapper.nix index dc819307..344dde8c 100644 --- a/lib/mapper.nix +++ b/lib/mapper.nix @@ -1,13 +1,14 @@ { lib }: rec { inherit (lib.attrsets) filterAttrs; - mapDirToAttrs = path: builtins.mapAttrs - (n: v: + mapDirToAttrs = path: + builtins.mapAttrs (n: v: let newPath = "${path}/${n}"; sourceAttrs = { source = newPath; }; - in - if v == "regular" - then sourceAttrs - else sourceAttrs // mapDirToAttrs newPath ) (filterAttrs (n: v: n != ".git") (builtins.readDir path)); + in if v == "regular" then + sourceAttrs + else + sourceAttrs // mapDirToAttrs newPath) + (filterAttrs (n: v: n != ".git") (builtins.readDir path)); } diff --git a/modules/agenix.nix b/modules/agenix.nix index e27aaede..103a3635 100644 --- a/modules/agenix.nix +++ b/modules/agenix.nix @@ -1,10 +1,8 @@ { config, lib, secretsFile, inputs, ... }: with lib; with lib.my; -let - privateKeyPath = "/home/wittano/.ssh/syncthing"; -in -{ +let privateKeyPath = "/home/wittano/.ssh/syncthing"; +in { environment.systemPackages = [ inputs.agenix.packages.x86_64-linux.default ]; age = mkIf (config.modules.services.syncthing.enable) { diff --git a/modules/desktop/apps/alacritty.nix b/modules/desktop/apps/alacritty.nix index ccdd1cc6..fab91254 100644 --- a/modules/desktop/apps/alacritty.nix +++ b/modules/desktop/apps/alacritty.nix @@ -9,8 +9,7 @@ let sha256 = "sha256-bpHznCqkNMbauDQjh98qj2+r1V8mXQIVmvKTldLcln0="; }); colorTheme = theme: (catppuccinTheme."catppuccin-${theme}.toml".source); -in -{ +in { fonts.packages = with pkgs; [ jetbrains-mono ]; home-manager.users.wittano.programs.alacritty = { @@ -60,7 +59,7 @@ in mouse = "Middle"; }]; }; - selection."semantic_escape_chars" = ",|`|:\"' (){}[]<>"; + selection."semantic_escape_chars" = '',|`|:"' (){}[]<>''; }; }; } diff --git a/modules/desktop/apps/dunst.nix b/modules/desktop/apps/dunst.nix index 742220bb..492c530c 100644 --- a/modules/desktop/apps/dunst.nix +++ b/modules/desktop/apps/dunst.nix @@ -9,8 +9,7 @@ let rev = "b0b838d38f134136322ad3df2b6dc57c4ca118cf"; sha256 = "sha256-ruFcHh1dkd4Zy9qNlAA8qAksTzNjXPd2hSSmhdGgflU="; }); -in -{ +in { home-manager.users.wittano.services.dunst = { enable = true; configFile = catppuccinDunstConfig.src."macchiato.conf".source; diff --git a/modules/desktop/apps/gtk.nix b/modules/desktop/apps/gtk.nix index 4af79dbd..d7f39ea2 100644 --- a/modules/desktop/apps/gtk.nix +++ b/modules/desktop/apps/gtk.nix @@ -6,16 +6,16 @@ let schemeVariants = [ "all" ]; colorVariants = [ "all" ]; }; -in -{ +in { home-manager.users.wittano = { home = { - packages = with pkgs; [ lxappearance colloidIconTheme ownPackages.bibata-cursor-theme ]; + packages = with pkgs; [ + lxappearance + colloidIconTheme + ownPackages.bibata-cursor-theme + ]; activation.linkMutableGtkConfig = - link.createMutableLinkActivation { - internalPath = ".config/gtk-3.0/settings.ini"; - isDevMode = cfg.enableDevMode; - }; + link.createMutableLinkActivation cfg ".config/gtk-3.0/settings.ini"; }; xdg.configFile = mkIf (cfg.enableDevMode == false) { diff --git a/modules/desktop/apps/kitty.nix b/modules/desktop/apps/kitty.nix index c3b5c712..d232617a 100644 --- a/modules/desktop/apps/kitty.nix +++ b/modules/desktop/apps/kitty.nix @@ -1,15 +1,11 @@ { pkgs, home-manager, lib, dotfiles, cfg, ... }: with lib; -with lib.my; -{ +with lib.my; { home-manager.users.wittano = { home = { packages = with pkgs; [ kitty ]; activation.linkMutableKittyConfig = - link.createMutableLinkActivation { - internalPath = ".config/kitty"; - isDevMode = cfg.enableDevMode; - }; + link.createMutableLinkActivation cfg ".config/kitty"; }; programs.fish.shellAliases.ssh = "kitty +kitten ssh"; diff --git a/modules/desktop/apps/nitrogen.nix b/modules/desktop/apps/nitrogen.nix index 28263736..71122198 100644 --- a/modules/desktop/apps/nitrogen.nix +++ b/modules/desktop/apps/nitrogen.nix @@ -1,22 +1,11 @@ { pkgs, lib, home-manager, dotfiles, cfg, ... }: with lib; -with lib.my; -{ +with lib.my; { home-manager.users.wittano = { home = { packages = with pkgs; [ nitrogen ]; - - activation = - let - customeActivation = path: - link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; - in - { - linkMutableNitrogen = customeActivation ".config/nitrogen"; - }; + activation.linkMutableNitrogen = + link.createMutableLinkActivation cfg ".config/nitrogen"; }; xdg.configFile = mkIf (cfg.enableDevMode == false) { diff --git a/modules/desktop/apps/picom.nix b/modules/desktop/apps/picom.nix index f6605a21..197173f6 100644 --- a/modules/desktop/apps/picom.nix +++ b/modules/desktop/apps/picom.nix @@ -1,27 +1,14 @@ { pkgs, lib, cfg, dotfiles, ... }: with lib; -with lib.my; -{ +with lib.my; { home-manager.users.wittano = { - home = { - activation = - let - customeActivation = path: - link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; - in - { - linkMutablePicomConfig = customeActivation ".config/picom"; - }; - }; + home.activation.linkMutablePicomConfig = + link.createMutableLinkActivation cfg ".config/picom"; - xdg.configFile = - let configDir = dotfiles.".config"; - in mkIf (cfg.enableDevMode == false) { - picom.source = configDir.picom.source; - }; + xdg.configFile = let configDir = dotfiles.".config"; + in mkIf (cfg.enableDevMode == false) { + picom.source = configDir.picom.source; + }; systemd.user.services.picom = { Unit = { @@ -36,9 +23,7 @@ with lib.my; ''; Restart = "on-failure"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/modules/desktop/apps/postman.nix b/modules/desktop/apps/postman.nix index 3043b675..beeedaf8 100644 --- a/modules/desktop/apps/postman.nix +++ b/modules/desktop/apps/postman.nix @@ -1,4 +1,3 @@ -{ pkgs, home-manager, ... }: -{ +{ pkgs, home-manager, ... }: { home-manager.users.wittano.home.packages = with pkgs; [ postman ]; } diff --git a/modules/desktop/apps/ranger.nix b/modules/desktop/apps/ranger.nix index 9ac38110..bce6e74e 100644 --- a/modules/desktop/apps/ranger.nix +++ b/modules/desktop/apps/ranger.nix @@ -1,14 +1,15 @@ { cfg, pkgs, lib, home-manager, dotfiles, ... }: with lib; -with lib.my; -{ +with lib.my; { home-manager.users.wittano = { home = { packages = with pkgs; [ ranger ]; # It's required cause ranger doesn't allow non-writeable config (27.12.2023) activation.copyRangerConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - ${pkgs.coreutils}/bin/cp -r ${dotfiles.".config".ranger.source} /home/wittano/.config + ${pkgs.coreutils}/bin/cp -r ${ + dotfiles.".config".ranger.source + } /home/wittano/.config ${pkgs.coreutils}/bin/chmod -R 755 /home/wittano/.config/ranger ''; diff --git a/modules/desktop/apps/rofi.nix b/modules/desktop/apps/rofi.nix index 70d07584..86949325 100644 --- a/modules/desktop/apps/rofi.nix +++ b/modules/desktop/apps/rofi.nix @@ -14,12 +14,10 @@ in { packages = with pkgs; [ rofi ]; activation.linkMutableRofiConfig = - link.createMutableLinkActivation { - internalPath = ".config/rofi"; - isDevMode = cfg.enableDevMode; - }; + link.createMutableLinkActivation cfg ".config/rofi"; - file.".local/share/rofi/themes".source = builtins.toPath "${catpuccinTheme}/basic/.local/share/rofi/themes"; + file.".local/share/rofi/themes".source = + builtins.toPath "${catpuccinTheme}/basic/.local/share/rofi/themes"; }; xdg.configFile = mkIf (cfg.enableDevMode == false) { diff --git a/modules/desktop/apps/switchOff.nix b/modules/desktop/apps/switchOff.nix new file mode 100644 index 00000000..92bba07d --- /dev/null +++ b/modules/desktop/apps/switchOff.nix @@ -0,0 +1,35 @@ +{ pkgs, lib, config, ... }: +let + kill = "${pkgs.toybox}/bin/kill"; + pgrep = "${pkgs.toybox}/bin/pgrep"; + program = pkgs.writeScriptBin "switch-off" /*bash*/ + '' + #!/usr/bin/env bash + + SHUTDOWN="Shutdown" + LOGOUT="Logout" + REBOOT="Reboot" + + CHOICE=$(${pkgs.toybox}/bin/printf "%s\n%s\n%s" $SHUTDOWN $LOGOUT $REBOOT | ${pkgs.rofi}/bin/rofi -dmenu) + + case $CHOICE in + "$SHUTDOWN") + ${pkgs.systemd}/bin/poweroff + ;; + "$LOGOUT") + QTILE=$(${pgrep} qtile) + BSPWM=$(${pgrep} bspwm) + ${kill} -9 "$QTILE" + ${kill} -9 "$BSPWM" + ;; + "$REBOOT") + ${pkgs.systemd}/bin/reboot + ;; + "*") + exit 1 + ;; + esac + ''; +in +{ home-manager.users.wittano.home.packages = [ program ]; } + diff --git a/modules/desktop/apps/tmux.nix b/modules/desktop/apps/tmux.nix index 79607660..4b3cb070 100644 --- a/modules/desktop/apps/tmux.nix +++ b/modules/desktop/apps/tmux.nix @@ -1,7 +1,6 @@ { cfg, pkgs, lib, home-manager, dotfiles, ... }: with lib; -with lib.my; -{ +with lib.my; { home-manager.users.wittano.programs = { fzf = { enable = true; @@ -24,7 +23,13 @@ with lib.my; enable = true; mouse = true; newSession = false; - plugins = with pkgs.tmuxPlugins; [ tmux-fzf catppuccin sensible vim-tmux-navigator yank ]; + plugins = with pkgs.tmuxPlugins; [ + tmux-fzf + catppuccin + sensible + vim-tmux-navigator + yank + ]; shell = "${pkgs.fish}/bin/fish"; resizeAmount = 3; prefix = "C-Space"; diff --git a/modules/desktop/apps/zeal.nix b/modules/desktop/apps/zeal.nix index 2ad8dea9..1127d2f2 100644 --- a/modules/desktop/apps/zeal.nix +++ b/modules/desktop/apps/zeal.nix @@ -1,4 +1,3 @@ -{ pkgs, home-manager, ... }: -{ +{ pkgs, home-manager, ... }: { home-manager.users.wittano.home.packages = with pkgs; [ zeal ]; } diff --git a/modules/desktop/bspwm.nix b/modules/desktop/bspwm.nix index 8cd7612b..43256f04 100644 --- a/modules/desktop/bspwm.nix +++ b/modules/desktop/bspwm.nix @@ -3,18 +3,8 @@ with lib; with lib.my; let cfg = config.modules.desktop.bspwm; - importApp = name: - apps.importApp cfg name; - - nitrogenConfig = importApp "nitrogen"; - alacrittyConfig = importApp "alacritty"; - rofiConfig = importApp "rofi"; - tmuxConfig = importApp "tmux"; - picomConfig = importApp "picom"; - gtkConfig = importApp "gtk"; - switchOffScript = pkgs.callPackage ./utils/switch-off.nix { }; -in -{ + desktopApps = apps.desktopApps config cfg; +in { options.modules.desktop.bspwm = { enable = mkEnableOption "Enable BSPWM desktop"; @@ -24,52 +14,42 @@ in ''; }; - config = mkIf cfg.enable (mkMerge [ - rofiConfig - picomConfig - gtkConfig - alacrittyConfig - tmuxConfig - nitrogenConfig + config = mkIf cfg.enable (mkMerge (with desktopApps; [ + nitrogen + picom + gtk + alacritty + tmux + dunst + rofi + switchOff { + fonts.packages = with pkgs; [ font-awesome font-awesome_5 siji ]; + home-manager.users.wittano = { home = { packages = with pkgs; [ - polybar + polybar # TODO export polybar config to apps gsimplecal - notify-osd-customizable - notify-desktop wmname - rofi - - font-awesome - font-awesome_5 - siji - switchOffScript ]; - activation = - let - customeActivation = path: - link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; - in - { - linkMutableBspwmConfig = customeActivation ".config/bspwm"; - linkMutableSxhkdConfig = customeActivation ".config/sxhkd"; - linkMutablePolybarConfig = customeActivation ".config/polybar"; - }; + activation = { + linkMutableBspwmConfig = + link.createMutableLinkActivation cfg ".config/bspwm"; + linkMutableSxhkdConfig = + link.createMutableLinkActivation cfg ".config/sxhkd"; + linkMutablePolybarConfig = + link.createMutableLinkActivation cfg ".config/polybar"; + }; }; - xdg.configFile = - let configDir = dotfiles.".config"; - in mkIf (cfg.enableDevMode == false) { - bspwm.source = configDir.bspwm.source; - sxhkd.source = configDir.sxhkd.source; - polybar.source = configDir.polybar.source; - }; + xdg.configFile = let configDir = dotfiles.".config"; + in mkIf (cfg.enableDevMode == false) { + bspwm.source = configDir.bspwm.source; + sxhkd.source = configDir.sxhkd.source; + polybar.source = configDir.polybar.source; + }; }; services = { @@ -79,6 +59,6 @@ in }; }; } - ]); + ])); } diff --git a/modules/desktop/gaming/gaming.nix b/modules/desktop/gaming/gaming.nix index c5a9470b..a327dd85 100644 --- a/modules/desktop/gaming/gaming.nix +++ b/modules/desktop/gaming/gaming.nix @@ -1,9 +1,7 @@ { config, pkgs, home-manager, lib, inputs, ... }: with lib; -let - cfg = config.modules.desktop.gaming; -in -{ +let cfg = config.modules.desktop.gaming; +in { options = { modules.desktop.gaming = { enable = mkEnableOption '' @@ -27,25 +25,24 @@ in # Honkai Railway programs.honkers-railway-launcher.enable = cfg.enableMihoyoGames; - home-manager.users.wittano.home.packages = - with pkgs; [ - # Lutris - lutris - xdelta - xterm - gnome.zenity + home-manager.users.wittano.home.packages = with pkgs; [ + # Lutris + lutris + xdelta + xterm + gnome.zenity - # Wine - bottles - wineWowPackages.full + # Wine + bottles + wineWowPackages.full - # FSH - steam-run + # FSH + steam-run - # Games - prismlauncher - xivlauncher - ]; + # Games + prismlauncher + xivlauncher + ]; boot.kernelPackages = pkgs.linuxKernel.packages.linux_xanmod_stable; @@ -58,9 +55,9 @@ in }; }; - home-manager.users.wittano.programs.fish.shellAliases = - let - fixAge2SyncScript = pkgs.writeScriptBin "fixAge2Sync.sh" /*bash*/ '' + home-manager.users.wittano.programs.fish.shellAliases = let + fixAge2SyncScript = pkgs.writeScriptBin "fixAge2Sync.sh" # bash + '' cd /mnt/gaming/SteamLibrary/steamapps/compatdata/813780/pfx/drive_c/windows/system32 if [ ! -e "vc_redist.x64.exe" ]; then @@ -70,11 +67,11 @@ in sudo ${pkgs.cabextract}/bin/cabextract vc_redist.x64.exe sudo ${pkgs.cabextract}/bin/cabextract a10 ''; - in - { - fixSteamSystemTray = "rm -rf ~/.local/share/Steam/ubuntu12_32/steam-runtime/pinned_libs_{32,64}"; - fixAge2Sync = "${pkgs.bash}/bin/bash ${fixAge2SyncScript}"; - }; + in { + fixSteamSystemTray = + "rm -rf ~/.local/share/Steam/ubuntu12_32/steam-runtime/pinned_libs_{32,64}"; + fixAge2Sync = "${pkgs.bash}/bin/bash ${fixAge2SyncScript}"; + }; }; } diff --git a/modules/desktop/hyprland.nix b/modules/desktop/hyprland.nix index abb7971a..4e43f165 100644 --- a/modules/desktop/hyprland.nix +++ b/modules/desktop/hyprland.nix @@ -1,10 +1,8 @@ { config, pkgs, lib, dotfiles, unstable, ... }: with lib; with lib.my; -let - cfg = config.modules.desktop.hyprland; -in -{ +let cfg = config.modules.desktop.hyprland; +in { options.modules.desktop.hyprland = { enable = mkEnableOption "Enable Hyperland(Wayland) desktop"; enableDevMode = mkEnableOption '' diff --git a/modules/desktop/openbox.nix b/modules/desktop/openbox.nix index b245a712..0a4026ed 100644 --- a/modules/desktop/openbox.nix +++ b/modules/desktop/openbox.nix @@ -3,14 +3,7 @@ with lib; with lib.my; let cfg = config.modules.desktop.openbox; - - importApp = name: apps.importApp cfg name; - - nitrogenConfig = importApp "nitrogen"; - terminalConfig = importApp "alacritty"; - rofiConfig = importApp "rofi"; - gtkConfig = importApp "gtk"; - xautolockConfig = importApp "xautolock"; + desktopApps = apps.desktopApps config cfg; in { options.modules.desktop.openbox = { @@ -21,12 +14,13 @@ in { ''; }; - config = mkIf cfg.enable (mkMerge [ - nitrogenConfig - terminalConfig - xautolockConfig - gtkConfig - rofiConfig + config = mkIf cfg.enable (mkMerge (with desktopApps; [ + nitrogen + alacritty + rofi + gtk + xautolock + dunst { home-manager.users.wittano = { home = { @@ -37,23 +31,16 @@ in { tint2 volumeicon gsimplecal - notify-osd-customizable - picom-jonaburg # Utils arandr ]; - activation = let - customeActivation = path: - link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; - in { - linkMutableOpenboxConfig = customeActivation ".config/openbox"; - linkMutableTint2Config = customeActivation ".config/tint2"; - linkMutablePicomConfig = customeActivation ".config/picom"; + activation = { + linkMutableOpenboxConfig = + link.createMutableLinkActivation cfg ".config/openbox"; + linkMutableTint2Config = + link.createMutableLinkActivation cfg ".config/tint2"; }; }; @@ -61,7 +48,6 @@ in { in mkIf (cfg.enableDevMode == false) { openbox.source = configDir.openbox.source; tint2.source = configDir.tint2.source; - picom.source = configDir.picom.source; }; }; @@ -72,6 +58,6 @@ in { windowManager.openbox.enable = true; }; } - ]); + ])); } diff --git a/modules/desktop/qtile.nix b/modules/desktop/qtile.nix index e0a5e9c3..331b1d5a 100644 --- a/modules/desktop/qtile.nix +++ b/modules/desktop/qtile.nix @@ -1,22 +1,10 @@ -{ config, pkgs, lib, dotfiles, unstable, username ? "wittano", ownPackages, ... }: +{ config, pkgs, lib, dotfiles, unstable, ownPackages, ... }: with lib; with lib.my; let cfg = config.modules.desktop.qtile; - importApp = name: - apps.importApp cfg name; - - nitrogenConfig = importApp "nitrogen"; - terminalConfig = importApp "kitty"; - rofiConfig = importApp "rofi"; - picomConfig = importApp "picom"; - tmuxConfig = importApp "tmux"; - gtkConfig = importApp "gtk"; - dunstConfig = importApp "dunst"; - rangerConfig = importApp "ranger"; -in -{ - + desktopApps = apps.desktopApps config cfg; +in { options.modules.desktop.qtile = { enable = mkEnableOption "Enable Qtile desktop"; enableDevMode = mkEnableOption '' @@ -25,47 +13,24 @@ in ''; }; - config = mkIf (cfg.enable) (mkMerge [ - rofiConfig - rangerConfig - terminalConfig - tmuxConfig - picomConfig - dunstConfig - gtkConfig - nitrogenConfig + config = mkIf (cfg.enable) (mkMerge (with desktopApps; [ + nitrogen + gtk + dunst + ranger + picom + tmux + kitty + rofi + switchOff { - home-manager.users."${username}" = { - home = { - packages = - let - switchOff = pkgs.callPackage ./utils/switch-off.nix { }; - in - with pkgs; [ - # Utils - switchOff - ]; + home-manager.users.wittano = { + home.activation.linkMutableQtileConfig = + link.createMutableLinkActivation cfg ".config/qtile"; - activation = - let - customeActivation = path: - link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; - in - { - linkMutableQtileConfig = customeActivation ".config/qtile"; - }; + xdg.configFile = mkIf (cfg.enableDevMode == false) { + qtile.source = dotfiles.".config".qtile.source; }; - - xdg.configFile = - let configDir = dotfiles.".config"; - in - mkIf (cfg.enableDevMode == false) { - qtile.source = configDir.qtile.source; - }; - }; services.xserver = { @@ -74,6 +39,6 @@ in windowManager.qtile.enable = true; }; } - ]); + ])); } diff --git a/modules/desktop/sddm.nix b/modules/desktop/sddm.nix index 4d14c4e2..2a405167 100644 --- a/modules/desktop/sddm.nix +++ b/modules/desktop/sddm.nix @@ -1,10 +1,8 @@ { config, pkgs, lib, ownPackages, ... }: with lib; with lib.my; -let - cfg = config.modules.desktop.sddm; -in -{ +let cfg = config.modules.desktop.sddm; +in { options.modules.desktop.sddm = { enable = mkEnableOption "Enable SDDM as display manager"; diff --git a/modules/desktop/utils/scripts/switch-off.sh b/modules/desktop/utils/scripts/switch-off.sh deleted file mode 100644 index 866f0111..00000000 --- a/modules/desktop/utils/scripts/switch-off.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -SHUTDOWN="Shutdown" -LOGOUT="Logout" -REBOOT="Reboot" - -CHOICE=$(printf "%s\n%s\n%s" $SHUTDOWN $LOGOUT $REBOOT | rofi -dmenu) - -case $CHOICE in -"$SHUTDOWN") - poweroff - ;; -"$LOGOUT") - QTILE=$(pgrep qtile) - BSPWM=$(pgrep bspwm) - kill -9 "$QTILE" - kill -9 "$BSPWM" - ;; -"$REBOOT") - reboot - ;; -"*") - echo "Unexpected option!" - exit 1 - ;; -esac \ No newline at end of file diff --git a/modules/desktop/utils/switch-off.nix b/modules/desktop/utils/switch-off.nix deleted file mode 100644 index bdf8eae1..00000000 --- a/modules/desktop/utils/switch-off.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ lib, stdenv, pkgs }: stdenv.mkDerivation rec { - name = "switch-off"; - - src = ./scripts; - - outputs = [ "out" ]; - - buildInputs = with pkgs; [ bash rofi ]; - - installPhase = '' - mkdir -p $out/bin - - cp ./switch-off.sh $out/bin/switch-off - - chmod +x $out/bin/switch-off - ''; - - meta = with lib; { - description = "Bash script to turn off Qtile desktop"; - maintainers = with maintainers; [ Wittano ]; - platforms = platforms.linux; - }; -} diff --git a/modules/dev/dotnet.nix b/modules/dev/dotnet.nix index 09c7f255..eab9045f 100644 --- a/modules/dev/dotnet.nix +++ b/modules/dev/dotnet.nix @@ -14,11 +14,7 @@ in { environment.variables.DOTNET_CLI_TELEMETRY_OPTOUT = "0"; home-manager.users.wittano = { - home.packages = with pkgs; [ - dotnet-sdk - mono - jetbrains.rider - ]; + home.packages = with pkgs; [ dotnet-sdk mono jetbrains.rider ]; programs.fish.shellAliases = mkIf (config.modules.shell.fish.enable) { pdotnet = "cd $HOME/projects/own/dotnet"; diff --git a/modules/dev/git.nix b/modules/dev/git.nix index 78e71363..4a3d3ab4 100644 --- a/modules/dev/git.nix +++ b/modules/dev/git.nix @@ -1,8 +1,7 @@ { config, pkgs, home-manager, lib, ... }: with lib; let cfg = config.modules.dev.git; -in -{ +in { options = { modules.dev.git = { enable = mkOption { diff --git a/modules/dev/go.nix b/modules/dev/go.nix index bea72b5b..f0ac1eb5 100644 --- a/modules/dev/go.nix +++ b/modules/dev/go.nix @@ -1,8 +1,7 @@ { config, pkgs, lib, home-manager, ... }: with lib; let cfg = config.modules.dev.goland; -in -{ +in { options = { modules.dev.goland = { enable = mkEnableOption '' @@ -16,7 +15,8 @@ in home.packages = mkIf cfg.enable (with pkgs; [ jetbrains.goland ]); programs.fish.shellAliases = mkIf (config.modules.shell.fish.enable) { pgo = "cd $HOME/projects/own/go"; - tempgo = "${pkgs.nixFlakes}/bin/nix flake init --template github:Wittano/nix-template#go"; + tempgo = + "${pkgs.nixFlakes}/bin/nix flake init --template github:Wittano/nix-template#go"; }; }; }; diff --git a/modules/dev/jvm.nix b/modules/dev/jvm.nix index 6bf74501..9efeaf46 100644 --- a/modules/dev/jvm.nix +++ b/modules/dev/jvm.nix @@ -1,10 +1,9 @@ -{ config, pkgs, lib, home-manager, username, ... }: +{ config, pkgs, lib, home-manager, ... }: let inherit (lib) mkEnableOption mkIf; cfg = config.modules.dev.jvm; -in -{ +in { options = { modules.dev.jvm = { enable = mkEnableOption '' @@ -18,7 +17,9 @@ in config = mkIf cfg.enable { home-manager.users.wittano = { - home.packages = with pkgs; [ jetbrains.idea-ultimate ] ++ (if cfg.enableAndroid then [ andorid-studio ] else [ ]); + home.packages = with pkgs; + [ jetbrains.idea-ultimate ] + ++ (if cfg.enableAndroid then [ andorid-studio ] else [ ]); programs.fish.shellAliases = mkIf (config.modules.shell.fish.enable) { pjvm = "cd $HOME/projects/own/jvm"; diff --git a/modules/dev/python.nix b/modules/dev/python.nix index a776ebc5..46683e77 100644 --- a/modules/dev/python.nix +++ b/modules/dev/python.nix @@ -1,8 +1,7 @@ { config, pkgs, lib, home-manager, unstable, ... }: with lib; let cfg = config.modules.dev.pycharm; -in -{ +in { options = { modules.dev.pycharm = { enable = mkEnableOption '' @@ -13,16 +12,13 @@ in config = { home-manager.users.wittano = { - home.packages = mkIf cfg.enable (with pkgs; [ - python3 - pipenv - poetry - jetbrains.pycharm-professional - ]); + home.packages = mkIf cfg.enable + (with pkgs; [ python3 pipenv poetry jetbrains.pycharm-professional ]); programs.fish.shellAliases = mkIf (config.modules.shell.fish.enable) { ppython = "cd $HOME/projects/own/python"; - temppy = "${pkgs.nixFlakes}/bin/nix flake init --template github:nix-community/poetry2nix"; + temppy = + "${pkgs.nixFlakes}/bin/nix flake init --template github:nix-community/poetry2nix"; }; }; }; diff --git a/modules/editors/emacs.nix b/modules/editors/emacs.nix index 22e2c281..a2338606 100644 --- a/modules/editors/emacs.nix +++ b/modules/editors/emacs.nix @@ -1,20 +1,16 @@ { config, pkgs, lib, home-manager, dotfiles, inputs, ... }: +with lib; +with lib.my; let inherit (lib) mkEnableOption mkOption mkIf types; cfg = config.modules.editors.emacs; - customeActivation = path: - lib.my.link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; downloadDoomEmacsScript = '' if [ ! -e $HOME/.emacs.d/bin/doom ]; then ${pkgs.git}/bin/git clone https://github.com/hlissner/doom-emacs ~/.emacs.d fi ''; -in -{ +in { options = { modules.editors.emacs = { enable = mkEnableOption '' @@ -45,8 +41,8 @@ in mkIf (cfg.version == "doom") (with pkgs; [ git ripgrep coreutils ]); activation = { - linkMutableDoomEmacsConfiguration = - mkIf (cfg.version == "doom") (customeActivation ".doom.d"); + linkMutableDoomEmacsConfiguration = mkIf (cfg.version == "doom") + (link.createMutableLinkActivation cfg ".doom.d"); downloadDoomEmacs = mkIf (cfg.version == "doom") (lib.hm.dag.entryAfter [ "writeBoundery" ] downloadDoomEmacsScript); }; diff --git a/modules/editors/neovim.nix b/modules/editors/neovim.nix index 98d96928..29dc8480 100644 --- a/modules/editors/neovim.nix +++ b/modules/editors/neovim.nix @@ -3,8 +3,7 @@ let inherit (lib) mkEnableOption mkIf; cfg = config.modules.editors.neovim; -in -{ +in { options = { modules.editors.neovim = { enable = mkEnableOption '' @@ -16,104 +15,97 @@ in config = mkIf cfg.enable { home-manager.users.wittano.home.packages = with pkgs; [ ripgrep ]; - programs.nixvim = - let - nixvimLib = inputs.nixvim.lib.x86_64-linux; + programs.nixvim = let + nixvimLib = inputs.nixvim.lib.x86_64-linux; - pluginBuilds = builtins.map (x: pkgs.callPackage (./plugins + "/${x}.nix") { }) - [ - "template.nvim" - "nvim-comment" - "gopher.nvim" - ]; - plugins = - let - deps = lib.lists.flatten (builtins.map (x: x.deps) pluginBuilds); - in - (builtins.map (x: x.plugin) pluginBuilds) ++ deps; - luaConfigs = builtins.concatStringsSep "\n\n" (builtins.map (x: x.luaConfig) pluginBuilds); - in - { - enable = true; - enableMan = true; - - extraPlugins = with pkgs.vimPlugins; [ - vim-wakatime - vimsence - ] ++ plugins; - - extraConfigLua = /*lua*/ '' + pluginBuilds = + builtins.map (x: pkgs.callPackage (./plugins + "/${x}.nix") { }) [ + "template.nvim" + "nvim-comment" + "gopher.nvim" + ]; + plugins = + let deps = lib.lists.flatten (builtins.map (x: x.deps) pluginBuilds); + in (builtins.map (x: x.plugin) pluginBuilds) ++ deps; + luaConfigs = builtins.concatStringsSep "\n\n" + (builtins.map (x: x.luaConfig) pluginBuilds); + in { + enable = true; + enableMan = true; + + extraPlugins = with pkgs.vimPlugins; [ vim-wakatime vimsence ] ++ plugins; + + extraConfigLua = # lua + '' -- nvim-autopairs require("nvim-autopairs").setup() ${luaConfigs} ''; - globals.mapleader = " "; - - options = { - number = true; - relativenumber = true; - swapfile = false; - wrap = true; - smartindent = true; - tabstop = 4; - softtabstop = 4; - shiftwidth = 4; - expandtab = true; - - hlsearch = true; - incsearch = true; - }; + globals.mapleader = " "; + + options = { + number = true; + relativenumber = true; + swapfile = false; + wrap = true; + smartindent = true; + tabstop = 4; + softtabstop = 4; + shiftwidth = 4; + expandtab = true; + + hlsearch = true; + incsearch = true; + }; - colorschemes = { - catppuccin = - let - theme = "macchiato"; - in - { - enable = true; - terminalColors = true; - background = { - dark = theme; - light = theme; - }; - styles = { - comments = [ "italic" ]; - functions = [ "italic" ]; - }; - flavour = theme; - integrations = { - native_lsp.enabled = true; - telescope.enabled = true; - dap = { - enable_ui = true; - enabled = true; - }; - }; + colorschemes = { + catppuccin = let theme = "macchiato"; + in { + enable = true; + terminalColors = true; + background = { + dark = theme; + light = theme; + }; + styles = { + comments = [ "italic" ]; + functions = [ "italic" ]; + }; + flavour = theme; + integrations = { + native_lsp.enabled = true; + telescope.enabled = true; + dap = { + enable_ui = true; + enabled = true; }; + }; }; + }; - plugins = { - treesitter.enable = true; + plugins = { + treesitter.enable = true; - undotree = { - autoOpenDiff = true; - focusOnToggle = true; - enable = true; - }; + undotree = { + autoOpenDiff = true; + focusOnToggle = true; + enable = true; + }; - dap = { - enable = true; - extensions = { - dap-go = { - enable = true; - dapConfigurations = [{ - name = "Debug with Arguments from DEBUG_ARGS env"; - request = "launch"; - type = "go"; - program = "\${file}"; - args = nixvimLib.helpers.mkRaw /*lua*/ '' + dap = { + enable = true; + extensions = { + dap-go = { + enable = true; + dapConfigurations = [{ + name = "Debug with Arguments from DEBUG_ARGS env"; + request = "launch"; + type = "go"; + program = "\${file}"; + args = nixvimLib.helpers.mkRaw # lua + '' function() return coroutine.create(function(dap_run_co) local args = vim.split(os.getenv("DEBUG_ARGS") or "", " ") @@ -121,60 +113,62 @@ in end) end ''; - }]; - delve.path = "${pkgs.delve}/bin/dlv"; - }; - dap-python = { - enable = true; - adapterPythonPath = "${pkgs.python3}/bin/python"; - }; - dap-ui.enable = true; - dap-virtual-text.enable = true; + }]; + delve.path = "${pkgs.delve}/bin/dlv"; + }; + dap-python = { + enable = true; + adapterPythonPath = "${pkgs.python3}/bin/python"; }; + dap-ui.enable = true; + dap-virtual-text.enable = true; }; + }; - lsp = { - enable = true; - capabilities = /*lua*/ "require('cmp_nvim_lsp').default_capabilities()"; - keymaps = { - diagnostic = { - "j" = "goto_next"; - "k" = "goto_prev"; - }; - lspBuf = { - K = "hover"; - gD = "references"; - gd = "definition"; - gi = "implementation"; - gt = "type_definition"; - R = "rename"; - }; + lsp = { + enable = true; + capabilities = # lua + "require('cmp_nvim_lsp').default_capabilities()"; + keymaps = { + diagnostic = { + "j" = "goto_next"; + "k" = "goto_prev"; }; - servers = { - rnix-lsp.enable = true; - rust-analyzer = { - enable = true; - installRustc = true; - installCargo = true; - }; - tsserver.enable = true; - yamlls.enable = true; - pylsp = { - enable = true; - settings.plugins = { - rope.enabled = true; - pylsp_mypy.enabled = true; - pylint.enabled = true; - isort.enabled = true; - flake8.enabled = true; - black.enabled = true; - }; + lspBuf = { + K = "hover"; + gD = "references"; + gd = "definition"; + gi = "implementation"; + gt = "type_definition"; + R = "rename"; + }; + }; + servers = { + rnix-lsp.enable = true; + rust-analyzer = { + enable = true; + installRustc = true; + installCargo = true; + }; + tsserver.enable = true; + yamlls.enable = true; + pylsp = { + enable = true; + settings.plugins = { + rope.enabled = true; + pylsp_mypy.enabled = true; + pylint.enabled = true; + isort.enabled = true; + flake8.enabled = true; + black.enabled = true; }; - lua-ls.enable = true; - html.enable = true; - gopls = { - enable = true; - onAttach.function = /*lua*/ '' + }; + lua-ls.enable = true; + html.enable = true; + gopls = { + enable = true; + onAttach.function = # lua + '' vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.go", callback = function() @@ -198,130 +192,131 @@ in end }) ''; - }; - cmake.enable = true; - gdscript.enable = true; - eslint.enable = true; - cssls.enable = true; - clangd.enable = true; - bashls.enable = true; - jsonls.enable = true; - tailwindcss.enable = true; - taplo.enable = true; - terraformls.enable = true; - - # TODO Enable LSP server, when will be added to stable version of nixvim (26.12.2023) - - #graphql.enable = true; - #dockerls.enable = true; - #ansiblels.enable = true; }; + cmake.enable = true; + gdscript.enable = true; + eslint.enable = true; + cssls.enable = true; + clangd.enable = true; + bashls.enable = true; + jsonls.enable = true; + tailwindcss.enable = true; + taplo.enable = true; + terraformls.enable = true; + + # TODO Enable LSP server, when will be added to stable version of nixvim (26.12.2023) + + #graphql.enable = true; + #dockerls.enable = true; + #ansiblels.enable = true; }; + }; - nvim-cmp = { - enable = true; - sources = [ - { name = "nvim_lsp"; } - { name = "path"; } - { name = "snippy"; } - { name = "spell"; } - { name = "buffer"; } - ]; - snippet.expand = "luasnip"; - mappingPresets = [ "insert" ]; - mapping = { - "" = "cmp.mapping.scroll_docs(-4)"; - "" = "cmp.mapping.scroll_docs(4)"; - "" = "cmp.mapping.complete()"; - "" = "cmp.mapping.abort()"; - "" = "cmp.mapping.confirm({ select = true })"; - }; + nvim-cmp = { + enable = true; + sources = [ + { name = "nvim_lsp"; } + { name = "path"; } + { name = "snippy"; } + { name = "spell"; } + { name = "buffer"; } + ]; + snippet.expand = "luasnip"; + mappingPresets = [ "insert" ]; + mapping = { + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.confirm({ select = true })"; }; + }; - luasnip.enable = true; - cmp-nvim-lua.enable = true; - cmp-nvim-lsp.enable = true; - cmp-path.enable = true; - cmp-snippy.enable = true; - cmp-buffer.enable = true; - cmp-spell.enable = true; - cmp-vim-lsp.enable = true; - - lsp-format = { - enable = true; - lspServersToEnable = "all"; - }; + luasnip.enable = true; + cmp-nvim-lua.enable = true; + cmp-nvim-lsp.enable = true; + cmp-path.enable = true; + cmp-snippy.enable = true; + cmp-buffer.enable = true; + cmp-spell.enable = true; + cmp-vim-lsp.enable = true; + + lsp-format = { + enable = true; + lspServersToEnable = "all"; + }; - efmls-configs = { - enable = true; - setup.go.formatter = [ "goimports" ]; - }; + efmls-configs = { + enable = true; + setup.go.formatter = [ "goimports" ]; + }; - barbar = { - enable = true; - autoHide = true; - insertAtEnd = true; - keymaps = { - close = "bd"; - goTo1 = "b1"; - goTo2 = "b2"; - goTo3 = "b3"; - goTo4 = "b4"; - goTo5 = "b5"; - goTo6 = "b6"; - goTo7 = "b7"; - goTo8 = "b8"; - goTo9 = "b9"; - next = "bj"; - previous = "bk"; - }; + barbar = { + enable = true; + autoHide = true; + insertAtEnd = true; + keymaps = { + close = "bd"; + goTo1 = "b1"; + goTo2 = "b2"; + goTo3 = "b3"; + goTo4 = "b4"; + goTo5 = "b5"; + goTo6 = "b6"; + goTo7 = "b7"; + goTo8 = "b8"; + goTo9 = "b9"; + next = "bj"; + previous = "bk"; }; + }; - tmux-navigator.enable = true; + tmux-navigator.enable = true; - lightline = { - enable = true; - colorscheme = "catppuccin"; - }; + lightline = { + enable = true; + colorscheme = "catppuccin"; + }; - nix.enable = true; + nix.enable = true; - surround.enable = true; - todo-comments.enable = true; - fugitive.enable = true; + surround.enable = true; + todo-comments.enable = true; + fugitive.enable = true; - telescope = { + telescope = { + enable = true; + extensions.file_browser = { enable = true; - extensions.file_browser = { - enable = true; - hidden = true; - }; - keymaps = { - "ff" = "find_files"; - "fg" = "git_files"; - "gg" = "live_grep"; - "bf" = "buffers"; - "" = "lsp_definitions"; - }; + hidden = true; + }; + keymaps = { + "ff" = "find_files"; + "fg" = "git_files"; + "gg" = "live_grep"; + "bf" = "buffers"; + "" = "lsp_definitions"; }; + }; - endwise.enable = true; - gitblame.enable = true; + endwise.enable = true; + gitblame.enable = true; - nvim-autopairs = { - enable = true; - disableInReplaceMode = true; - }; + nvim-autopairs = { + enable = true; + disableInReplaceMode = true; }; + }; - keymaps = [ - # Custom - { - action = " Explore"; - key = "fe"; - } - { - action = /*lua*/ '' + keymaps = [ + # Custom + { + action = " Explore"; + key = "fe"; + } + { + action = # lua + '' function() local currectFile = vim.fn.expand("%:p") local directory = vim.fn.expand('%:p:h') @@ -336,11 +331,12 @@ in vim.cmd("Telescope find_template type=insert filter_ft=true") end ''; - key = "fc"; - lua = true; - } - { - action = /*lua*/ '' + key = "fc"; + lua = true; + } + { + action = # lua + '' function() local newDirectoryName = vim.fn.input("Enter new directory name: ", "", "dir") local currentDirectory = vim.fn.expand('%:p:h') @@ -350,55 +346,55 @@ in print("Created new directory: " .. newDirectoryPath) end ''; - key = "fd"; - lua = true; - } - # TmuxNavigate - { - action = " TmuxNavifateLeft"; - key = ""; - } - { - action = " TmuxNavifateRight"; - key = ""; - } - { - action = " TmuxNavifateDown"; - key = ""; - } - { - action = " TmuxNavifateUp"; - key = ""; - } - # Undotree - { - action = " UndotreeToggle"; - key = "U"; - } - # DAP - { - action = ''function() require("dapui").toggle() end''; - lua = true; - key = ""; - } - { - action = '' DapToggleBreakpoint''; - key = ""; - } - { - action = " DapContinue"; - key = ""; - } - # Golang - { - action = " GoIfErr"; - key = ""; - } - { - action = " GoImpl"; - key = ""; - } - ]; - }; + key = "fd"; + lua = true; + } + # TmuxNavigate + { + action = " TmuxNavifateLeft"; + key = ""; + } + { + action = " TmuxNavifateRight"; + key = ""; + } + { + action = " TmuxNavifateDown"; + key = ""; + } + { + action = " TmuxNavifateUp"; + key = ""; + } + # Undotree + { + action = " UndotreeToggle"; + key = "U"; + } + # DAP + { + action = ''function() require("dapui").toggle() end''; + lua = true; + key = ""; + } + { + action = " DapToggleBreakpoint"; + key = ""; + } + { + action = " DapContinue"; + key = ""; + } + # Golang + { + action = " GoIfErr"; + key = ""; + } + { + action = " GoImpl"; + key = ""; + } + ]; + }; }; } diff --git a/modules/editors/plugins/gopher.nvim.nix b/modules/editors/plugins/gopher.nvim.nix index b9af808c..1cade339 100644 --- a/modules/editors/plugins/gopher.nvim.nix +++ b/modules/editors/plugins/gopher.nvim.nix @@ -1,14 +1,5 @@ -{ lib -, fetchFromGitHub -, go -, gomodifytags -, gotests -, impl -, iferr -, vimUtils -, vimPlugins -, ... -}: { +{ lib, fetchFromGitHub, go, gomodifytags, gotests, impl, iferr, vimUtils +, vimPlugins, ... }: { luaConfig = '' require("gopher").setup { commands = { @@ -33,16 +24,18 @@ meta.homepage = "https://github.com/olexsmir/gopher.nvim"; }; - deps = let plenaryNvim = vimUtils.buildVimPlugin { - pname = "plenary.nvim"; - version = "v0.1.4"; - src = fetchFromGitHub { - owner = "nvim-lua"; - repo = "plenary.nvim"; - rev = "50012918b2fc8357b87cff2a7f7f0446e47da174"; - sha256 = "sha256-zR44d9MowLG1lIbvrRaFTpO/HXKKrO6lbtZfvvTdx+o="; + deps = let + plenaryNvim = vimUtils.buildVimPlugin { + pname = "plenary.nvim"; + version = "v0.1.4"; + src = fetchFromGitHub { + owner = "nvim-lua"; + repo = "plenary.nvim"; + rev = "50012918b2fc8357b87cff2a7f7f0446e47da174"; + sha256 = "sha256-zR44d9MowLG1lIbvrRaFTpO/HXKKrO6lbtZfvvTdx+o="; + }; + meta.homepage = "https://github.com/nvim-lua/plenary.nvim"; }; - meta.homepage = "https://github.com/nvim-lua/plenary.nvim"; - }; in with vimPlugins; [ nvim-treesitter plenaryNvim ]; + in with vimPlugins; [ nvim-treesitter plenaryNvim ]; } diff --git a/modules/editors/plugins/nvim-comment.nix b/modules/editors/plugins/nvim-comment.nix index aa025afb..0fda95cd 100644 --- a/modules/editors/plugins/nvim-comment.nix +++ b/modules/editors/plugins/nvim-comment.nix @@ -1,5 +1,4 @@ -{ srcOnly, vimUtils, lib, fetchFromGitHub, ... }: -{ +{ srcOnly, vimUtils, lib, fetchFromGitHub, ... }: { luaConfig = '' require('nvim_comment').setup() ''; diff --git a/modules/editors/plugins/template.nvim.nix b/modules/editors/plugins/template.nvim.nix index 63a182f1..e05f91d7 100644 --- a/modules/editors/plugins/template.nvim.nix +++ b/modules/editors/plugins/template.nvim.nix @@ -4,8 +4,8 @@ let pname = "template-dir"; version = "28-12-2023"; src = ./templates; - }; in -{ + }; +in { luaConfig = '' require('template').setup({ temp_dir = "${templateDir}", diff --git a/modules/editors/plugins/templates/cc.nix b/modules/editors/plugins/templates/cc.nix index b26f97e9..20d396ae 100644 --- a/modules/editors/plugins/templates/cc.nix +++ b/modules/editors/plugins/templates/cc.nix @@ -1,14 +1,13 @@ -{ stdenv }: stdenv.mkDerivation { +{ stdenv }: +stdenv.mkDerivation { name = "{{_file_name_}}"; src = ./.; buildInputs = [ ]; - buildPhase = '' - ''; + buildPhase = ""; - installPhase = '' - ''; + installPhase = ""; meta = with lib; { homepage = "https://github.com/Wittano/{{_file_name_}}"; diff --git a/modules/editors/plugins/templates/nocc.nix b/modules/editors/plugins/templates/nocc.nix index 07149ef5..d7a11d0f 100644 --- a/modules/editors/plugins/templates/nocc.nix +++ b/modules/editors/plugins/templates/nocc.nix @@ -1,14 +1,13 @@ -{ stdenvNoCC }: stdenvNoCC.mkDerivation { +{ stdenvNoCC }: +stdenvNoCC.mkDerivation { name = "{{_file_name_}}"; src = ./.; buildInputs = [ ]; - buildPhase = '' - ''; + buildPhase = ""; - installPhase = '' - ''; + installPhase = ""; meta = with lib; { homepage = "https://github.com/Wittano/{{_file_name_}}"; diff --git a/modules/hardware/bootloader.nix b/modules/hardware/bootloader.nix index c6b4c13a..bd29c1b4 100644 --- a/modules/hardware/bootloader.nix +++ b/modules/hardware/bootloader.nix @@ -13,14 +13,11 @@ in { }; config = mkIf cfg.enable { - boot.loader = { - - grub = { - efiSupport = true; - enable = true; - useOSProber = true; - device = "nodev"; - }; + boot.loader.grub = { + efiSupport = true; + enable = true; + useOSProber = true; + device = "nodev"; }; }; } diff --git a/modules/hardware/nvidia.nix b/modules/hardware/nvidia.nix index 4bd87210..d8941855 100644 --- a/modules/hardware/nvidia.nix +++ b/modules/hardware/nvidia.nix @@ -3,8 +3,7 @@ let inherit (lib) mkEnableOption mkIf; cfg = config.modules.hardware.nvidia; -in -{ +in { options = { modules.hardware.nvidia = { enable = mkEnableOption '' diff --git a/modules/hardware/usb.nix b/modules/hardware/usb.nix index 022a9e30..5a2e7af0 100644 --- a/modules/hardware/usb.nix +++ b/modules/hardware/usb.nix @@ -6,8 +6,7 @@ let unmountUSBScript = pkgs.writeScriptBin "unmount.sh" '' ${pkgs.udisks2}/bin/udisksctl unmount -b "/dev/$2" ''; -in -{ +in { config = { services.udisks2 = { enable = true; diff --git a/modules/hardware/virutalization.nix b/modules/hardware/virutalization.nix index 2fba7e8b..a86fd554 100644 --- a/modules/hardware/virutalization.nix +++ b/modules/hardware/virutalization.nix @@ -1,11 +1,10 @@ -{ config, pkgs, lib, modulesPath, username, systemStaff, unstable, ... }: +{ config, pkgs, lib, modulesPath, systemStaff, unstable, ... }: with lib; with lib.my; let cfg = config.modules.hardware.virtualization; virutalizationDir = mapper.mapDirToAttrs ./virtualization; -in -{ +in { imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; options = { @@ -44,7 +43,7 @@ in }; }; - users.users."${username}".extraGroups = [ + users.users.wittano.extraGroups = [ (mkIf cfg.enableDocker "docker") (mkIf cfg.enableVagrant "vboxusers") "libvirtd" @@ -57,7 +56,7 @@ in }]; security.sudo.extraRules = mkIf cfg.enableWindowsVM [{ - users = [ "${username}" ]; + users = [ "wittano" ]; commands = [{ command = "${pkgs.libvirt}/bin/virsh start win10"; options = [ "NOPASSWD" ]; @@ -67,58 +66,58 @@ in programs.virt-manager.enable = true; environment.systemPackages = with pkgs; - [ libguestfs ] - ++ (if cfg.enableVagrant then [ vagrant ] else [ ]); + [ libguestfs ] ++ (if cfg.enableVagrant then [ vagrant ] else [ ]); systemd.services.libvirtd = mkIf cfg.enableWindowsVM { - path = - let - env = pkgs.buildEnv { - name = "qemu-hook-env"; - paths = with pkgs; [ bash libvirt kmod systemd ripgrep sd ]; - }; - in - [ env ]; - - preStart = - let - stopBoincScript = pkgs.writeScript "stop-boinc.sh" '' - #!/usr/bin/env bash - - systemctl stop display-manager.service - systemctl stop boinc.service - ''; - startBoincScript = pkgs.writeScript "start-boinc.sh" '' - #!/usr/bin/env bash - - systemctl start boinc.service - ''; - in - mkIf (cfg.enableWindowsVM) '' - mkdir -p /var/lib/libvirt/hooks/qemu.d/win10/prepare/begin - mkdir -p /var/lib/libvirt/hooks/qemu.d/win10/release/end - mkdir -p /var/lib/libvirt/vbios - - ln -sf ${virutalizationDir.hooks.qemu.source} /var/lib/libvirt/hooks/qemu - - ln -sf ${virutalizationDir.hooks."qemu.d".win10.prepare.begin."start.sh".source} /var/lib/libvirt/hooks/qemu.d/win10/prepare/begin/start.sh - ln -sf ${virutalizationDir.hooks."qemu.d".win10.release.end."revert.sh".source} /var/lib/libvirt/hooks/qemu.d/win10/release/end/stop.sh - - ln -sf ${stopBoincScript} /var/lib/libvirt/hooks/qemu.d/win10/prepare/begin/boinc.sh - ln -sf ${startBoincScript} /var/lib/libvirt/hooks/qemu.d/win10/release/end/boinc.sh - - ln -sf ${ - virutalizationDir."vibios.rom".source - } /var/lib/libvirt/vbios/vibios.rom + path = let + env = pkgs.buildEnv { + name = "qemu-hook-env"; + paths = with pkgs; [ bash libvirt kmod systemd ripgrep sd ]; + }; + in [ env ]; + + preStart = let + stopBoincScript = pkgs.writeScript "stop-boinc.sh" '' + #!/usr/bin/env bash + + systemctl stop display-manager.service + systemctl stop boinc.service + ''; + startBoincScript = pkgs.writeScript "start-boinc.sh" '' + #!/usr/bin/env bash + + systemctl start boinc.service ''; + in mkIf (cfg.enableWindowsVM) '' + mkdir -p /var/lib/libvirt/hooks/qemu.d/win10/prepare/begin + mkdir -p /var/lib/libvirt/hooks/qemu.d/win10/release/end + mkdir -p /var/lib/libvirt/vbios + + ln -sf ${virutalizationDir.hooks.qemu.source} /var/lib/libvirt/hooks/qemu + + ln -sf ${ + virutalizationDir.hooks."qemu.d".win10.prepare.begin."start.sh".source + } /var/lib/libvirt/hooks/qemu.d/win10/prepare/begin/start.sh + ln -sf ${ + virutalizationDir.hooks."qemu.d".win10.release.end."revert.sh".source + } /var/lib/libvirt/hooks/qemu.d/win10/release/end/stop.sh + + ln -sf ${stopBoincScript} /var/lib/libvirt/hooks/qemu.d/win10/prepare/begin/boinc.sh + ln -sf ${startBoincScript} /var/lib/libvirt/hooks/qemu.d/win10/release/end/boinc.sh + + ln -sf ${ + virutalizationDir."vibios.rom".source + } /var/lib/libvirt/vbios/vibios.rom + ''; }; systemd.services.pcscd.enable = !cfg.enableWindowsVM; systemd.sockets.pcscd.enable = !cfg.enableWindowsVM; - home-manager.users.wittano.programs.fish.shellAliases = mkIf (cfg.enableWindowsVM && config.modules.shell.fish.enable) { - vm = "bash ${virutalizationDir."select-vagrant-vm.sh".source}"; - }; + home-manager.users.wittano.programs.fish.shellAliases = + mkIf (cfg.enableWindowsVM && config.modules.shell.fish.enable) { + vm = "bash ${virutalizationDir."select-vagrant-vm.sh".source}"; + }; boot = { kernelPackages = mkIf cfg.enableWindowsVM pkgs.linuxPackages_5_15; diff --git a/modules/hardware/wacom.nix b/modules/hardware/wacom.nix index dddbfd13..8f86a065 100644 --- a/modules/hardware/wacom.nix +++ b/modules/hardware/wacom.nix @@ -10,8 +10,7 @@ let ${pkgs.xf86_input_wacom}/bin/xsetwacom --set "$i" MapToOutput HEAD-0 done ''; -in -{ +in { options = { modules.hardware.wacom = { enable = mkEnableOption "Enable support for wacom graphic tablet"; diff --git a/modules/hardware/wifi.nix b/modules/hardware/wifi.nix index ceaf0c64..13236662 100644 --- a/modules/hardware/wifi.nix +++ b/modules/hardware/wifi.nix @@ -5,11 +5,11 @@ let cfg = config.modules.hardware.wifi; kernel = config.boot.kernelPackages.kernel; kernelVersionPackage = - if (kernel.version == pkgs.linuxPackages_5_15.kernel.version) - then "linux_5_15" - else "linux_6_1"; # This driver is working only for kernel 5.18 and lower! 12.11.2023 -in -{ + if (kernel.version == pkgs.linuxPackages_5_15.kernel.version) then + "linux_5_15" + else + "linux_6_1"; # This driver is working only for kernel 5.18 and lower! 12.11.2023 +in { options = { modules.hardware.wifi = { enable = mkEnableOption "Enable support for WiFi"; @@ -19,12 +19,11 @@ in config = mkIf cfg.enable { # TODO Fix problem with blocking playing spotify tracks - networking = { - wireless.enable = true; - }; + networking = { wireless.enable = true; }; boot = mkIf cfg.enableTpLink { - extraModulePackages = mkIf (!kernel.kernelAtLeast "5.18") [ pkgs.linuxKernel.packages."${kernelVersionPackage}".rtl8192eu ]; + extraModulePackages = mkIf (!kernel.kernelAtLeast "5.18") + [ pkgs.linuxKernel.packages."${kernelVersionPackage}".rtl8192eu ]; extraModprobeConfig = '' blacklist rtl8xxxu ''; diff --git a/modules/networking/default.nix b/modules/networking/default.nix index f5f2d72c..d89380d4 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -1,3 +1 @@ -{ config, pkgs, ... }: { - networking.hostName = "nixos"; -} +{ config, pkgs, ... }: { networking.hostName = "nixos"; } diff --git a/modules/services/backup.nix b/modules/services/backup.nix index 90660369..67fb91cf 100644 --- a/modules/services/backup.nix +++ b/modules/services/backup.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, username, ... }: +{ config, pkgs, lib, ... }: let inherit (lib) mkEnableOption types mkIf mkOption; @@ -30,8 +30,7 @@ let go/**/* git ''; -in -{ +in { options = { modules.services.backup = { enable = mkEnableOption "Enable Backup service"; @@ -54,16 +53,16 @@ in }; systemd.services.backup = { description = '' - Backup service for ${username} home directory + Backup service for wittano home directory ''; serviceConfig = { Type = "oneshot"; - User = username; + User = "wittano"; }; wantedBy = [ "multi-user.target" ]; preStart = '' mkdir -p ${cfg.backupDir} - chown ${username}:users ${cfg.backupDir} + chown wittano:users ${cfg.backupDir} ''; script = '' today=$(${pkgs.coreutils}/bin/date -I) diff --git a/modules/services/boinc.nix b/modules/services/boinc.nix index 3c0e4877..a4687141 100644 --- a/modules/services/boinc.nix +++ b/modules/services/boinc.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, username, ... }: +{ config, pkgs, lib, ... }: let inherit (lib) mkEnableOption mkIf; @@ -9,7 +9,7 @@ in { }; config = mkIf cfg.enable { - users.users."${username}".extraGroups = [ "boinc" ]; + users.users.wittano.extraGroups = [ "boinc" ]; services.boinc = { enable = true; diff --git a/modules/services/filebot.nix b/modules/services/filebot.nix index 4ab435bb..10906dfb 100644 --- a/modules/services/filebot.nix +++ b/modules/services/filebot.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, username, ... }: +{ config, pkgs, lib, ... }: let inherit (lib) mkEnableOption mkIf; @@ -6,13 +6,15 @@ let in { options = { - modules.services.filebot = { enable = mkEnableOption "Enable filebot service"; }; + modules.services.filebot = { + enable = mkEnableOption "Enable filebot service"; + }; }; config = { services.filebot = { enable = cfg.enable; - user = username; + user = "wittano"; configPath = builtins.toFile "config.toml" '' [Pictures] src = [ "$HOME/Downloads/*.(gif|jpe?g|tiff?|png|webp|bmp)" ] diff --git a/modules/services/flatpak.nix b/modules/services/flatpak.nix index e979e957..19331569 100644 --- a/modules/services/flatpak.nix +++ b/modules/services/flatpak.nix @@ -1,10 +1,9 @@ -{ config, pkgs, lib, username, ... }: +{ config, pkgs, lib, ... }: let inherit (lib) mkEnableOption mkIf; cfg = config.modules.services.flatpak; -in -{ +in { options = { modules.services.flatpak = { enable = mkEnableOption "Enable flatpak"; }; }; @@ -15,11 +14,10 @@ in enable = true; extraPortals = lib.mkIf (config.services.xserver.desktopManager.gnome.enable == false) - [ pkgs.xdg-desktop-portal-gtk ]; + [ pkgs.xdg-desktop-portal-gtk ]; config.common.default = "*"; }; - systemd.user.extraConfig = '' DefaultEnvironment="PATH=/run/current-system/sw/bin" ''; diff --git a/modules/services/prometheus.nix b/modules/services/prometheus.nix index 3b7e0ac5..7046a69e 100644 --- a/modules/services/prometheus.nix +++ b/modules/services/prometheus.nix @@ -4,8 +4,7 @@ let inherit (lib) mkEnableOption mkIf; cfg = config.modules.services.prometheus; -in -{ +in { options = { modules.services.prometheus = { enable = mkEnableOption '' @@ -22,12 +21,10 @@ in enable = true; port = 9090; - scrapeConfigs = [ - { - job_name = "node"; - static_configs = [{ targets = [ "localhost:9100" ]; }]; - } - ]; + scrapeConfigs = [{ + job_name = "node"; + static_configs = [{ targets = [ "localhost:9100" ]; }]; + }]; exporters = { node = { diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 9794b778..46b5ccb7 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -4,9 +4,9 @@ let homeDir = "/home/wittano"; cfg = config.modules.services.syncthing; - encryptedConfig = builtins.fromJSON (builtins.readFile config.age.secrets.syncthing.path); -in -{ + encryptedConfig = + builtins.fromJSON (builtins.readFile config.age.secrets.syncthing.path); +in { options = { modules.services.syncthing = { enable = mkEnableOption '' @@ -15,18 +15,19 @@ in }; }; - config = mkIf (cfg.enable && builtins.pathExists config.age.secrets.syncthing.path) { - services.syncthing = rec { - enable = true; - systemService = true; - dataDir = "${homeDir}/.cache/syncthing"; - configDir = "${homeDir}/.config/syncthing"; - user = "wittano"; - settings = { - folders = encryptedConfig.folders; - devices = encryptedConfig.devices; - extraOptions.gui.theme = "dark"; + config = + mkIf (cfg.enable && builtins.pathExists config.age.secrets.syncthing.path) { + services.syncthing = rec { + enable = true; + systemService = true; + dataDir = "${homeDir}/.cache/syncthing"; + configDir = "${homeDir}/.config/syncthing"; + user = "wittano"; + settings = { + folders = encryptedConfig.folders; + devices = encryptedConfig.devices; + extraOptions.gui.theme = "dark"; + }; }; }; - }; } diff --git a/modules/shell/fish.nix b/modules/shell/fish.nix index 66ce727e..eca23768 100644 --- a/modules/shell/fish.nix +++ b/modules/shell/fish.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, home-manager, hostName, username, dotfiles, ... }: +{ config, lib, pkgs, home-manager, hostname, dotfiles, ... }: with lib; with lib.my; let cfg = config.modules.shell.fish; @@ -22,26 +22,17 @@ in }; config = mkIf cfg.enable { - users.users."${username}".shell = mkIf cfg.default pkgs.fish; + users.users.wittano.shell = mkIf cfg.default pkgs.fish; programs.fish.enable = cfg.enable; environment.shells = mkIf cfg.default (with pkgs; [ fish ]); home-manager.users.wittano = { - home.activation = - let - customeActivation = path: - link.createMutableLinkActivation { - internalPath = path; - isDevMode = cfg.enableDevMode; - }; - in - { - linkMutableOmfConfig = customeActivation ".config/omf"; - linkMutableExternalAliasesConfig = - customeActivation ".config/fish/conf.d"; - }; + home.activation = { + linkMutableOmfConfig = link.createMutableLinkActivation cfg ".config/omf"; + linkMutableExternalAliasesConfig = link.createMutableLinkActivation cfg ".config/fish/conf.d"; + }; xdg.configFile = mkIf (cfg.enableDevMode == false) { omf.source = dotfiles.".config".omf.source; @@ -53,17 +44,18 @@ in interactiveShellInit = '' direnv hook fish | source ''; - loginShellInit = '' - set -U fish_user_paths $HOME/.local/bin $fish_user_paths - ''; shellAliases = let - host = builtins.replaceStrings [ "-dev" ] [ "" ] hostName; + host = builtins.replaceStrings [ "-dev" ] [ "" ] hostname; rebuild = name: - let impureFlag = - if config.modules.services.syncthing.enable - then "--impure" else ""; - in "sudo nixos-rebuild switch --flake ${config.environment.variables.NIX_DOTFILES}#${name} ${impureFlag}"; + let + impureFlag = + if config.modules.services.syncthing.enable then + "--impure" + else + ""; + in + "sudo nixos-rebuild switch --flake ${config.environment.variables.NIX_DOTFILES}#${name} ${impureFlag}"; in { xc = "xprop | grep CLASS"; diff --git a/modules/utils.nix b/modules/utils.nix index 08f1d546..c22c6581 100644 --- a/modules/utils.nix +++ b/modules/utils.nix @@ -1,9 +1,7 @@ { config, pkgs, lib, home-manager, ownPackages, ... }: with lib; -let - cfg = config.modules.utils; -in -{ +let cfg = config.modules.utils; +in { options = { modules.utils = { enable = mkEnableOption '' @@ -18,6 +16,7 @@ in config = mkIf cfg.enable { home-manager.users.wittano.home.packages = mkIf (cfg.enable) ([ ]); - environment.systemPackages = mkIf (cfg.enableGlobalUtils) ([ ownPackages.patcherDir ]); + environment.systemPackages = + mkIf (cfg.enableGlobalUtils) ([ ownPackages.patcherDir ]); }; } diff --git a/secrets/secrets.nix b/secrets/secrets.nix index c4330dca..0057738c 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -1,6 +1,4 @@ let - key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCZNdd31cwPZMn4MAdPavH13whw4sDlRBn+hgHs+ACmBrtWHUoG7bNc6x7PgLlA3w6ln9yMyHzNDw7S0/yrsZmqb2dJkLPW50bsJampxZVLS6iPudVfjYRGDI+awOa1sqiXvQCZf6rR7NBXZnG2YaP2iuqppZiz7S5BjZV2uSUfAliST0gUUGrG7nv0DUXzT/bgtfxGSlf9UiFaq/Cu39nNrftwFccTJ/PyB4nlH/n5LPPi+ZBCsljO7p4FaLdLKmuVJVQBvg+IJcVtEBr9sUPtsOT2f/8MEUU91uZ0W+3ml2TWK/mogpaGH0Ym3nnUl7BsVdL1490GJRN4kOYhArznytVYqh7c44LKnaIFITEcuLbYlR5TyQHrmMQVZjyBv05MV7Taq/Onbv1O/95pmcRd/2J3lCUGkgTjqBIaKO9FV35++pt5jAfLAY8qtOMbozkLCTzPnfGZLzXAsibKfI6KwETU2E1spI0bJ08sXXxqBtnGGE8nRBZ3NfqySmwqg/8= wittano@nixos"; -in -{ - "syncthing.age".publicKeys = [ key ]; -} + key = + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCZNdd31cwPZMn4MAdPavH13whw4sDlRBn+hgHs+ACmBrtWHUoG7bNc6x7PgLlA3w6ln9yMyHzNDw7S0/yrsZmqb2dJkLPW50bsJampxZVLS6iPudVfjYRGDI+awOa1sqiXvQCZf6rR7NBXZnG2YaP2iuqppZiz7S5BjZV2uSUfAliST0gUUGrG7nv0DUXzT/bgtfxGSlf9UiFaq/Cu39nNrftwFccTJ/PyB4nlH/n5LPPi+ZBCsljO7p4FaLdLKmuVJVQBvg+IJcVtEBr9sUPtsOT2f/8MEUU91uZ0W+3ml2TWK/mogpaGH0Ym3nnUl7BsVdL1490GJRN4kOYhArznytVYqh7c44LKnaIFITEcuLbYlR5TyQHrmMQVZjyBv05MV7Taq/Onbv1O/95pmcRd/2J3lCUGkgTjqBIaKO9FV35++pt5jAfLAY8qtOMbozkLCTzPnfGZLzXAsibKfI6KwETU2E1spI0bJ08sXXxqBtnGGE8nRBZ3NfqySmwqg/8= wittano@nixos"; +in { "syncthing.age".publicKeys = [ key ]; }