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/asus/
!machines/asus/discord/
!machines/asus/docker/
!machines/asus/firefox/
!machines/asus/git/
!machines/asus/intellij/
!machines/asus/libreoffice/
!machines/asus/neovim/
!machines/asus/neovim/nvchad/
!machines/asus/networkmanager/
!machines/asus/nixpkgs/
!machines/asus/nushell/
!machines/asus/openttd/
!machines/asus/pipewire/
!machines/asus/users/
!machines/asus/system/
!machines/asus/qbittorrent/
!machines/asus/wine/
!machines/asus/xserver/
!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 {
importConfiguration = configDirectory:
with {
hostName = builtins.baseNameOf configDirectory;
hostPlatform = import (configDirectory + "/platform.nix");
nixosSystem = arguments: modules: nixpkgs.lib.nixosSystem {
specialArgs = arguments;
modules = modules;
};
{
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem {
specialArgs = {
lib = nixpkgs.lib;
importConfiguration = configurationDirectory: let
hostName = builtins.baseNameOf configurationDirectory;
hostPlatform = import configurationDirectory + "/platform.nix";
in {
nixosConfigurations.${hostName} = nixosSystem {
lib = nixpkgs.lib;
pkgs = import nixpkgs {
system = hostPlatform;
config.allowUnfree = true;
pkgs = import nixpkgs {
system = hostPlatform;
config.allowUnfree = true;
overlays = [
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@";
overlays = [
fenix.overlays.default
];
};
modules = [
configDirectory
home-manager.nixosModules.home-manager
# Helper functions for readability & DRY.
systemConfiguration = attributes: attributes;
{
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
homeConfiguration = userName: attributes: systemConfiguration {
home-manager.users.${userName} = attributes;
};
networking.hostName = hostName;
nixpkgs.hostPlatform = hostPlatform;
imports = importPaths: systemConfiguration {
imports = importPaths;
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
packages = packages: systemConfiguration {
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;
}
];
};
};
builtins.foldl' nixpkgs.lib.recursiveUpdate {} (builtins.map importConfiguration [
./machines/asus
]);
in builtins.foldl' nixpkgs.lib.recursiveUpdate {} (builtins.map importConfiguration machines);
}

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";
})
imports = [
./docker
./git
./neovim
./networkmanager
./nixpkgs
./nushell
./pipewire
./system
./users
./xserver
];
}
//
//
(homeManagerConfiguration "nixos" {
(homeConfiguration "nixos" {
home.stateVersion = "22.11";
})

View file

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

View file

@ -1,5 +1,5 @@
{ ... }:
{ systemConfiguration, enabled, ... }:
{
virtualisation.docker.enable = true;
systemConfiguration {
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 {
fonts = [
"JetBrainsMono"

View file

@ -1,8 +1,7 @@
{ homeManagerConfiguration, ... }:
{ homeConfiguration, enabled, ... }:
homeManagerConfiguration "nixos" {
programs.git.enable = true;
programs.git = {
homeConfiguration "nixos" {
programs.git = enabled {
userName = "RGBCube";
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";
console.keyMap = "trq";

View file

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

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

View file

@ -1,5 +1,5 @@
{ ... }:
{ systemConfiguration, enabled, ... }:
{
networking.networkmanager.enable = true;
systemConfiguration {
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" {
programs.starship.enable = true;
programs.starship.settings.character = {
success_symbol = "";
error_symbol = "";
(systemConfiguration {
users.defaultUserShell = pkgs.nushell;
})
//
(homeConfiguration "nixos" {
programs.starship = enabled {
settings.character = {
success_symbol = "";
error_symbol = "";
};
};
programs.nushell.enable = true;
programs.nushell = {
configFile.source = ./config.nu;
envFile.source = ./env.nu;
programs.nushell = enabled {
configFile.source = ./configuration.nu;
envFile.source = ./environment.nu;
environmentVariables = {
EDITOR = "nvim";
@ -35,4 +41,4 @@ homeManagerConfiguration "nixos" {
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, ... }:
{
sound.enable = true;
services.pipewire.enable = true;
services.pipewire = {
pulse.enable = true;
systemConfiguration {
security.rtkit = enabled {};
sound = enabled {};
alsa.enable = true;
alsa.support32Bit = true;
services.pipewire = enabled {
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, ... }:
{
users.users.nixos = {
systemConfiguration {
users.users.nixos = normalUser {
description = "NixOS";
isNormalUser = true;
extraGroups = [
"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, ... }:
{
services.xserver.enable = true;
services.xserver = {
displayManager.sddm.enable = true;
desktopManager.plasma5.enable = true;
systemConfiguration {
services.xserver = enabled {
displayManager.sddm = enabled {};
desktopManager.plasma5 = enabled {};
};
}

View file

@ -1,11 +1,9 @@
#!/bin/sh
if [[ $1 == "--help" || $1 == "-h" ]]; then
echo "Usage: rebuild.sh [-h | --help] [-c | --clean-garbage] [machine]"
if [[ $1 == "-h" || $1 == "--help" ]]; then
echo "Usage: $0 [-h | --help] [-c | --clean-garbage] [machine]"
exit
fi
sudo true
fi<
if [[ -n $1 ]]; 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
fi
sudo true
sed -ie "s|@pwd@|$PWD|g" flake.nix
sudo nixos-rebuild switch --impure --flake .#$machine