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

Rewrite everythin

This commit is contained in:
RGBCube 2023-05-10 23:06:24 +03:00
parent a36664a390
commit 7e281a3470
35 changed files with 277 additions and 281 deletions

11
.gitignore vendored
View file

@ -2,16 +2,19 @@
!machines/ !machines/
!machines/asus/ !machines/asus/
!machines/asus/discord/
!machines/asus/docker/ !machines/asus/docker/
!machines/asus/firefox/
!machines/asus/git/ !machines/asus/git/
!machines/asus/intellij/
!machines/asus/libreoffice/
!machines/asus/neovim/ !machines/asus/neovim/
!machines/asus/neovim/nvchad/
!machines/asus/networkmanager/ !machines/asus/networkmanager/
!machines/asus/nixpkgs/
!machines/asus/nushell/ !machines/asus/nushell/
!machines/asus/openttd/
!machines/asus/pipewire/ !machines/asus/pipewire/
!machines/asus/users/ !machines/asus/qbittorrent/
!machines/asus/system/ !machines/asus/wine/
!machines/asus/xserver/ !machines/asus/xserver/
!flake.lock !flake.lock

126
flake.nix
View file

@ -25,69 +25,87 @@
}; };
}; };
outputs = { nixpkgs, home-manager, fenix, ... }: outputs = { nixpkgs, home-manager, fenix, ... }: let
machines = [
./machines/asus
];
with { nixosSystem = arguments: modules: nixpkgs.lib.nixosSystem {
importConfiguration = configDirectory: specialArgs = arguments;
with { modules = modules;
hostName = builtins.baseNameOf configDirectory;
hostPlatform = import (configDirectory + "/platform.nix");
}; };
{ importConfiguration = configurationDirectory: let
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem { hostName = builtins.baseNameOf configurationDirectory;
specialArgs = { hostPlatform = import configurationDirectory + "/platform.nix";
lib = nixpkgs.lib; in {
nixosConfigurations.${hostName} = nixosSystem {
lib = nixpkgs.lib;
pkgs = import nixpkgs { pkgs = import nixpkgs {
system = hostPlatform; system = hostPlatform;
config.allowUnfree = true; config.allowUnfree = true;
overlays = [ overlays = [
fenix.overlays.default fenix.overlays.default
]; ];
};
# Helper function for DRY.
homeManagerConfiguration = userName: attrs: {
home-manager.users.${userName} = attrs;
};
# Q: Can't we just do supply a relative path "./foo" ?
# A: When configuring our system with flakes, Nix copies them to the
# Nix store to run them. So we can't use relative paths as they will refer
# to a file which is in the Nix store, and is immutable because it is in
# the Nix store, which beats the point of abusing Home Managers
# mkOutOfStoreSymlink to create symlinks to mutable files.
# To avoid this, we must give an absolute path to a file,
# so we do this. The @pwd@ here is replaced by the rebuild script
# with the working directory, then changed back after the build.
# And yes, this is a major hack.
projectPath = "@pwd@";
}; };
modules = [ # Helper functions for readability & DRY.
configDirectory systemConfiguration = attributes: attributes;
home-manager.nixosModules.home-manager
{ homeConfiguration = userName: attributes: systemConfiguration {
nix.settings.experimental-features = [ home-manager.users.${userName} = attributes;
"nix-command" };
"flakes"
];
networking.hostName = hostName; imports = importPaths: systemConfiguration {
nixpkgs.hostPlatform = hostPlatform; imports = importPaths;
};
home-manager.useGlobalPkgs = true; packages = packages: systemConfiguration {
home-manager.useUserPackages = true; environment.systemPackages = packages;
} };
];
}; fonts = fonts: systemConfiguration {
fonts.fonts = packages;
};
enabled = attributes: attributes // {
enabled = true;
};
normalUser = attributes: attributes // {
isNormalUser = true;
};
# Q: Can't we just do supply a relative path "./foo" ?
# A: When configuring our system with flakes, Nix copies them to the
# Nix store to run them. So we can't use relative paths as they will refer
# to a file which is in the Nix store, and is immutable because it is in
# the Nix store, which beats the point of abusing Home Managers
# mkOutOfStoreSymlink to create symlinks to mutable files.
# To avoid this, we must give an absolute path to a file,
# so we do this. The @pwd@ here is replaced by the rebuild script
# with the working directory, then changed back after the build.
# And yes, this is a major hack.
projectPath = "@pwd@";
} [
configurationDirectory
home-manager.nixosModules.home-manager
{
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
networking.hostName = hostName;
nixpkgs.hostPlatform = hostPlatform;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
}; };
}; in builtins.foldl' nixpkgs.lib.recursiveUpdate {} (builtins.map importConfiguration machines);
builtins.foldl' nixpkgs.lib.recursiveUpdate {} (builtins.map importConfiguration [
./machines/asus
]);
} }

