From 660149f46b5996576387821bcc944f5a7634d87c Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Thu, 22 May 2025 21:19:25 -0400 Subject: [PATCH] Fix aliases, nh, etc --- flake.lock | 21 +++++++++++++++ flake.nix | 4 +++ modules/common/bat.nix | 5 ++++ modules/common/experimental.nix | 2 +- modules/common/eza.nix | 5 ++++ modules/common/fish.nix | 26 +------------------ modules/common/free.nix | 1 + modules/common/git.nix | 20 ++++++++++++-- modules/common/neowofetch/default.nix | 3 +++ .../common/neowofetch}/neofetch.conf | 0 modules/common/nh.nix | 16 ++++++++++++ modules/common/run0.nix | 10 +++---- modules/common/trash.nix | 1 + wrappers/common/bat.nix | 6 ----- wrappers/common/eza.nix | 12 --------- wrappers/common/neofetch/default.nix | 9 ------- 16 files changed, 81 insertions(+), 60 deletions(-) create mode 100644 modules/common/bat.nix create mode 100644 modules/common/eza.nix create mode 100644 modules/common/free.nix create mode 100644 modules/common/neowofetch/default.nix rename {wrappers/common/neofetch => modules/common/neowofetch}/neofetch.conf (100%) create mode 100644 modules/common/trash.nix delete mode 100644 wrappers/common/bat.nix delete mode 100644 wrappers/common/eza.nix delete mode 100644 wrappers/common/neofetch/default.nix diff --git a/flake.lock b/flake.lock index 31f5c2c..258693f 100644 --- a/flake.lock +++ b/flake.lock @@ -563,6 +563,26 @@ "type": "github" } }, + "nh": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747943020, + "narHash": "sha256-LlMUdltEdGxVLDZRSDQn3/i/WWn7Jakdz4wQxLxzfZ8=", + "owner": "nix-community", + "repo": "nh", + "rev": "24c12228e1f1e4fc953e37283fe442ca169951ed", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nh", + "type": "github" + } + }, "nix-filter": { "locked": { "lastModified": 1731533336, @@ -768,6 +788,7 @@ "firefox-gnome-theme": "firefox-gnome-theme", "grapevine": "grapevine", "home-manager": "home-manager_2", + "nh": "nh", "nixpkgs": "nixpkgs_4", "programsdb": "programsdb", "stylix": "stylix", diff --git a/flake.nix b/flake.nix index 04940b9..7fd2918 100755 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,10 @@ url = "github:viperML/wrapper-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + nh = { + url = "github:nix-community/nh"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs: let diff --git a/modules/common/bat.nix b/modules/common/bat.nix new file mode 100644 index 0000000..7c9a8ba --- /dev/null +++ b/modules/common/bat.nix @@ -0,0 +1,5 @@ +{ + lib, + pkgs, + ... +}: {environment.shellAliases.cat = "${lib.getExe pkgs.bat} --theme Nord";} diff --git a/modules/common/experimental.nix b/modules/common/experimental.nix index 8e3b499..512b86f 100644 --- a/modules/common/experimental.nix +++ b/modules/common/experimental.nix @@ -1 +1 @@ -{nix.settings.experimental-features = ["nix-command" "flakes"];} +{nix.settings.experimental-features = ["nix-command" "flakes" "repl-flake"];} diff --git a/modules/common/eza.nix b/modules/common/eza.nix new file mode 100644 index 0000000..d5d7ad9 --- /dev/null +++ b/modules/common/eza.nix @@ -0,0 +1,5 @@ +{ + lib, + pkgs, + ... +}: {environment.shellAliases.ls = "${lib.getExe pkgs.eza} --all --icons --hyperlink --group-directories-first --color=always";} diff --git a/modules/common/fish.nix b/modules/common/fish.nix index c2b2de7..017f55b 100644 --- a/modules/common/fish.nix +++ b/modules/common/fish.nix @@ -7,30 +7,6 @@ ''; }; - environment = { - shells = [pkgs.fish]; - shellAliases = { - # Utility - ls = "eza"; - cat = "bat"; - rm = "gio trash"; - free = "free -h"; - neofetch = "neowofetch"; - shutdown = "shutdown now"; - - # Git - clone = "gh repo clone"; - create = "gh repo create"; - - push = "git push"; - commit = "git commit -am"; - - # NixOS - clean = "nh clean all"; - rebuild = "nh os switch"; - rebuildServer = "nixos-rebuild switch --flake ~/.config/nixos#quadraticserver --target-host quadradical@192.168.0.132 --use-remote-sudo"; - update = "pushd ~/.config/nixos && nix flake update && popd && rebuild"; - }; - }; + environment.shells = [pkgs.fish]; users.defaultUserShell = pkgs.fish; } diff --git a/modules/common/free.nix b/modules/common/free.nix new file mode 100644 index 0000000..942832a --- /dev/null +++ b/modules/common/free.nix @@ -0,0 +1 @@ +{pkgs, ...}: {environment.shellAliases.free = "${pkgs.procps}/bin/free -h";} diff --git a/modules/common/git.nix b/modules/common/git.nix index 1141ae4..b2a488f 100644 --- a/modules/common/git.nix +++ b/modules/common/git.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: { +{ + pkgs, + lib, + ... +}: { programs.git = { enable = true; config = { @@ -17,5 +21,17 @@ gpg.format = "ssh"; }; }; - environment.systemPackages = [pkgs.gh]; + environment = { + systemPackages = [pkgs.gh]; + shellAliases = let + gitExe = lib.meta.getExe pkgs.git; + ghExe = lib.meta.getExe pkgs.gh; + in { + clone = "${ghExe} repo clone"; + create = "${ghExe} repo create"; + + push = "${gitExe} push"; + commit = "${gitExe} commit -am"; + }; + }; } diff --git a/modules/common/neowofetch/default.nix b/modules/common/neowofetch/default.nix new file mode 100644 index 0000000..7f92393 --- /dev/null +++ b/modules/common/neowofetch/default.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + environment.shellAliases.neofetch = "${pkgs.hyfetch}/bin/neowofetch --config ${./neofetch.conf}"; +} diff --git a/wrappers/common/neofetch/neofetch.conf b/modules/common/neowofetch/neofetch.conf similarity index 100% rename from wrappers/common/neofetch/neofetch.conf rename to modules/common/neowofetch/neofetch.conf diff --git a/modules/common/nh.nix b/modules/common/nh.nix index 96195e5..d0a7262 100644 --- a/modules/common/nh.nix +++ b/modules/common/nh.nix @@ -1,7 +1,23 @@ { + inputs, + pkgs, + lib, + ... +}: let + pkg = inputs.nh.packages.${pkgs.system}.default; + exe = lib.getExe pkg; +in { programs.nh = { enable = true; + package = pkg; clean.enable = true; flake = "/home/quadradical/.config/nixos"; }; + + environment.shellAliases = { + clean = "${exe} clean all"; + update = "pushd ~/.config/nixos && nix flake update && popd && rebuild"; + rebuild = "${exe} os switch"; + rebuildServer = "${exe} os switch --hostname quadraticserver --target-host 192.168.0.132"; + }; } diff --git a/modules/common/run0.nix b/modules/common/run0.nix index ec62ce1..99d9a4f 100644 --- a/modules/common/run0.nix +++ b/modules/common/run0.nix @@ -1,7 +1,7 @@ {pkgs, ...}: { - environment.systemPackages = [(pkgs.writeShellScriptBin "sudo" "run0 $@")]; - security = { - sudo.enable = false; - pam.services.systemd-run0 = {}; - }; + # environment.systemPackages = [(pkgs.writeShellScriptBin "sudo" "run0 $@")]; + # security = { + # sudo.enable = false; + # pam.services.systemd-run0 = {}; + # }; } diff --git a/modules/common/trash.nix b/modules/common/trash.nix new file mode 100644 index 0000000..d4a204b --- /dev/null +++ b/modules/common/trash.nix @@ -0,0 +1 @@ +{pkgs, ...}: {environment.shellAliases.rm = "${pkgs.glib}/bin/gio trash";} diff --git a/wrappers/common/bat.nix b/wrappers/common/bat.nix deleted file mode 100644 index 5271789..0000000 --- a/wrappers/common/bat.nix +++ /dev/null @@ -1,6 +0,0 @@ -{pkgs, ...}: { - wrappers.bat = { - basePackage = pkgs.bat; - flags = ["--theme" "Nord"]; - }; -} diff --git a/wrappers/common/eza.nix b/wrappers/common/eza.nix deleted file mode 100644 index 692794a..0000000 --- a/wrappers/common/eza.nix +++ /dev/null @@ -1,12 +0,0 @@ -{pkgs, ...}: { - wrappers.eza = { - basePackage = pkgs.eza; - flags = [ - "--all" - "--icons" - "--hyperlink" - "--color=always" - "--group-directories-first" - ]; - }; -} diff --git a/wrappers/common/neofetch/default.nix b/wrappers/common/neofetch/default.nix deleted file mode 100644 index 2143a75..0000000 --- a/wrappers/common/neofetch/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{pkgs, ...}: { - wrappers.neofetch = { - basePackage = pkgs.hyfetch; # Neowofetch - flags = [ - "--config" - ./neofetch.conf - ]; - }; -}