diff --git a/modules/network.mod.nix b/modules/network.mod.nix index 1030520..c04b845 100644 --- a/modules/network.mod.nix +++ b/modules/network.mod.nix @@ -68,6 +68,8 @@ { networking.useNetworkd = true; + networking.nftables.enable = true; + networking.networkmanager.enable = true; users.extraGroups.networkmanager.members = diff --git a/modules/nushell.mod.nix b/modules/nushell.mod.nix new file mode 100644 index 0000000..4f7494d --- /dev/null +++ b/modules/nushell.mod.nix @@ -0,0 +1,133 @@ +let + commonModule = + { + config, + lib, + pkgs, + ... + }: + let + inherit (lib.attrsets) + attrNames + attrValues + filterAttrs + mapAttrs + mapAttrsToList + ; + inherit (lib.lists) + filter + flatten + last + listToAttrs + singleton + ; + inherit (lib.meta) getExe; + inherit (lib.modules) mkIf; + inherit (lib.trivial) const; + inherit (lib.strings) + concatStrings + readFile + replaceStrings + splitString + ; + in + { + home.extraModules = singleton ( + homeArgs: + let + config' = homeArgs.config; + + variablesMap = + { + HOME = config'.home.directory; + USER = config'.home.directory |> splitString "/" |> filter (s: s != "") |> last; + + XDG_CACHE_HOME = config'.xdg.cache.directory; + XDG_CONFIG_HOME = config'.xdg.config.directory; + XDG_DATA_HOME = config'.xdg.data.directory; + XDG_STATE_HOME = config'.xdg.state.directory; + } + |> mapAttrsToList ( + name: value: [ + { + name = "\$${name}"; + inherit value; + } + { + name = "\${${name}}"; + inherit value; + } + ] + ) + |> flatten + |> listToAttrs; + + nuVariables = + config.environment.variables + |> mapAttrs (const <| replaceStrings (attrNames variablesMap) (attrValues variablesMap)) + |> filterAttrs (name: const <| name != "TERM"); + + nuVariables' = + nuVariables + |> mapAttrsToList ( + name: value: + # nu + '' + $env.${name} = "${value}" + '' + ) + |> concatStrings; + + nuConfig = nuVariables' + readFile ./nushell.config.nu; + + in + { + home.file.".zshrc".text = + mkIf config.nixpkgs.system.hostPlatform.isDarwin # zsh + '' + SHELL=${getExe config'.programs.nushell.package} exec ${getExe config'.programs.nushell.package} + ''; + + programs.nushell = { + enable = true; + + extraConfig = nuConfig; + + aliases = { + la = "ls --all"; + ll = "ls --long"; + lla = "ls --long --all"; + sl = "ls"; + + cp = "cp --recursive --verbose --progress"; + mk = "mkdir"; + mv = "mv --verbose"; + rm = "rm --recursive --verbose"; + + pstree = "${getExe pkgs.pstree} -g 3"; + tree = "${getExe pkgs.eza} --tree --git-ignore --group-directories-first"; + }; + }; + } + ); + }; +in +{ + nixosModules.nushell = + { lib, pkgs, ... }: + let + inherit (lib.modules) mkForce; + in + { + imports = [ commonModule ]; + + users.defaultUserShell = pkgs.nushell; + + environment.shellAliases = { + ls = mkForce null; + l = mkForce null; + }; + }; + + darwinModules.nushell = commonModule; +} diff --git a/modules/video-player.mod.nix b/modules/video-player.mod.nix index 2bb122b..7dbb688 100644 --- a/modules/video-player.mod.nix +++ b/modules/video-player.mod.nix @@ -7,18 +7,18 @@ ... }: let - inherit (lib.modules) optionals; + inherit (lib.lists) singleton; in { # TODO: xdg-mime - packages = [ - ] - ++ optionals config.nixpkgs.hostPlatform.isLinux [ - pkgs.haruna - ] - ++ optionals config.nixpkgs.hostPlatform.isDarwin [ - pkgs.iina - ]; + packages = singleton ( + if config.nixpkgs.hostPlatform.isLinux then + pkgs.haruna + else if config.nixpkgs.hostPlatform.isDarwin then + pkgs.iina + else + throw "Unsupported OS" + ); }; } diff --git a/modules/zoxide.mod.nix b/modules/zoxide.mod.nix new file mode 100644 index 0000000..1775796 --- /dev/null +++ b/modules/zoxide.mod.nix @@ -0,0 +1,14 @@ +{ + homeModules.zoxide = { + programs.zoxide = { + enable = true; + + flags = [ + "--cmd" + "cd" + ]; + + integrations.nushell.enable = true; + }; + }; +}