View file

@ -1,24 +1,36 @@
{ homeManagerConfiguration, ... }: { systemConfiguration, homeConfiguration, imports, ... }:
{ (imports [
./discord
./docker
./firefox
./git
./intellij
./libreoffice
./neovim
./networkmanager
./nushell
./openttd
./pipewire
./qbittorrent
./wine
./xserver
./fonts.nix
./hardware.nix
./localisation.nix
./packages.nix
./user.nix
])
//
(systemConfiguration {
system.stateVersion = "22.11"; system.stateVersion = "22.11";
})
imports = [ //
./docker
./git
./neovim
./networkmanager
./nixpkgs
./nushell
./pipewire
./system
./users
./xserver
];
}
// (homeConfiguration "nixos" {
(homeManagerConfiguration "nixos" {
home.stateVersion = "22.11"; home.stateVersion = "22.11";
}) })

View file

@ -0,0 +1,5 @@
{ pkgs, packages, ... }:
with pkgs; packages [
discord
]

View file

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

View file

@ -0,0 +1,5 @@
{ systemConfiguration, enabled, ... }:
systemConfiguration {
programs.firefox = enabled {};
}

View file

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

View file

@ -1,8 +1,7 @@
{ homeManagerConfiguration, ... }: { homeConfiguration, enabled, ... }:
homeManagerConfiguration "nixos" { homeConfiguration "nixos" {
programs.git.enable = true; programs.git = enabled {
programs.git = {
userName = "RGBCube"; userName = "RGBCube";
userEmail = "RGBCube@users.noreply.github.com"; userEmail = "RGBCube@users.noreply.github.com";

View file

@ -0,0 +1,40 @@
{ systemConfiguration, ... }:
systemConfiguration {
powerManagement.cpuFreqGovernor = "performance";
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";
};
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,5 @@
{ pkgs, packages, ... }:
with pkgs.jetbrains; packages [
idea-ultimate
]

View file

@ -0,0 +1,7 @@
{ pkgs, packages, ... }:
with pkgs; packages [
libreoffice
hunspellDicts.en_US
hunspellDicts.en_GB-ize
]

View file

@ -1,6 +1,6 @@
{ ... }: { systemConfiguration, ... }:
{ systemConfiguration {
services.xserver.layout = "tr"; services.xserver.layout = "tr";
console.keyMap = "trq"; console.keyMap = "trq";

View file

@ -1,23 +1,21 @@
{ pkgs, lib, homeManagerConfiguration, projectPath, ... }: { lib, pkgs, systemConfiguration, homeConfiguration, packages, enabled, projectPath, ... }:
{ (systemConfiguration {
# Nuking nano out of orbit.
environment.defaultPackages = []; environment.defaultPackages = [];
programs.nano.syntaxHighlight = false; programs.nano.syntaxHighlight = false;
})
environment.systemPackages = with pkgs; [
neovim-qt
];
}
// //
(homeManagerConfiguration "nixos" ({ config, ... }: { (with pkgs; packages [
programs.neovim.enable = true; neovim-qt
programs.neovim = { ])
# Does not work with Nushell for some reason, I just set it manually.
# defaultEditor = true;
//
(homeConfiguration "nixos" ({ config, ... }: {
programs.neovim = enabled {
defaultEditor = true;
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;
}; };

@ -1 +0,0 @@
Subproject commit 3dd0fa6c5b0933d9a395e2492de69c151831c66e

View file

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

View file

@ -1,6 +0,0 @@
{ pkgs, ... }:
{
environment.systemPackages = import ./packages.nix pkgs;
fonts.fonts = import ./fonts.nix pkgs;
}

View file

@ -1,63 +0,0 @@
pkgs: with pkgs; []
++ [ # APPLICATIONS
firefox
discord
qbittorrent
]
++ [ # DEVELOPMENT TOOLS
bat
]
++ [ # EDITORS
jetbrains.idea-ultimate
]
++ [ # EMULATION
wine
]
++ [ # FIRMWARE
linux-firmware
]
++ [ # GAMES
openttd
]
++ [ # LIBREOFFICE
libreoffice
hunspellDicts.en_US
hunspellDicts.en_GB-ize
]
++ [ # MISCELLANEOUS
htop
neofetch
]
++ [ # PLASMA THEMES
lightly-qt
]
++ [ # COMPILERS & TOOLING
gcc
go
(fenix.complete.withComponents [
"rustc"
"rust-src"
"cargo"
"rustfmt"
"clippy"
])
]
++ [ # PYTHON
(python311.withPackages (pkgs: with pkgs; [
pip
requests
]))
virtualenv
poetry
]

View file

@ -1,16 +1,22 @@
{ homeManagerConfiguration, ... }: { pkgs, systemConfiguration, homeConfiguration, enabled, ... }:
homeManagerConfiguration "nixos" { (systemConfiguration {
programs.starship.enable = true; users.defaultUserShell = pkgs.nushell;
programs.starship.settings.character = { })
success_symbol = "";
error_symbol = ""; //
(homeConfiguration "nixos" {
programs.starship = enabled {
settings.character = {
success_symbol = "";
error_symbol = "";
};
}; };
programs.nushell.enable = true; programs.nushell = enabled {
programs.nushell = { configFile.source = ./configuration.nu;
configFile.source = ./config.nu; envFile.source = ./environment.nu;
envFile.source = ./env.nu;
environmentVariables = { environmentVariables = {
EDITOR = "nvim"; EDITOR = "nvim";
@ -35,4 +41,4 @@ homeManagerConfiguration "nixos" {
p = "python3"; p = "python3";
}; };
}; };
} })

View file

@ -0,0 +1,5 @@
{ pkgs, packages, ... }:
with pkgs; packages [
openttd
]

View file

@ -0,0 +1,27 @@
{ pkgs, packages, ... }:
with pkgs; packages [
bat
htop
neofetch
lightly-qt
gcc
go
(fenix.complete.withComponents [
"rustc"
"rust-src"
"cargo"
"rustfmt"
"clippy"
])
(python311.withPackages (pkgs: with pkgs; [
pip
requests
]))
virtualenv
poetry
]

View file

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

View file

@ -1 +0,0 @@
"x86_64-linux"

View file

@ -0,0 +1,5 @@
{ pkgs, packages, ... }:
with pkgs; packages [
qbittorrent
]

View file

@ -1,5 +0,0 @@
{ ... }:
{
hardware.bluetooth.enable = true;
}

View file

@ -1,22 +0,0 @@
{ ... }:
{
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

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

View file

@ -1,19 +0,0 @@
{ ... }:
{
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

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

View file

@ -1,9 +1,8 @@
{ ... }: { systemConfiguration, normalUser, ... }:
{ systemConfiguration {
users.users.nixos = { users.users.nixos = normalUser {
description = "NixOS"; description = "NixOS";
isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "wheel"

View file

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

View file

@ -0,0 +1,5 @@
{ pkgs, packages, ... }:
with pkgs; packages [
wine
]

View file

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

View file

@ -1,11 +1,9 @@
#!/bin/sh #!/bin/sh
if [[ $1 == "--help" || $1 == "-h" ]]; then if [[ $1 == "-h" || $1 == "--help" ]]; then
echo "Usage: rebuild.sh [-h | --help] [-c | --clean-garbage] [machine]" echo "Usage: $0 [-h | --help] [-c | --clean-garbage] [machine]"
exit exit
fi fi<
sudo true
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
if [[ $1 != "-c" && $1 != "--clean-garbage" ]]; then if [[ $1 != "-c" && $1 != "--clean-garbage" ]]; then
@ -19,6 +17,8 @@ else
read -p "What machine would you want to build? [$(ls --format=commas machines)]: " machine read -p "What machine would you want to build? [$(ls --format=commas machines)]: " machine
fi fi
sudo true
sed -ie "s|@pwd@|$PWD|g" flake.nix sed -ie "s|@pwd@|$PWD|g" flake.nix
sudo nixos-rebuild switch --impure --flake .#$machine sudo nixos-rebuild switch --impure --flake .#$machine