Compare commits

...

5 Commits

Author SHA1 Message Date
88a1e08e52 add ame 2025-10-08 21:35:50 +02:00
a2cb841039 reuse variable 2025-10-08 21:32:35 +02:00
91baaf07d7 add profile name 2025-10-08 21:28:56 +02:00
01898ecafc new files 2025-10-08 19:48:34 +02:00
01b6bc1593 delete old 2025-10-08 19:47:45 +02:00
6 changed files with 163 additions and 84 deletions

View File

@@ -1,24 +0,0 @@
# Nix
Nix setup for server
## Install
```bash
# First time install
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
# Install / Update
nix run home-manager -- switch --flake github:cupcakearmy/nix-cli#root -b bkp
```
## Update
This can be run on any machine. Just update and then just rerun on the targets
```bash
nix flake update
# To test
nix run home-manager -- build --flake .#root
```

12
flake.lock generated
View File

@@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1735774425,
"narHash": "sha256-C73gLFnEh8ZI0uDijUgCDWCd21T6I6tsaWgIBHcfAXg=",
"lastModified": 1759853171,
"narHash": "sha256-uqbhyXtqMbYIiMqVqUhNdSuh9AEEkiasoK3mIPIVRhk=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "5f6aa268e419d053c3d5025da740e390b12ac936",
"rev": "1a09eb84fa9e33748432a5253102d01251f72d6d",
"type": "github"
},
"original": {
@@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1735471104,
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
"lastModified": 1759831965,
"narHash": "sha256-vgPm2xjOmKdZ0xKA6yLXPJpjOtQPHfaZDRtH+47XEBo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
"rev": "c9b6fb798541223bbb396d287d16f43520250518",
"type": "github"
},
"original": {

View File

@@ -1,5 +1,5 @@
{
description = "nix base CLI env";
description = "Server Shell";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
@@ -10,15 +10,33 @@
};
outputs =
{ nixpkgs, home-manager, ... }:
{
nixpkgs,
home-manager,
...
}:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
profiles = import ./profiles.nix;
in
{
homeConfigurations."root" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home.nix ];
};
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;
};
}
);
};
}

105
home.nix
View File

@@ -1,76 +1,89 @@
{ config, pkgs, ... }:
{
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 = {
username = "root";
homeDirectory = "/root";
stateVersion = "25.05"; # Please read the comment before changing.
packages = with pkgs; [
neovim
tmux
git
gnutar
btop
# Rust utils
bat
eza
fd
ripgrep
ripgrep-all
zoxide
uutils-coreutils-noprefix
dust
yazi
starship
rclone
nerd-fonts.jetbrains-mono
];
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";
vai = "home-manager switch --flake github:cupcakearmy/nix-cli#root -b backup";
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 = {
home-manager.enable = true;
starship.enable = true;
bash.enable = true;
fish.enable = true;
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 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
'';
# 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";
};

46
pkgs.nix Normal file
View File

@@ -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
]

26
profiles.nix Normal file
View File

@@ -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";
}
]