From c8569a12246df071d41103a1f51b976aee3454b6 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Wed, 8 Oct 2025 22:28:06 +0200 Subject: [PATCH] add cli to main nix repo --- cli/flake.lock | 48 +++++++++++++++++++++++++ cli/flake.nix | 42 ++++++++++++++++++++++ cli/home.nix | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ cli/pkgs.nix | 46 ++++++++++++++++++++++++ cli/profiles.nix | 26 ++++++++++++++ 5 files changed, 253 insertions(+) create mode 100644 cli/flake.lock create mode 100644 cli/flake.nix create mode 100644 cli/home.nix create mode 100644 cli/pkgs.nix create mode 100644 cli/profiles.nix diff --git a/cli/flake.lock b/cli/flake.lock new file mode 100644 index 0000000..edaab72 --- /dev/null +++ b/cli/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1759853171, + "narHash": "sha256-uqbhyXtqMbYIiMqVqUhNdSuh9AEEkiasoK3mIPIVRhk=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "1a09eb84fa9e33748432a5253102d01251f72d6d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1759831965, + "narHash": "sha256-vgPm2xjOmKdZ0xKA6yLXPJpjOtQPHfaZDRtH+47XEBo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c9b6fb798541223bbb396d287d16f43520250518", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/cli/flake.nix b/cli/flake.nix new file mode 100644 index 0000000..83833bc --- /dev/null +++ b/cli/flake.nix @@ -0,0 +1,42 @@ +{ + description = "Server Shell"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + nixpkgs, + home-manager, + ... + }: + let + profiles = import ./profiles.nix; + in + { + homeConfigurations = nixpkgs.lib.genAttrs (builtins.map (p: p.name) profiles) ( + profile: + let + p = (nixpkgs.lib.findFirst (p: p.name == profile) null profiles); + system = p.architecture; + pkgs = nixpkgs.legacyPackages.${system}; + in + home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + modules = [ ./home.nix ]; + + extraSpecialArgs = { + username = p.username; + homeDirectory = p.homeDirectory; + name = p.name; + }; + } + ); + }; +} diff --git a/cli/home.nix b/cli/home.nix new file mode 100644 index 0000000..fda323d --- /dev/null +++ b/cli/home.nix @@ -0,0 +1,91 @@ +{ + config, + pkgs, + username, + name, + homeDirectory, + ... +}: + +{ + home.username = username; + home.homeDirectory = homeDirectory; + + home.stateVersion = "25.11"; + + home.packages = (import ./pkgs.nix { inherit pkgs; }); + + fonts.fontconfig.enable = true; + + home = { + sessionVariables = { + EDITOR = "nvim"; + }; + + shellAliases = { + # Rust re-maps + l = "eza -a1lh"; + ls = "eza"; + cat = "bat"; + cd = "z"; + + # QOL + dc = "docker compose"; + rsync = "rsync -az --info=progress2"; + t = "tmux new-session -A -s main"; + e = "nvim"; + g = "lazygit"; + d = "lazydocker"; + p = "pnpm"; + px = "pnpm -s dlx"; + n = "fnm use --install-if-missing"; + c = "pwd | pbcopy"; + k = "kubectl"; + + hm = "nix run home-manager/master -- switch --flake github:cupcakearmy/nix-cli/v3#${name} -b backup"; + }; + }; + + programs = { + direnv.enable = true; + zoxide.enable = true; + + fish = { + enable = true; + interactiveShellInit = '' + if type -q starship + starship init fish | source + end + if type -q fnm + fnm env --use-on-cd | source + end + if type -q nvs + nvs env --source | source + end + ''; + }; + bash = { + enable = true; + }; + tmux = { + enable = true; + clock24 = true; + mouse = true; + extraConfig = '' + # switch panes using Alt-arrow without prefix + bind -n M-Left select-pane -L + bind -n M-Right select-pane -R + bind -n M-Up select-pane -U + bind -n M-Down select-pane -D + + # switch panes using jkhl + bind h select-pane -L + bind l select-pane -R + bind j select-pane -U + bind k select-pane -D + ''; + shell = "${pkgs.fish}/bin/fish"; + terminal = "tmux-256color"; + }; + }; +} diff --git a/cli/pkgs.nix b/cli/pkgs.nix new file mode 100644 index 0000000..1301cd0 --- /dev/null +++ b/cli/pkgs.nix @@ -0,0 +1,46 @@ +{ pkgs }: +with pkgs; +[ + # Base + tmux + git + git-lfs + git-crypt + gnutar + gnupg + htop + btop + rclone + rename + tmux + tree + wget + rsync + yq + delta + + # Rust utils + bat + eza + fd + ripgrep + ripgrep-all + zoxide + uutils-coreutils-noprefix + dust + yazi + starship + + # Dev + lazydocker + k9s + kubectl + + # Editor + neovim + fzf + lazygit + + # Fonts + nerd-fonts.jetbrains-mono +] diff --git a/cli/profiles.nix b/cli/profiles.nix new file mode 100644 index 0000000..f7607b1 --- /dev/null +++ b/cli/profiles.nix @@ -0,0 +1,26 @@ +[ + { + name = "root_x86_linux"; + username = "root"; + architecture = "x86_64-linux"; + homeDirectory = "/root"; + } + { + name = "root_x86_macos"; + username = "root"; + architecture = "x86_64-darwin"; + homeDirectory = "/root"; + } + { + name = "root_arm_linux"; + username = "root"; + architecture = "aarch64-linux"; + homeDirectory = "/root"; + } + { + name = "root_arm_macos"; + username = "root"; + architecture = "aarch64-darwin"; + homeDirectory = "/root"; + } +]