mirror of
https://github.com/cupcakearmy/nix-cli.git
synced 2025-12-11 16:25:03 +00:00
Compare commits
5 Commits
v2
...
88a1e08e52
| Author | SHA1 | Date | |
|---|---|---|---|
| 88a1e08e52 | |||
| a2cb841039 | |||
| 91baaf07d7 | |||
| 01898ecafc | |||
| 01b6bc1593 |
37
README.md
37
README.md
@@ -1,37 +0,0 @@
|
|||||||
# My Nix Server Configuration
|
|
||||||
|
|
||||||
This Nix flake configures a server with common tools and shell aliases.
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
- [Nix](https://nixos.org/download.html) must be installed on the server.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
1. **Fork this repository on GitHub.**
|
|
||||||
|
|
||||||
2. **Customize your fork:**
|
|
||||||
|
|
||||||
In `flake.nix`, change the `username` variable to your actual username on the server. You can do this directly on GitHub or by cloning your fork locally, making the change, and pushing it.
|
|
||||||
|
|
||||||
3. **Apply the configuration on your server:**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nix run home-manager/master -- switch --flake github:<your-github-username>/nix-server#<your-username>
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, if your GitHub username is `johndoe` and your server username is `john`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nix run home-manager/master -- switch --flake github:johndoe/nix-server#john
|
|
||||||
```
|
|
||||||
|
|
||||||
## Updating
|
|
||||||
|
|
||||||
To update the packages and your configuration on the server, simply run the same command again. Nix will automatically fetch the latest version of your flake from your GitHub repository.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nix run home-manager/master -- switch --flake github:<your-github-username>/nix-server#<your-username>
|
|
||||||
```
|
|
||||||
|
|
||||||
To update the flake's dependencies (like `nixpkgs`), you'll need to update the `flake.lock` file in your repository. You can do this by running `nix flake update` in a local clone of your repository and pushing the changes.
|
|
||||||
40
flake.lock
generated
40
flake.lock
generated
@@ -1,23 +1,5 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -40,11 +22,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759733170,
|
"lastModified": 1759831965,
|
||||||
"narHash": "sha256-TXnlsVb5Z8HXZ6mZoeOAIwxmvGHp1g4Dw89eLvIwKVI=",
|
"narHash": "sha256-vgPm2xjOmKdZ0xKA6yLXPJpjOtQPHfaZDRtH+47XEBo=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8913c168d1c56dc49a7718685968f38752171c3b",
|
"rev": "c9b6fb798541223bbb396d287d16f43520250518",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -56,25 +38,9 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|||||||
59
flake.nix
59
flake.nix
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
description = "A simple Nix flake for server configuration";
|
description = "Server Shell";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
@@ -7,51 +7,36 @@
|
|||||||
url = "github:nix-community/home-manager";
|
url = "github:nix-community/home-manager";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{
|
||||||
self,
|
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
home-manager,
|
home-manager,
|
||||||
flake-utils,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
let
|
||||||
system:
|
profiles = import ./profiles.nix;
|
||||||
let
|
in
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
{
|
||||||
# This is the main entry point for a user's home configuration.
|
homeConfigurations = nixpkgs.lib.genAttrs (builtins.map (p: p.name) profiles) (
|
||||||
# The user should be changed to the actual username.
|
profile:
|
||||||
username = "root";
|
let
|
||||||
in
|
p = (nixpkgs.lib.findFirst (p: p.name == profile) null profiles);
|
||||||
{
|
system = p.architecture;
|
||||||
packages.default = pkgs.btop;
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
|
home-manager.lib.homeManagerConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
modules = [
|
|
||||||
(
|
|
||||||
{ config, pkgs, ... }:
|
|
||||||
{
|
|
||||||
home.username = username;
|
|
||||||
home.homeDirectory = "/home/${username}";
|
|
||||||
|
|
||||||
home.stateVersion = "23.11"; # Please change this to your version.
|
modules = [ ./home.nix ];
|
||||||
|
|
||||||
home.alias = {
|
extraSpecialArgs = {
|
||||||
l = "ls -hal";
|
username = p.username;
|
||||||
};
|
homeDirectory = p.homeDirectory;
|
||||||
|
name = p.name;
|
||||||
home.packages = [
|
};
|
||||||
pkgs.btop
|
}
|
||||||
];
|
);
|
||||||
}
|
};
|
||||||
)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
91
home.nix
Normal file
91
home.nix
Normal file
@@ -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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
46
pkgs.nix
Normal file
46
pkgs.nix
Normal 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
26
profiles.nix
Normal 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";
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user