restruct
This commit is contained in:
parent
f6f61a9250
commit
6a4d493911
8 changed files with 575 additions and 334 deletions
184
QUICKREF.md
184
QUICKREF.md
|
|
@ -3,94 +3,148 @@
|
|||
## Essential Commands
|
||||
|
||||
```bash
|
||||
# Rebuild system with new configuration
|
||||
sudo nixos-rebuild switch --flake .#nxs
|
||||
# Rebuild system with new configuration
|
||||
sudo
|
||||
nixos-rebuild
|
||||
switch - -flake.#nxs
|
||||
|
||||
# Test without making permanent changes
|
||||
sudo nixos-rebuild test --flake .#nxs
|
||||
sudo nixos-rebuild
|
||||
test - -flake.#nxs
|
||||
|
||||
# Build without activating
|
||||
sudo nixos-rebuild build --flake .#nxs
|
||||
sudo nixos-rebuild
|
||||
build - -flake.#nxs
|
||||
|
||||
# Check flake syntax
|
||||
nix flake check
|
||||
nix flake
|
||||
check
|
||||
|
||||
# Update all dependencies
|
||||
nix flake update
|
||||
# Update all dependencies
|
||||
nix
|
||||
flake
|
||||
update
|
||||
|
||||
# Search for packages
|
||||
nix search nixpkgs <package-name>
|
||||
```
|
||||
# Search for packages
|
||||
nix
|
||||
search
|
||||
nixpkgs <package-name>
|
||||
```
|
||||
|
||||
## File Layout
|
||||
## File Layout
|
||||
|
||||
| Path | Purpose |
|
||||
|------|---------|
|
||||
|
|
||||
Path |
|
||||
Purpose |
|
||||
| - -----|---------|
|
||||
| `flake.nix` | Main flake entry point |
|
||||
| `hosts/nxs/default.nix` | System configuration |
|
||||
| `hosts/nxs/hardware.nix` | Hardware settings |
|
||||
| `hosts/nxs/home.nix` | User environment |
|
||||
| `modules/system/` | Reusable system modules |
|
||||
| `modules/home/` | Reusable user modules |
|
||||
| `hosts/nxs/default.nix` |
|
||||
System
|
||||
configuration |
|
||||
| `hosts/nxs/hardware.nix` |
|
||||
Hardware
|
||||
settings |
|
||||
| `hosts/nxs/home.nix` |
|
||||
User
|
||||
environment |
|
||||
| `modules/system/` |
|
||||
Reusable
|
||||
system
|
||||
modules |
|
||||
| `modules/home/` |
|
||||
Reusable
|
||||
user
|
||||
modules |
|
||||
|
||||
## Quick Edits
|
||||
## Quick Edits
|
||||
|
||||
```bash
|
||||
# Edit system config
|
||||
vim hosts/nxs/default.nix
|
||||
```
|
||||
bash
|
||||
# Edit system config
|
||||
vim hosts/nxs/default.nix
|
||||
|
||||
# Edit user packages/programs
|
||||
vim hosts/nxs/home.nix
|
||||
# Edit user packages/programs
|
||||
vim hosts/nxs/home.nix
|
||||
|
||||
# Edit Neovim config
|
||||
vim modules/home/neovim/default.nix
|
||||
# Edit Neovim config
|
||||
vim modules/home/neovim/default.nix
|
||||
|
||||
# Add language support to Neovim
|
||||
vim modules/home/neovim/languages/<lang>.nix
|
||||
```
|
||||
# Add language support to Neovim
|
||||
vim modules/home/neovim/languages/
|
||||
<lang>.nix
|
||||
```
|
||||
|
||||
## Where to Add Things
|
||||
## Where to Add Things
|
||||
|
||||
| What | Where | File |
|
||||
|------|-------|------|
|
||||
|
|
||||
What |
|
||||
Where |
|
||||
File |
|
||||
| - -----|-------|------|
|
||||
| System package | hosts/nxs/ | default.nix → environment.systemPackages |
|
||||
| User package | hosts/nxs/ | home.nix → home.packages |
|
||||
| System service | modules/system/ | relevant-module.nix |
|
||||
| User program config | modules/home/ | program-name.nix |
|
||||
| Boot settings | modules/system/ | boot.nix |
|
||||
| Desktop/GUI | modules/system/ | desktop.nix |
|
||||
|
|
||||
User
|
||||
package | hosts/nxs/ |
|
||||
home.nix →
|
||||
home.packages |
|
||||
|
|
||||
System
|
||||
service | modules/system/ |
|
||||
relevant-module.nix |
|
||||
|
|
||||
User
|
||||
program
|
||||
config | modules/home/ |
|
||||
program-name.nix |
|
||||
|
|
||||
Boot
|
||||
settings | modules/system/ |
|
||||
boot.nix |
|
||||
| Desktop/GUI | modules/system/ |
|
||||
desktop.nix |
|
||||
|
||||
## Git Workflow
|
||||
## Git Workflow
|
||||
|
||||
```bash
|
||||
# Check status
|
||||
git status
|
||||
```
|
||||
bash
|
||||
# Check status
|
||||
git
|
||||
status
|
||||
|
||||
# View changes
|
||||
git diff
|
||||
# View changes
|
||||
git
|
||||
diff
|
||||
|
||||
# Stage all changes
|
||||
git add -A
|
||||
# Stage all changes
|
||||
git
|
||||
add - A
|
||||
|
||||
# Commit
|
||||
git commit -m "description"
|
||||
# Commit
|
||||
git
|
||||
commit - m "description"
|
||||
|
||||
# Push
|
||||
git push
|
||||
```
|
||||
|
||||
## Maintenance
|
||||
|
||||
```bash
|
||||
# Clean old generations (7 days)
|
||||
sudo nix-collect-garbage --delete-older-than 7d
|
||||
|
||||
# Optimize store
|
||||
nix-store --optimise
|
||||
|
||||
# List generations
|
||||
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
|
||||
|
||||
# Rollback
|
||||
sudo nixos-rebuild switch --rollback
|
||||
# Push
|
||||
git
|
||||
push
|
||||
```
|
||||
|
||||
## Maintenance
|
||||
|
||||
```
|
||||
bash
|
||||
# Clean old generations (7 days)
|
||||
sudo
|
||||
nix-collect-garbage - -delete-older-than 7 d
|
||||
|
||||
# Optimize store
|
||||
nix-store - -optimise
|
||||
|
||||
# List generations
|
||||
sudo
|
||||
nix-env - -list-generations - -profile /nix/var/nix/profiles/system
|
||||
|
||||
# Rollback
|
||||
sudo
|
||||
nixos-rebuild
|
||||
switch - -rollback
|
||||
```
|
||||
|
|
|
|||
462
flake.lock
generated
462
flake.lock
generated
|
|
@ -1,236 +1,236 @@
|
|||
{
|
||||
"nodes": {
|
||||
"blueprint": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nix-ai-tools",
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763308703,
|
||||
"narHash": "sha256-O9Y+Wer8wOh+N+4kcCK5p/VLrXyX+ktk0/s3HdZvJzk=",
|
||||
"owner": "numtide",
|
||||
"repo": "blueprint",
|
||||
"rev": "5a9bba070f801d63e2af3c9ef00b86b212429f4f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "blueprint",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixvim",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763759067,
|
||||
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765202646,
|
||||
"narHash": "sha256-Cgceqa+xPgI8JiS1fMaviGw4dthTeW2RqE6RUR4OcS8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "caa47b637d877124ac891a64abc14de09fce1675",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-ai-tools": {
|
||||
"inputs": {
|
||||
"blueprint": "blueprint",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765203591,
|
||||
"narHash": "sha256-LAWxwGYTM6bZqTode/bHmR2tX96X4u0JQDOaHxUSNkA=",
|
||||
"owner": "numtide",
|
||||
"repo": "nix-ai-tools",
|
||||
"rev": "edfd764a49e2440fd2169c9e14d8fd6b7df11135",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "nix-ai-tools",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1764947035,
|
||||
"narHash": "sha256-EYHSjVM4Ox4lvCXUMiKKs2vETUSL5mx+J2FfutM7T9w=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a672be65651c80d3f592a89b3945466584a22069",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1764950072,
|
||||
"narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f61125a668a320878494449750330ca58b78c557",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixvim": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765210697,
|
||||
"narHash": "sha256-Gq6/MRmBhNjGdMDFvZBcnPcfuw/j/dk6N1Y9R+HSA7Q=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixvim",
|
||||
"rev": "05c57f2e74d39e87ef0696e450b7e817dde5378d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"home-manager": "home-manager",
|
||||
"nix-ai-tools": "nix-ai-tools",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixvim": "nixvim"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nix-ai-tools",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1762938485,
|
||||
"narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
"blueprint": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nix-ai-tools",
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763308703,
|
||||
"narHash": "sha256-O9Y+Wer8wOh+N+4kcCK5p/VLrXyX+ktk0/s3HdZvJzk=",
|
||||
"owner": "numtide",
|
||||
"repo": "blueprint",
|
||||
"rev": "5a9bba070f801d63e2af3c9ef00b86b212429f4f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "blueprint",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixvim",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763759067,
|
||||
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765337252,
|
||||
"narHash": "sha256-HuWQp8fM25fyWflbuunQkQI62Hg0ecJxWD52FAgmxqY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "13cc1efd78b943b98c08d74c9060a5b59bf86921",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-ai-tools": {
|
||||
"inputs": {
|
||||
"blueprint": "blueprint",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765441138,
|
||||
"narHash": "sha256-FePRiHnpHiee34zY/09G/DmqVgbKRJqyQ5M2VU4Mwl8=",
|
||||
"owner": "numtide",
|
||||
"repo": "nix-ai-tools",
|
||||
"rev": "041cfda7939ff1f3776893896d6c8785c3373295",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "nix-ai-tools",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1765270179,
|
||||
"narHash": "sha256-g2a4MhRKu4ymR4xwo+I+auTknXt/+j37Lnf0Mvfl1rE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "677fbe97984e7af3175b6c121f3c39ee5c8d62c9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1765186076,
|
||||
"narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixvim": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765413189,
|
||||
"narHash": "sha256-CEXdMdYV6ETQF/ol8z2odP55b0P/+2UjZczNeBAxBOA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixvim",
|
||||
"rev": "f61667b37eed4f17e19a38eb1d31f0b6be6e52a8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"home-manager": "home-manager",
|
||||
"nix-ai-tools": "nix-ai-tools",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixvim": "nixvim"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nix-ai-tools",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1762938485,
|
||||
"narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
imports = [
|
||||
./hardware.nix
|
||||
../../modules/system/boot.nix
|
||||
../../modules/system/nvidia.nix
|
||||
../../modules/system/hardware.nix
|
||||
../../modules/system/desktop.nix
|
||||
../../modules/system/power-management.nix
|
||||
|
|
@ -29,28 +30,50 @@
|
|||
enable = true;
|
||||
enableOnBoot = true;
|
||||
};
|
||||
virtualisation = {
|
||||
containers.enable = true;
|
||||
podman = {
|
||||
enable = true;
|
||||
defaultNetwork.settings.dns_enabled = true; # Required for containers under podman-compose to be able to talk to each other.
|
||||
virtualisation = {
|
||||
containers.enable = true;
|
||||
podman = {
|
||||
enable = true;
|
||||
defaultNetwork.settings.dns_enabled = true; # Required for containers under podman-compose to be able to talk to each other.
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nix.settings = {
|
||||
substituters = [
|
||||
"https://cache.nixos-cuda.org"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M="
|
||||
];
|
||||
};
|
||||
nix.settings = {
|
||||
substituters = [
|
||||
"https://cache.nixos-cuda.org"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M="
|
||||
];
|
||||
};
|
||||
|
||||
# Users
|
||||
programs.fish.enable = true;
|
||||
users.users.narrator = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" "docker" ];
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"docker"
|
||||
"sudo"
|
||||
"uucp"
|
||||
"lp"
|
||||
"adm"
|
||||
"input"
|
||||
"uinput"
|
||||
"docker"
|
||||
"lxd"
|
||||
"libvirtd"
|
||||
"vboxsf"
|
||||
"vboxusers"
|
||||
"wireshark"
|
||||
"networkmanager"
|
||||
"network"
|
||||
"audio"
|
||||
"storage"
|
||||
"libvirtd"
|
||||
"video"
|
||||
"render"
|
||||
];
|
||||
shell = pkgs.fish;
|
||||
packages = with pkgs; [ tree ];
|
||||
};
|
||||
|
|
@ -73,7 +96,7 @@ nix.settings = {
|
|||
i3
|
||||
awesome
|
||||
|
||||
(ollama.override {
|
||||
(ollama.override {
|
||||
acceleration = "cuda";
|
||||
})
|
||||
blueman
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
stateVersion = "26.05";
|
||||
|
||||
packages = with pkgs; [
|
||||
kitty
|
||||
spotify
|
||||
aider-chat
|
||||
distrobox
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
set fish_greeting
|
||||
direnv hook fish | source
|
||||
zoxide init fish | source
|
||||
set fish_tmux_autostart true
|
||||
'';
|
||||
shellAbbrs = {
|
||||
# basics
|
||||
|
|
@ -110,6 +111,15 @@
|
|||
hash = "sha256-LtiaIlMJ1ZyzNvBzi5uPztoBV6G57Q6z6HUFcOBi9cg=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "tmux.fish";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "budimanjojo";
|
||||
repo = "tmux.fish";
|
||||
rev = "db0030b7f4f78af4053dc5c032c7512406961ea5";
|
||||
hash = "sha256-rRibn+FN8VNTSC1HmV05DXEa6+3uOHNx03tprkcjjs8=";
|
||||
};
|
||||
}
|
||||
];
|
||||
functions.fish_greeting.body = ''
|
||||
fish_logo
|
||||
|
|
|
|||
|
|
@ -3,24 +3,10 @@
|
|||
{
|
||||
hardware = {
|
||||
graphics.enable = true;
|
||||
graphics.enable32Bit = true;
|
||||
bluetooth.enable = true;
|
||||
|
||||
nvidia = {
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = true;
|
||||
open = true;
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.beta;
|
||||
forceFullCompositionPipeline = true;
|
||||
|
||||
prime = {
|
||||
offload.enable = true;
|
||||
amdgpuBusId = "PCI:7:0:0";
|
||||
nvidiaBusId = "PCI:1:0:0";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
hardware.tuxedo-keyboard.enable = true;
|
||||
services.xserver = {
|
||||
videoDrivers = [ "amdgpu" "nvidia" ];
|
||||
deviceSection = ''
|
||||
|
|
|
|||
167
modules/system/nvidia.nix
Normal file
167
modules/system/nvidia.nix
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
# https://markwatkinson.com/knowledge/linux/nvidia-dgpu-power/
|
||||
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, inputs
|
||||
, ...
|
||||
}:
|
||||
{
|
||||
|
||||
# Enable Nix cache for CUDA packages
|
||||
nix.settings = {
|
||||
substituters = [ "https://cuda-maintainers.cachix.org" ];
|
||||
trusted-public-keys = [
|
||||
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
|
||||
];
|
||||
};
|
||||
|
||||
boot = {
|
||||
# Nvidia-specific: kernel parameters
|
||||
# See: https://download.nvidia.com/XFree86/Linux-x86_64/580.65.06/README/dynamicpowermanagement.html
|
||||
# Preserving video memory in early KMS fails, see: https://www.reddit.com/r/hyprland/comments/1cyb0h7/hibernate_on_nvidia
|
||||
# Do not load nvidia in early KMS (boot.initrd.kernelModules), load via boot.kernelModules instead
|
||||
kernelModules = [
|
||||
"nvidia"
|
||||
"nvidia_drm"
|
||||
"nvidia_modeset"
|
||||
# "nvidia_uvm" # Don't load it early as it causes power-management issues
|
||||
];
|
||||
|
||||
kernelParams = [
|
||||
# NVIDIA PRIME Offloading / suspend helpers
|
||||
"nvidia-drm.modeset=1" # Required for PRIME render offload and proper Wayland/XWayland integration
|
||||
"nvidia.NVreg_UsePageAttributeTable=1" # nvidia assume that by default your CPU does not support PAT; why this isn't default is beyond me.
|
||||
"nvidia.NVreg_InitializeSystemMemoryAllocations=0" # Disable pre-allocation of system memory for pinned allocations; helps with memory fragmentation
|
||||
"nvidia.NVreg_DeviceFileUID=0" # Set device file ownership to root
|
||||
"nvidia.NVreg_DeviceFileGID=26" # 26 is the GID of the "video" group on NixOS
|
||||
"nvidia.NVreg_DeviceFileMode=0660" # Set device file permissions to rw-rw----
|
||||
"nvidia.NVreg_EnableS0ixPowerManagement=1" # Enable S0ix support in NVIDIA driver
|
||||
"nvidia.NVreg_DynamicPowerManagement=0x02" # Enable dynamic power management to let TCC control power limits (0x01=disabled, 0x02=auto, 0x03=always on)
|
||||
"nvidia.NVreg_DynamicPowerManagementVideoMemoryThreshold=0"
|
||||
"nvidia.NVreg_S0ixPowerManagementVideoMemoryThreshold=16384" # 16 GiB; > 12 GiB VRAM, so always copy vram to /dev/shm + power-off
|
||||
"nvidia.NVreg_PreserveVideoMemoryAllocations=1" # Preserve video memory across suspend/resume; required for stable S0ix
|
||||
"nvidia.NVreg_TemporaryFilePath=/dev/shm" # Path to save VRAM contents during suspend; /dev/shm is 47G and VRAM is 12G
|
||||
];
|
||||
};
|
||||
|
||||
hardware = {
|
||||
# NVIDIA hybrid graphics setup (PRIME offload mode for battery efficiency; switch to sync if needed for performance)
|
||||
nvidia = {
|
||||
# Modesetting is required.
|
||||
modesetting.enable = true;
|
||||
|
||||
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
|
||||
# Enable this if you have graphical corruption issues or application crashes after waking
|
||||
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
|
||||
# of just the bare essentials.
|
||||
powerManagement.enable = true; # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/472
|
||||
# [ 363.611590] NVRM: GPU 0000:02:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface. Please refer to the 'Configuring Power Management Support' section in the driver README.
|
||||
|
||||
# Fine-grained power management. Turns off GPU when not in use.
|
||||
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
|
||||
powerManagement.finegrained = true;
|
||||
|
||||
# Use the Nvidia open source kernel module (not to be confused with the
|
||||
# independent third-party "nouveau" open source driver).
|
||||
# Support is limited to the Turing and later architectures. Full list of
|
||||
# supported GPUs is at:
|
||||
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
|
||||
# Only available from driver 515.43.04+
|
||||
# An important note to take is that the option hardware.nvidia.open
|
||||
# should only be set to false if you have a GPU with an older
|
||||
# architecture than Turing (older than the RTX 20-Series).
|
||||
open = true;
|
||||
|
||||
# Enable the Nvidia settings menu,
|
||||
# accessible via `nvidia-settings`.
|
||||
nvidiaSettings = true;
|
||||
|
||||
# Disable NVIDIA persistence mode so the driver can be unloaded when not in use.
|
||||
nvidiaPersistenced = false;
|
||||
|
||||
# Optionally, you may need to select the appropriate driver version for your specific GPU.
|
||||
package = config.boot.kernelPackages.nvidiaPackages.beta;
|
||||
|
||||
prime = {
|
||||
offload = {
|
||||
enable = true;
|
||||
enableOffloadCmd = true;
|
||||
};
|
||||
# Bus IDs: Run `lspci | egrep 'VGA|3D'` post-install to confirm; these are typical for Intel + NVIDIA laptops
|
||||
amdgpuBusId = "PCI:7:0:0";
|
||||
nvidiaBusId = "PCI:1:0:0";
|
||||
};
|
||||
};
|
||||
|
||||
# Enable Nvidia graphics acceleration
|
||||
graphics = {
|
||||
extraPackages = with pkgs; [
|
||||
libva-vdpau-driver
|
||||
#vaapiVdpau # For Nvidia VDPAU backend
|
||||
];
|
||||
extraPackages32 = with pkgs.pkgsi686Linux; [
|
||||
# vaapiVdpau # For Nvidia VDPAU backend
|
||||
libva-vdpau-driver
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Custom udev rules for NVIDIA GPU
|
||||
# See: https://download.nvidia.com/XFree86/Linux-x86_64/580.65.06/README/dynamicpowermanagement.html
|
||||
services.udev.extraRules = ''
|
||||
# Remove NVIDIA USB xHCI Host Controller devices, if present
|
||||
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
|
||||
|
||||
# Remove NVIDIA USB Type-C UCSI devices, if present
|
||||
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"
|
||||
|
||||
# Remove NVIDIA Audio devices, if present
|
||||
# ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
|
||||
|
||||
# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
|
||||
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
|
||||
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto"
|
||||
|
||||
# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
|
||||
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
|
||||
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"
|
||||
'';
|
||||
|
||||
# Enable NVIDIA Dynamic Boost for automatic CPU/GPU power management
|
||||
hardware.nvidia.dynamicBoost.enable = true;
|
||||
|
||||
# Enable nvidia-suspend service
|
||||
systemd.services.nvidia-suspend = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.mkForce "${config.boot.kernelPackages.nvidiaPackages.latest}/bin/nvidia-sleep.sh suspend";
|
||||
};
|
||||
before = [ "systemd-suspend.service" ];
|
||||
wantedBy = [ "suspend.target" ];
|
||||
};
|
||||
|
||||
systemd.services.nvidia-hibernate = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.mkForce "${config.boot.kernelPackages.nvidiaPackages.latest}/bin/nvidia-sleep.sh hibernate";
|
||||
};
|
||||
before = [ "systemd-hibernate.service" ];
|
||||
wantedBy = [ "hibernate.target" ];
|
||||
};
|
||||
|
||||
systemd.services.nvidia-resume = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.mkForce "${config.boot.kernelPackages.nvidiaPackages.latest}/bin/nvidia-sleep.sh resume";
|
||||
};
|
||||
after = [
|
||||
"systemd-suspend.service"
|
||||
"systemd-hibernate.service"
|
||||
];
|
||||
wantedBy = [
|
||||
"suspend.target"
|
||||
"hibernate.target"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -7,12 +7,12 @@
|
|||
lidSwitchExternalPower = "lock";
|
||||
};
|
||||
|
||||
systemd.sleep.extraConfig = ''
|
||||
AllowSuspend=no
|
||||
AllowHibernation=no
|
||||
AllowHybridSleep=no
|
||||
AllowSuspendThenHibernate=no
|
||||
'';
|
||||
#systemd.sleep.extraConfig = ''
|
||||
# AllowSuspend=no
|
||||
# AllowHibernation=no
|
||||
# AllowHybridSleep=no
|
||||
# AllowSuspendThenHibernate=no
|
||||
#'';
|
||||
|
||||
systemd.services = {
|
||||
systemd-suspend.environment.SYSTEMD_SLEEP_FREEZE_USER_SESSIONS = "false";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue