1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-29 11:07:44 +00:00

Rewrite everything

This commit is contained in:
RGBCube 2023-05-03 11:53:50 +03:00
commit 294739594d
29 changed files with 911 additions and 0 deletions

4
.editorconfig Normal file
View file

@ -0,0 +1,4 @@
[*.nix]
end_of_line = lf
indent_style = space
indent_size = 2

23
.gitignore vendored Normal file
View file

@ -0,0 +1,23 @@
*
!machines/
!machines/asus/
!machines/asus/docker/
!machines/asus/git/
!machines/asus/neovim/
!machines/asus/networkmanager/
!machines/asus/nixpkgs/
!machines/asus/nushell/
!machines/asus/pipewire/
!machines/asus/users/
# !machines/asus/plasma/
!machines/asus/system/
!machines/asus/xserver/
!.editorconfig
!.gitignore
!*.md
!*.nu
!*.nix
!*.sh

21
LICENSE.md Normal file
View file

@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2023-present RGBCube
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

30
README.md Normal file
View file

@ -0,0 +1,30 @@
# My NixOS Configuration
## License
```
MIT License
Copyright (c) 2023-present RGBCube
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

71
flake.nix Normal file
View file

@ -0,0 +1,71 @@
{
description = "My NixOS configuration.";
nixConfig = {
extra-experimental-features = ''
nix-command
flakes
'';
extra-substituters = "https://nix-community.cachix.org";
extra-trusted-public-keys = "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=";
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# plasma-manager = {
# url = "github:pjones/plasma-manager"; # Add "inputs.plasma-manager.homeManagerModules.plasma-manager" to the home-manager.users.${user}.imports
# inputs.nixpkgs.follows = "nixpkgs";
# inputs.home-manager.follows = "home-manager";
# };
};
outputs = {
nixpkgs,
home-manager,
# plasma-manager,
...
}:
let
lib = nixpkgs.lib;
importConfiguration = directory: lib.nixosSystem {
specialArgs = {
inherit lib; # plasma-manager;
pkgs = import nixpkgs {
config.allowUnfree = true;
};
homeManagerConfiguration = attrs:
let
userName = import (directory + "user-name.nix");
in
{
home-manager.users.${userName} = attrs;
};
};
nixosConfigurations.${basename directory} = {
modules = [
directory
{
networking.hostName = basename directory;
}
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
};
in
builtins.foldl lib.recursiveUpdate (builtins.map importConfiguration (builtins.readDir ./machines));
}

14
link.sh Normal file
View file

@ -0,0 +1,14 @@
#!/bin/sh
sudo true
echo "* Cleaning /etc/nixos"
sudo rm -rf /etc/nixos
sudo mkdir /etc/nixos
echo "* Linking files"
sudo ln ./flake.nix /etc/nixos/flake.nix
sudo ln ./flake.lock /etc/nixos/flake.nix
sudo ln -s ./system-configuration /etc/nixos/
sudo ln -s ./home-configuration /etc/nixos/

27
machines/asus/default.nix Normal file
View file

@ -0,0 +1,27 @@
{ homeManagerConfiguration, ... }:
{
system.stateVersion = "22.11";
imports = [
./docker
./git
./neovim
./networkmanager
./nixpkgs
./nushell
./pipewire
# ./plasma
./system
./users
./xserver
];
}
# //
#
# (homeManagerConfiguration {
# imports = [
# plasma-manager.homeManagerModules.plasma-manager
# ];
# })

View file

@ -0,0 +1,5 @@
{ ... }:
{
virtualisation.docker.enable = true;
}

View file

@ -0,0 +1,11 @@
{ homeManagerConfiguration, ... }:
homeManagerConfiguration {
programs.git.enable = true;
programs.git = {
userName = "RGBCube";
userEmail = "RGBCube@users.noreply.github.com";
config.init.defaultBranch = "master";
};
}

View file

@ -0,0 +1,19 @@
{ homeManagerConfiguration, ... }:
homeManagerConfiguration {
# Nuking nano out of orbit.
environment.defaultPackages = [];
programs.nano.syntaxHighlight = false;
programs.neovim.enable = true;
programs.neovim = {
defaultEditor = true;
viAlias = true;
vimAlias = true;
plugins = [
# lunarVim
];
};
}

View file

@ -0,0 +1,5 @@
{ ... }:
{
networking.networkmanager.enable = true;
}

View file

@ -0,0 +1,8 @@
{ pkgs, ... }:
{
nixpkgs.hostPlatform = "x86_64-linux";
environment.systemPackages = import ./packages.nix pkgs;
fonts.fonts = import ./fonts.nix pkgs;
}

View file

@ -0,0 +1,5 @@
pkgs: with pkgs; []
++ [ (nerdfonts.override { fonts = [ # NERD FONTS
"JetBrainsMono"
]; }) ]

View file

@ -0,0 +1,55 @@
pkgs: with pkgs; []
++ [ # EDITORS
# neovim # Declared in neovim/.
jetbrains.idea-ultimate
]
++ [ # VERSION CONTROL
# git # Declared in git/.
]
++ [ # SHELLS
# nushell # Declared in nushell/.
starship
]
++ [ # DEVELOPMENT TOOLS
# docker # Declared in docker/.
bat
]
++ [ # MISCELLANEOUS
htop
neofetch
]
++ [ # PYTHON
(python311.withPackages (pkgs: with pkgs; [
pip
requests
]))
virtualenv
poetry
]
++ [ # APPLICATIONS
firefox
discord
qbittorrent
lightly-qt
]
++ [ # LIBREOFFICE
libreoffice
hunspellDicts.en_US
hunspellDicts.en_GB-ize
]
++ [ # GAMES
openttd
]
++ [ # EMULATION
wine
]

View file

@ -0,0 +1,399 @@
let theme = {
filesize: {|e|
if $e == 0b {
'white'
} else if $e < 1mb {
'cyan'
} else { 'blue' }
}
date: {|| (date now) - $in |
if $in < 1hr {
'red3b'
} else if $in < 6hr {
'orange3'
} else if $in < 1day {
'yellow3b'
} else if $in < 3day {
'chartreuse2b'
} else if $in < 1wk {
'green3b'
} else if $in < 6wk {
'darkturquoise'
} else if $in < 52wk {
'deepskyblue3b'
} else { 'dark_gray' }
}
bool: {||
if $in {
'light_cyan'
} else {
'light_gray'
}
}
leading_trailing_space_bg: { attr: n }
empty: blue
hints: dark_gray
header: green_bold
row_index: green_bold
separator: white
duration: white
int: white
range: white
float: white
string: white
nothing: white
binary: white
cellpath: white
record: white
list: white
block: white
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b}
shape_matching_brackets: { attr: u }
shape_and: purple_bold
shape_binary: purple_bold
shape_block: blue_bold
shape_bool: light_cyan
shape_custom: green
shape_datetime: cyan_bold
shape_directory: cyan
shape_external: cyan
shape_externalarg: green_bold
shape_filepath: cyan
shape_flag: blue_bold
shape_float: purple_bold
shape_globpattern: cyan_bold
shape_int: purple_bold
shape_internalcall: cyan_bold
shape_list: cyan_bold
shape_match_pattern: green
shape_literal: blue
shape_nothing: light_cyan
shape_operator: yellow
shape_or: purple_bold
shape_pipe: purple_bold
shape_range: yellow_bold
shape_record: cyan_bold
shape_redirection: purple_bold
shape_signature: green_bold
shape_string: green
shape_string_interpolation: cyan_bold
shape_table: blue_bold
shape_variable: purple
}
let-env config = {
show_banner: false
ls: {
use_ls_colors: true
clickable_links: true
}
rm: {
always_trash: false
}
cd: {
abbreviations: false
}
table: {
mode: rounded
index_mode: always
show_empty: true
trim: {
methodology: wrapping
wrapping_try_keep_words: true
truncating_suffix: "..."
}
}
explore: {
help_banner: true
exit_esc: true
command_bar_text: '#C4C9C6'
status_bar_background: {fg: '#1D1F21' bg: '#C4C9C6' }
highlight: {bg: 'yellow' fg: 'black' }
table: {
split_line: '#404040'
cursor: true
line_index: true
line_shift: true
line_head_top: true
line_head_bottom: true
show_head: true
show_index: true
}
config: {
cursor_color: {bg: 'yellow' fg: 'black' }
}
}
history: {
max_size: 10000
sync_on_enter: true
file_format: "plaintext"
}
completions: {
case_sensitive: false
quick: true
partial: true
algorithm: "prefix"
external: {
enable: true
max_results: 100
completer: null
}
}
filesize: {
metric: true
format: "auto"
}
cursor_shape: {
vi_insert: block
vi_normal: underscore
}
color_config: $theme
use_grid_icons: true
footer_mode: "25"
float_precision: 2
use_ansi_coloring: true
edit_mode: vi
shell_integration: false
render_right_prompt_on_last_line: false
hooks: {
display_output: {||
if (term size).columns >= 100 { table -e } else { table }
}
}
menus: [
{
name: completion_menu
only_buffer_difference: false
marker: "| "
type: {
layout: columnar
columns: 4
col_width: 20
col_padding: 2
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
}
{
name: history_menu
only_buffer_difference: true
marker: "? "
type: {
layout: list
page_size: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
}
{
name: help_menu
only_buffer_difference: true
marker: "? "
type: {
layout: description
columns: 4
col_width: 20
col_padding: 2
selection_rows: 4
description_rows: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
}
{
name: commands_menu
only_buffer_difference: false
marker: "# "
type: {
layout: columnar
columns: 4
col_width: 20
col_padding: 2
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
$nu.scope.commands
| where name =~ $buffer
| each { |it| {value: $it.name description: $it.usage} }
}
}
{
name: vars_menu
only_buffer_difference: true
marker: "# "
type: {
layout: list
page_size: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
nu.scope.vars
| where name =~ $buffer
| sort-by name
| each { |it| {value: $it.name description: $it.type} }
}
}
{
name: commands_with_description
only_buffer_difference: true
marker: "# "
type: {
layout: description
columns: 4
col_width: 20
col_padding: 2
selection_rows: 4
description_rows: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
$nu.scope.commands
| where name =~ $buffer
| each { |it| {value: $it.name description: $it.usage} }
}
}
]
keybindings: [
{
name: completion_menu
modifier: none
keycode: tab
mode: [emacs vi_normal vi_insert]
event: {
until: [
{ send: menu name: completion_menu }
{ send: menunext }
]
}
}
{
name: completion_previous
modifier: shift
keycode: backtab
mode: [vi_normal, vi_insert]
event: { send: menuprevious }
}
{
name: history_menu
modifier: control
keycode: char_r
mode: emacs
event: { send: menu name: history_menu }
}
{
name: next_page
modifier: control
keycode: char_x
mode: emacs
event: { send: menupagenext }
}
{
name: undo_or_previous_page
modifier: control
keycode: char_z
mode: emacs
event: {
until: [
{ send: menupageprevious }
{ edit: undo }
]
}
}
{
name: yank
modifier: control
keycode: char_y
mode: emacs
event: {
until: [
{edit: pastecutbufferafter}
]
}
}
{
name: unix-line-discard
modifier: control
keycode: char_u
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{edit: cutfromlinestart}
]
}
}
{
name: kill-line
modifier: control
keycode: char_k
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{edit: cuttolineend}
]
}
}
{
name: commands_menu
modifier: control
keycode: char_t
mode: [emacs, vi_normal, vi_insert]
event: { send: menu name: commands_menu }
}
{
name: vars_menu
modifier: alt
keycode: char_o
mode: [emacs, vi_normal, vi_insert]
event: { send: menu name: vars_menu }
}
{
name: commands_with_description
modifier: control
keycode: char_s
mode: [emacs, vi_normal, vi_insert]
event: { send: menu name: commands_with_description }
}
]
}

View file

@ -0,0 +1,29 @@
{ homeManagerConfiguration, ... }:
homeManagerConfiguration {
programs.nushell.enable = true;
programs.nushell = {
configFile.source = ./config.nu;
envFile.source = ./env.nu;
shellAliases = {
g = "git";
ga = "git add";
gb = "git branch";
gc = "git commit -m";
gca = "git commit --amend";
gcl = "git clone";
gp = "git push";
grb = "git rebase -i";
grba = "git rebase --abort";
gs = "git switch";
gsm = "git switch master";
la = "ls -a";
sl = "ls";
n = "neovim";
p = "python3";
};
};
}

View file

@ -0,0 +1,33 @@
let-env ENV_CONVERSIONS = {
"PATH": {
from_string: { |s| $s | split row (char esep) | path expand -n }
to_string: { |v| $v | path expand -n | str join (char esep) }
}
}
let-env NU_LIB_DIRS = [
($nu.config-path | path dirname | path join 'scripts')
]
let-env NU_PLUGIN_DIRS = [
($nu.config-path | path dirname | path join 'plugins')
]
# STARSHIP
let-env config = $env.config | upsert render_right_prompt_on_last_line true
let-env STARSHIP_SHELL = "nu"
let-env STARSHIP_SESSION_KEY = (random chars -l 16)
let-env PROMPT_INDICATOR = ""
let-env PROMPT_MULTILINE_INDICATOR = (^/run/current-system/sw/bin/starship prompt --continuation)
let-env PROMPT_COMMAND = { ||
let width = (term size).columns
^/run/current-system/sw/bin/starship prompt $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
}
let-env PROMPT_COMMAND_RIGHT = { ||
let width = (term size).columns
^/run/current-system/sw/bin/starship prompt --right $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
}

View file

@ -0,0 +1,14 @@
{ ... }:
{
sound.enable = true;
services.pipewire.enable = true;
services.pipewire = {
pulse.enable = true;
alsa.enable = true;
alsa.support32Bit = true;
};
security.rtkit.enable = true; # Needed for PulseAudio.
}

View file

View file

@ -0,0 +1,22 @@
{ ... }:
{
boot.initrd.availableKernelModules = [
"ahci"
"sd_mod"
"sr_mod"
"usb_storage"
"usbhid"
"xhci_pci"
];
boot.kernelModules = [
"kvm-intel"
];
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
efi.efiSysMountPoint = "/boot/efi";
};
}

View file

@ -0,0 +1,10 @@
{ ... }:
{
imports = [
./boot.nix
./filesystem.nix
./localisation.nix
./performance.nix
];
}

View file

@ -0,0 +1,19 @@
{ ... }:
{
fileSystems."/" = {
device = "/dev/disk/by-uuid/d0e4626c-507e-484a-9ecc-94817d889083";
fsType = "ext4";
};
fileSystems."/boot/efi" = {
device = "/dev/disk/by-uuid/A467-98D1";
fsType = "vfat";
};
swapDevices = [
{
device = "/dev/disk/by-uuid/10bfe7d8-1daf-4c65-a5a6-cf3c9a085478";
}
];
}

View file

@ -0,0 +1,21 @@
{ ... }:
{
services.xserver.layout = "tr";
console.keyMap = "trq";
time.timeZone = "Europe/Istanbul";
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "tr_TR.UTF-8";
LC_IDENTIFICATION = "tr_TR.UTF-8";
LC_MEASUREMENT = "tr_TR.UTF-8";
LC_MONETARY = "tr_TR.UTF-8";
LC_NAME = "tr_TR.UTF-8";
LC_NUMERIC = "tr_TR.UTF-8";
LC_PAPER = "tr_TR.UTF-8";
LC_TELEPHONE = "tr_TR.UTF-8";
LC_TIME = "tr_TR.UTF-8";
};
}

View file

@ -0,0 +1,5 @@
{ ... }:
{
powerManagement.cpuFreqGovernor = "performance";
}

View file

@ -0,0 +1 @@
"nixos"

View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
users.defaultShell = pkgs.nushell;
imports = [
./nixos.nix
];
}

View file

@ -0,0 +1,14 @@
{ ... }:
{
users.users.nixos = {
description = "NixOS";
isNormalUser = true;
extraGroups = [
"wheel"
"networkmanager"
"docker"
];
};
}

View file

@ -0,0 +1,9 @@
{ ... }:
{
services.xserver.enable = true;
services.xserver = {
displayManager.sddm.enable = true;
desktopManager.plasma5.enable = true;
};
}

28
rebuild.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/sh
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "Usage: rebuild.sh [-h | --help] [-c | --clean-garbage]"
exit
fi
sudo true
echo -e "\n*** LINKING *** \n"
./link.sh
echo -e "\n*** REBUILDING SYSTEM ***\n"
sudo nixos-rebuild switch
if [[ $? != 0 ]]; then
exit 1
fi
if [[ $1 != "-c" && $1 != "--clean-garbage" ]]; then
read -p "Clean garbage? [Y/N]: " clean_garbage
if [[ $clean_garbage =~ ^[Yy]$ ]]; then
nix-collect-garbage -d
fi
else
nix-collect-garbage -d
fi