mirror of
https://github.com/cupcakearmy/nix-cli.git
synced 2025-12-07 22:35:03 +00:00
Compare commits
3 Commits
f47c09f5aa
...
v2
| Author | SHA1 | Date | |
|---|---|---|---|
| cc099305dd | |||
| 7c533ae24b | |||
| 7127578fc7 |
53
README.md
53
README.md
@@ -1,28 +1,37 @@
|
||||
# Nix
|
||||
# My Nix Server Configuration
|
||||
|
||||
Nix setup for server
|
||||
This Nix flake configures a server with common tools and shell aliases.
|
||||
|
||||
## Install
|
||||
## 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
|
||||
# First time install
|
||||
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --determinate
|
||||
|
||||
# Install / Update
|
||||
nix run home-manager -- switch --flake github:cupcakearmy/nix-cli#root -b bkp
|
||||
nix run home-manager/master -- switch --flake github:<your-github-username>/nix-server#<your-username>
|
||||
```
|
||||
|
||||
## 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
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
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.
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
|
||||
|
||||
palette:
|
||||
error-0: '#ff4040'
|
||||
error-10: '#e23629'
|
||||
error-15: '#d33220'
|
||||
error-20: '#c52e18'
|
||||
error-30: '#a8280d'
|
||||
error-40: '#8a2106'
|
||||
error-5: '#f03a34'
|
||||
error-50: '#6d1b02'
|
||||
error-60: '#501401'
|
||||
error-70: '#330d00'
|
||||
main-0: '#f7fbff'
|
||||
main-10: '#b4cafd'
|
||||
main-15: '#95a9fc'
|
||||
main-20: '#7783fa'
|
||||
main-30: '#5348f4'
|
||||
main-40: '#4826e8'
|
||||
main-5: '#d6e6fe'
|
||||
main-50: '#3e10ca'
|
||||
main-60: '#22036e'
|
||||
main-70: '#020008'
|
||||
success-0: '#40ff46'
|
||||
success-10: '#29e243'
|
||||
success-15: '#20d342'
|
||||
success-20: '#18c541'
|
||||
success-30: '#0da83d'
|
||||
success-40: '#068a36'
|
||||
success-5: '#34f044'
|
||||
success-50: '#026d2d'
|
||||
success-60: '#015022'
|
||||
success-70: '#003316'
|
||||
warning-0: '#ffff40'
|
||||
warning-10: '#dae229'
|
||||
warning-15: '#c8d320'
|
||||
warning-20: '#b6c518'
|
||||
warning-30: '#96a80d'
|
||||
warning-40: '#788a06'
|
||||
warning-5: '#ecf034'
|
||||
warning-50: '#5d6d02'
|
||||
warning-60: '#435001'
|
||||
warning-70: '#2a3300'
|
||||
blocks:
|
||||
- type: prompt
|
||||
alignment: left
|
||||
segments:
|
||||
- leading_diamond:
|
||||
foreground: p:main-70
|
||||
background: p:main-5
|
||||
type: os
|
||||
style: diamond
|
||||
- properties:
|
||||
style: full
|
||||
template: " \uf0e7 "
|
||||
foreground: p:main-70
|
||||
powerline_symbol:
|
||||
background: p:error-15
|
||||
type: root
|
||||
style: powerline
|
||||
- properties:
|
||||
style: full
|
||||
template: ' {{ .Path }} '
|
||||
foreground: p:main-0
|
||||
powerline_symbol:
|
||||
background: p:main-40
|
||||
type: path
|
||||
style: powerline
|
||||
- template: ' {{ .HEAD }} '
|
||||
foreground: p:main-70
|
||||
powerline_symbol:
|
||||
background: p:warning-10
|
||||
type: git
|
||||
style: powerline
|
||||
- type: prompt
|
||||
alignment: right
|
||||
segments:
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: python
|
||||
style: dynamic
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: go
|
||||
style: dynamic
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: node
|
||||
style: dynamic
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
template: '{{ .Context }}{{ if .Namespace }}::{{ .Namespace }}{{ end }}'
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: kubectl
|
||||
style: dynamic
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
template: '{{ .Icon }} {{ .Server }}'
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: docker
|
||||
style: dynamic
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: rust
|
||||
style: dynamic
|
||||
- leading_diamond:
|
||||
trailing_diamond:
|
||||
foreground: p:main-70
|
||||
background: p:main-10
|
||||
type: battery
|
||||
style: dynamic
|
||||
- properties:
|
||||
always_enabled: true
|
||||
leading_diamond:
|
||||
template: "{{ if gt .Code 0 }}\uf00d {{ .Code }} {{ .Meaning }}{{ else }}\uf42e{{ end }}"
|
||||
foreground: p:main-70
|
||||
type: status
|
||||
style: diamond
|
||||
background_templates:
|
||||
- '{{ if gt .Code 0 }}p:error-0{{ else }}p:main-10{{ end }}'
|
||||
- properties:
|
||||
always_enabled: true
|
||||
style: round
|
||||
foreground: p:main-70
|
||||
powerline_symbol:
|
||||
background: p:main-5
|
||||
type: executiontime
|
||||
style: powerline
|
||||
- properties:
|
||||
time_format: '15:04:05'
|
||||
template: ' {{ .CurrentDate | date .Format }} '
|
||||
foreground: p:main-70
|
||||
powerline_symbol:
|
||||
background: p:main-0
|
||||
type: time
|
||||
style: powerline
|
||||
- type: prompt
|
||||
alignment: left
|
||||
segments:
|
||||
- properties:
|
||||
always_enabled: true
|
||||
template: '❯ '
|
||||
foreground: p:main-15
|
||||
type: status
|
||||
style: plain
|
||||
foreground_templates:
|
||||
- '{{ if gt .Code 0 }}p:error-15{{ end }}'
|
||||
newline: true
|
||||
version: 3
|
||||
|
||||
46
flake.lock
generated
46
flake.lock
generated
@@ -1,5 +1,23 @@
|
||||
{
|
||||
"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": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -7,11 +25,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 +40,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1735471104,
|
||||
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
|
||||
"lastModified": 1759733170,
|
||||
"narHash": "sha256-TXnlsVb5Z8HXZ6mZoeOAIwxmvGHp1g4Dw89eLvIwKVI=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
|
||||
"rev": "8913c168d1c56dc49a7718685968f38752171c3b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -38,9 +56,25 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"home-manager": "home-manager",
|
||||
"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",
|
||||
|
||||
60
flake.nix
60
flake.nix
@@ -1,29 +1,57 @@
|
||||
{
|
||||
description = "Home Manager configuration of root";
|
||||
description = "A simple Nix flake for server configuration";
|
||||
|
||||
inputs = {
|
||||
# Specify the source of Home Manager and Nixpkgs.
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, home-manager, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
homeConfigurations."root" = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
home-manager,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
# This is the main entry point for a user's home configuration.
|
||||
# The user should be changed to the actual username.
|
||||
username = "root";
|
||||
in
|
||||
{
|
||||
packages.default = pkgs.btop;
|
||||
|
||||
# Specify your home configuration modules here, for example,
|
||||
# the path to your home.nix.
|
||||
modules = [ ./home.nix ];
|
||||
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
(
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
home.username = username;
|
||||
home.homeDirectory = "/home/${username}";
|
||||
|
||||
# Optionally use extraSpecialArgs
|
||||
# to pass through arguments to home.nix
|
||||
};
|
||||
};
|
||||
home.stateVersion = "23.11"; # Please change this to your version.
|
||||
|
||||
home.alias = {
|
||||
l = "ls -hal";
|
||||
};
|
||||
|
||||
home.packages = [
|
||||
pkgs.btop
|
||||
];
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
76
home.nix
76
home.nix
@@ -1,76 +0,0 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
home.username = "root";
|
||||
home.homeDirectory = "/root";
|
||||
|
||||
#
|
||||
# You should not change this value, even if you update Home Manager. If you do
|
||||
# want to update the value, then make sure to first check the Home Manager
|
||||
# release notes.
|
||||
home.stateVersion = "24.05"; # Please read the comment before changing.
|
||||
|
||||
home.packages = [
|
||||
pkgs.neovim
|
||||
pkgs.tmux
|
||||
pkgs.oh-my-posh
|
||||
|
||||
pkgs.git
|
||||
pkgs.gnutar
|
||||
pkgs.btop
|
||||
|
||||
pkgs.rclone
|
||||
|
||||
pkgs.nerd-fonts.jetbrains-mono
|
||||
|
||||
];
|
||||
|
||||
home.file = {
|
||||
".config/omp/config.yaml".source = ./files/omp/config.yaml;
|
||||
};
|
||||
|
||||
home.sessionVariables = {
|
||||
EDITOR = "nvim";
|
||||
};
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
|
||||
home.shellAliases = {
|
||||
l = "ls -hal";
|
||||
dc = "docker compose";
|
||||
rsync = "rsync -az --info=progress2";
|
||||
t = "tmux new-session -A -s main";
|
||||
e = "nvim";
|
||||
hms = "home-manager switch --flake ~/nix#root -b backup";
|
||||
};
|
||||
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
shellInit = ''
|
||||
oh-my-posh init fish --config ~/.config/omp/config.yaml | source
|
||||
'';
|
||||
};
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
};
|
||||
programs.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";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user