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

Refactor everything to make usage easier with

mutiple systems, also merge all abstractions
to avoid huge desctructions in the attrset input.
This commit is contained in:
RGBCube 2023-12-10 18:31:37 +03:00
parent a0fa73b873
commit ee2055928c
No known key found for this signature in database
47 changed files with 343 additions and 279 deletions

60
.gitignore vendored
View file

@ -2,32 +2,40 @@
!derivations/
!machines/
!machines/enka/
!machines/enka/bat/
!machines/enka/blueman/
!machines/enka/discord/
!machines/enka/dunst/
!machines/enka/firefox/
!machines/enka/fuzzel/
!machines/enka/ghostty/
!machines/enka/git/
!machines/enka/greetd/
!machines/enka/gtk/
!machines/enka/helix/
!machines/enka/hyprland/
!machines/enka/kitty/
!machines/enka/logind/
!machines/enka/networkmanager/
!machines/enka/nushell/
!machines/enka/openttd/
!machines/enka/pipewire/
!machines/enka/pueue/
!machines/enka/python/
!machines/enka/qt/
!machines/enka/steam/
!machines/enka/steck/
!machines/enka/waybar/
!hosts/
!modules/
!modules/bat/
!modules/blueman/
!modules/boot/
!modules/discord/
!modules/dunst/
!modules/firefox/
!modules/fonts/
!modules/fuzzel/
!modules/ghostty/
!modules/git/
!modules/greetd/
!modules/gtk/
!modules/helix/
!modules/hyprland/
!modules/kitty/
!modules/localisation/
!modules/logind/
!modules/networkmanager/
!modules/nix/
!modules/nushell/
!modules/openttd/
!modules/pipewire/
!modules/pueue/
!modules/python/
!modules/qt/
!modules/rust/
!modules/steam/
!modules/steck/
!modules/waybar/
!lib/
!.gitignore
!flake.lock

View file

@ -1,6 +1,6 @@
{ lib, pkgs, systemPackages, homePackages, ... }: lib.recursiveUpdate
{ ulib, pkgs, ... }: with ulib; merge
(with pkgs; systemPackages [
(systemPackages (with pkgs; [
asciinema
fastfetch
fd
@ -28,19 +28,17 @@
maven
vlang
zig
]))
(fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
<<<<<<< Updated upstream:enka/packages.nix
])
(with pkgs; homePackages "nixos" [
(with pkgs; graphicalPackages [
jetbrains.idea-ultimate
=======
(graphicalPackages (with pkgs; [
>>>>>>> Stashed changes:modules/packages/default.nix
qbittorrent
thunderbird
whatsapp-for-linux
@ -52,4 +50,4 @@
libreoffice
hunspellDicts.en_US
hunspellDicts.en_GB-ize
])
]))

159
flake.nix
View file

@ -18,14 +18,14 @@
};
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
nixSuper = {
url = "github:privatevoid-net/nix-super";
};
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
homeManager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
@ -72,8 +72,7 @@
};
};
outputs = inputs @ {
self,
outputs = {
nixSuper,
nixpkgs,
homeManager,
@ -83,131 +82,63 @@
tools,
themes,
...
}: tools.eachDefaultLinuxArch (system: let
pkgs = nixpkgs.legacyPackages.${system};
upkgs = tools.recursiveUpdateMap (name: {
${name} = inputs.${name}.packages.${system}.default;
}) [ "nixSuper" "hyprland" "hyprpicker" "ghostty" "zls" ];
} @ inputs: let
lib = nixpkgs.lib;
ulib = {
inherit (tools) recursiveUpdateMap;
inherit nuScripts;
ulib = import ./lib lib;
recursiveUpdate3 = x: y: z: lib.recursiveUpdate x (lib.recursiveUpdate y z);
};
configuration = host: system: let
pkgs = import nixpkgs { inherit system; };
theme = themes.custom (themes.raw.gruvbox-dark-hard // {
corner-radius = 0;
border-width = 1;
upkgs = { inherit nuScripts; } // (lib.genAttrs
[ "nixSuper" "hyprland" "hyprpicker" "ghostty" "zls" ]
(name: inputs.${name}.packages.${system}.default));
margin = 0;
padding = 8;
theme = themes.custom (themes.raw.gruvbox-dark-hard // {
corner-radius = 0;
border-width = 1;
font.size.normal = 12;
font.size.big = 18;
margin = 0;
padding = 8;
font.sans.name = "Lexend";
font.sans.package = pkgs.lexend;
font.size.normal = 12;
font.size.big = 18;
font.mono.name = "RobotoMono Nerd Font";
font.mono.package = (pkgs.nerdfonts.override { fonts = [ "RobotoMono" ]; });
font.sans.name = "Lexend";
font.sans.package = pkgs.lexend;
icons.name = "Gruvbox-Plus-Dark";
icons.package = pkgs.callPackage (import ./derivations/gruvbox-icons.nix) {};
});
font.mono.name = "RobotoMono Nerd Font";
font.mono.package = (pkgs.nerdfonts.override { fonts = [ "RobotoMono" ]; });
abstractions = rec {
imports = paths: lib.genAttrs [ "imports" ] (_: paths);
icons.name = "Gruvbox-Plus-Dark";
icons.package = pkgs.callPackage (import ./derivations/gruvbox-icons.nix) {};
});
enabled = attributes: attributes // { enable = true; };
defaultConfiguration = {
environment.defaultPackages = [];
normalUser = attributes: attributes // { isNormalUser = true; };
home-manager.sharedModules = [ ghosttyModule.homeModules.default ];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
systemConfiguration = attributes: attributes;
systemPackages = packages: systemConfiguration {
environment.systemPackages = packages;
networking.hostName = host;
nixpkgs.hostPlatform = system;
};
in lib.nixosSystem {
inherit system;
systemFonts = fonts: systemConfiguration {
fonts.packages = fonts;
};
homeConfiguration = user: attributes: systemConfiguration {
home-manager.users = tools.recursiveUpdateMap (user: {
${user} = attributes;
}) (if builtins.isList user then user else [ user ]);
};
homePackages = user: packages: homeConfiguration user {
home.packages = packages;
};
};
defaultConfiguration = host: with abstractions; systemConfiguration {
boot.tmp.cleanOnBoot = true;
environment.defaultPackages = [];
home-manager.sharedModules = [ ghosttyModule.homeModules.default ];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
networking.hostName = host;
nix.gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
persistent = true;
};
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
nix.optimise.automatic = true;
nix.package = upkgs.nixSuper;
nix.registry = {
nixpkgs.flake = nixpkgs;
default.flake = nixpkgs;
};
nix.settings.experimental-features = [
"fetch-tree"
"flakes"
"nix-command"
"repl-flake"
specialArgs = { inherit inputs ulib upkgs theme; };
modules = [
homeManager.nixosModules.default
defaultConfiguration
./hosts/${host}.nix
];
nix.settings.trusted-users = [ "root" "@wheel" ];
nix.settings.warn-dirty = false;
nixpkgs.config.allowUnfree = true;
nixpkgs.overlays = [ fenix.overlays.default ];
programs.nix-ld = enabled {};
};
specialArgs = abstractions // {
inherit upkgs ulib theme;
configurations = builtins.mapAttrs configuration;
in {
nixosConfigurations = configurations {
enka = "x86_64-linux";
};
importConfigurations = tools.recursiveUpdateMap (host: {
nixosConfigurations.${host} = lib.nixosSystem {
inherit specialArgs;
modules = [
homeManager.nixosModules.default
(defaultConfiguration host)
./machines/${host}
];
};
});
in importConfigurations [
"enka"
]);
};
}

51
hosts/enka.nix Normal file
View file

@ -0,0 +1,51 @@
{ ulib, ... }: with ulib; merge3
(systemConfiguration {
system.stateVersion = "23.05";
users.users.nixos = graphicalUser {
description = "NixOS";
extraGroups = [ "wheel" ];
};
})
(homeConfiguration {
home.stateVersion = "23.05";
})
(importModules [
"bat"
"blueman"
"boot"
"discord"
"dunst"
"firefox"
"fonts"
"fuzzel"
"ghostty"
"git"
"greetd"
"gtk"
"helix"
"hyprland"
"kitty"
"localisation"
"logind"
"networkmanager"
"nix"
"nushell"
"openttd"
"pipewire"
"pueue"
"python"
"qt"
"rust"
"steam"
"steck"
"waybar"
# TODO: Move this somewhere, IDK.
../enka/packages.nix
/etc/nixos/hardware-configuration.nix
])

29
lib/configuration.nix Normal file
View file

@ -0,0 +1,29 @@
rec {
systemConfiguration = configuration: configuration;
systemPackages = packages: systemConfiguration {
environment.systemPackages = packages;
};
systemFonts = packages: systemConfiguration {
fonts.packages = packages;
};
userHomeConfiguration = users: configuration: {
home-manager.users = builtins.foldl' (final: user: final // {
${user} = configuration;
}) {} (if builtins.isList users then users else [ users ]);
};
# FIXME: Don't hardcode these.
graphicalConfiguration = userHomeConfiguration "nixos";
graphicalPackages = packages: graphicalConfiguration {
home.packages = packages;
};
# FIXME: Don't hardcode these.
homeConfiguration = userHomeConfiguration [ "nixos" "root" ];
homePackages = packages: homeConfiguration {
home.packages = packages;
};
}

9
lib/default.nix Normal file
View file

@ -0,0 +1,9 @@
lib:
(import ./configuration.nix)
//
(import ./merge.nix lib)
//
(import ./modules.nix)
//
(import ./values.nix)

8
lib/merge.nix Normal file
View file

@ -0,0 +1,8 @@
lib:
rec {
merge = lib.recursiveUpdate;
merge3 = x: y: merge (merge x y);
merge4 = x: y: merge3 (merge x y);
merge5 = x: y: merge4 (merge x y);
}

8
lib/modules.nix Normal file
View file

@ -0,0 +1,8 @@
{
importModules = modules: {
imports = builtins.map (module: if builtins.isPath module then
module
else
../modules/${module}) modules;
};
}

14
lib/values.nix Normal file
View file

@ -0,0 +1,14 @@
{
enabled = attributes: attributes // {
enable = true;
};
normalUser = attributes: attributes // {
isNormalUser = true;
};
graphicalUser = attributes: attributes // {
extraGroups = [ "graphical" ] ++ (attributes.extraGroups or []);
isNormalUser = true;
};
}

View file

@ -1,49 +0,0 @@
{ pkgs, ulib, systemConfiguration, homeConfiguration, imports, ... }: ulib.recursiveUpdate3
(systemConfiguration {
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot.enable = true;
systemd-boot.editor = false;
};
system.stateVersion = "23.05";
})
(homeConfiguration [ "nixos" "root" ] {
home.stateVersion = "23.05";
})
(imports [
./bat
./blueman
./discord
./dunst
./firefox
./fuzzel
./ghostty
./git
./greetd
./gtk
./helix
./hyprland
./kitty
./logind
./networkmanager
./nushell
./openttd
./pipewire
./pueue
./python
./steam
./steck
./waybar
./fonts.nix
./localisation.nix
./packages.nix
./users.nix
/etc/nixos/hardware-configuration.nix
])

View file

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

View file

@ -1,9 +0,0 @@
{ lib, pkgs, systemPackages, homeConfiguration, ... }: lib.recursiveUpdate
(with pkgs; systemPackages [
steck
])
(homeConfiguration [ "nixos" "root" ] {
programs.nushell.shellAliases.share = "steck paste";
})

View file

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

View file

@ -1,6 +1,6 @@
{ theme, homeConfiguration, enabled, ... }:
{ ulib, theme, ... }: with ulib;
homeConfiguration [ "nixos" "root" ] {
homeConfiguration {
programs.nushell.environmentVariables = {
MANPAGER = ''"bat --plain --language man"'';
PAGER = ''"bat --plain"'';
@ -12,7 +12,7 @@ homeConfiguration [ "nixos" "root" ] {
};
programs.bat = enabled {
config.theme = "default";
themes.default = theme.tmTheme;
config.theme = "base16";
themes.base16 = theme.tmTheme;
};
}

View file

@ -1,4 +1,4 @@
{ systemConfiguration, enabled, ... }:
{ ulib, ... }: with ulib;
systemConfiguration {
services.blueman = enabled {};

13
modules/boot/default.nix Normal file
View file

@ -0,0 +1,13 @@
{ ulib, pkgs, ... }: with ulib;
systemConfiguration {
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot.enable = true;
systemd-boot.editor = false;
};
boot.tmp.cleanOnBoot = true;
}

View file

@ -1,12 +1,12 @@
{ lib, pkgs, theme, homeConfiguration, homePackages, ... }: lib.recursiveUpdate
{ ulib, pkgs, theme, ... }: with ulib; merge
(homeConfiguration "nixos" {
(graphicalConfiguration {
xdg.configFile."Vencord/settings/quickCss.css".text = theme.discordCss;
})
(with pkgs; homePackages "nixos" [
(graphicalPackages (with pkgs; [
(discord.override {
withOpenASAR = true;
withVencord = true;
})
])
]))

View file

@ -1,6 +1,6 @@
{ theme, homeConfiguration, enabled, ... }:
{ ulib, theme, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
services.dunst = with theme.withHashtag; enabled {
iconTheme = icons;

View file

@ -1,6 +1,6 @@
{ homeConfiguration, enabled, ... }:
{ ulib, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
programs.firefox = enabled {};
programs.librewolf = enabled {};

View file

@ -1,4 +1,4 @@
{ lib, pkgs, theme, systemConfiguration, systemFonts, ... }: lib.recursiveUpdate
{ ulib, pkgs, theme, ... }: with ulib; merge
(systemConfiguration {
console = {
@ -10,7 +10,7 @@
};
})
(with pkgs; systemFonts [
(systemFonts (with pkgs; [
theme.font.sans.package
theme.font.mono.package
@ -18,4 +18,4 @@
noto-fonts-cjk-sans
noto-fonts-lgc-plus
noto-fonts-emoji
])
]))

View file

@ -1,6 +1,6 @@
{ theme, homeConfiguration, enabled, ... }:
{ ulib, theme, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
programs.fuzzel = with theme; enabled {
settings.main = {
dpi-aware = false;

View file

@ -1,6 +1,6 @@
{ pkgs, upkgs, theme, homeConfiguration, enabled, ... }:
{ ulib, pkgs, upkgs, theme, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
programs.nushell.environmentVariables.TERMINAL = "ghostty";
programs.ghostty = enabled {

View file

@ -1,6 +1,6 @@
{ pkgs, homeConfiguration, enabled, ... }:
{ ulib, pkgs, ... }: with ulib;
homeConfiguration [ "nixos" "root" ] {
homeConfiguration {
programs.nushell.shellAliases = {
g = "git";

View file

@ -1,4 +1,4 @@
{ pkgs, systemConfiguration, enabled, ... }:
{ ulib, pkgs, ... }: with ulib;
systemConfiguration {
services.greetd = enabled {

View file

@ -1,10 +1,10 @@
{ lib, pkgs, theme, systemConfiguration, homeConfiguration, enabled, ... }: lib.recursiveUpdate
{ ulib, pkgs, theme, ... }: with ulib; merge
(systemConfiguration {
programs.dconf = enabled {};
})
(homeConfiguration "nixos" {
(graphicalConfiguration {
gtk = enabled {
gtk3.extraCss = theme.adwaitaGtkCss;
gtk4.extraCss = theme.adwaitaGtkCss;

View file

@ -1,6 +1,6 @@
{ lib, pkgs, upkgs, homeConfiguration, homePackages, enabled, ... }: lib.recursiveUpdate
{ ulib, lib, pkgs, upkgs, ... }: with ulib; merge
(homeConfiguration [ "nixos" "root" ] {
(homeConfiguration {
programs.nushell.environmentVariables.EDITOR = "hx";
programs.nushell.shellAliases.x = "hx";
@ -43,7 +43,7 @@
};
})
(with pkgs; homePackages "nixos" [
(homePackages (with pkgs; [
# CMAKE
cmake-language-server
@ -76,4 +76,4 @@
# ZIG
upkgs.zls
])
]))

View file

@ -1,4 +1,4 @@
{ pkgs, upkgs, ulib, theme, systemConfiguration, homeConfiguration, homePackages, enabled, ... }: ulib.recursiveUpdate3
{ ulib, pkgs, upkgs, theme, ... }: with ulib; merge3
(systemConfiguration {
hardware.opengl = enabled {};
@ -10,7 +10,7 @@
};
})
(homeConfiguration "nixos" {
(graphicalConfiguration {
wayland.windowManager.hyprland = with theme; enabled {
package = upkgs.hyprland;
@ -213,7 +213,7 @@
};
})
(with pkgs; homePackages "nixos" [
(homePackages (with pkgs; [
brightnessctl
cliphist
grim
@ -224,4 +224,4 @@
wl-clipboard
xdg-utils
xwaylandvideobridge
])
]))

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

@ -1,6 +1,6 @@
{ theme, homeConfiguration, enabled, ... }:
{ ulib, theme, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
programs.kitty = with theme.withHashtag; enabled {
font = with font; {
inherit (mono) name package;

View file

@ -1,4 +1,4 @@
{ systemConfiguration, ... }:
{ ulib, ... }: with ulib;
systemConfiguration {
console.keyMap = "trq";

View file

@ -1,4 +1,4 @@
{ systemConfiguration, ... }:
{ ulib, ... }: with ulib;
systemConfiguration {
services.logind.powerKey = "ignore";

View file

@ -1,4 +1,4 @@
{ systemConfiguration, enabled, ... }:
{ ulib, ... }: with ulib;
systemConfiguration {
networking.networkmanager = enabled {};

35
modules/nix/default.nix Normal file
View file

@ -0,0 +1,35 @@
{ inputs, ulib, upkgs, ... }: with ulib;
systemConfiguration {
nix = {
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
persistent = true;
};
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
optimise.automatic = true;
package = upkgs.nixSuper;
registry = {
nixpkgs.flake = inputs.nixpkgs;
default.flake = inputs.nixpkgs;
};
settings.experimental-features = [
"fetch-tree"
"flakes"
"nix-command"
"repl-flake"
];
settings.trusted-users = [ "root" "@wheel" ];
settings.warn-dirty = false;
};
programs.nix-ld = enabled {};
}

View file

@ -1,16 +1,16 @@
{ config, pkgs, ulib, theme, systemConfiguration, homeConfiguration, homePackages, enabled, ... }: ulib.recursiveUpdate3
{ config, ulib, pkgs, upkgs, theme, ... }: with ulib; merge3
(systemConfiguration {
users.defaultUserShell = pkgs.nushell;
})
(homeConfiguration [ "nixos" "root" ] {
(homeConfiguration {
programs.starship = enabled {};
programs.nushell = enabled {
configFile.text = import ./configuration.nix.nu;
envFile.text = import ./environment.nix.nu {
inherit (ulib) nuScripts;
inherit (upkgs) nuScripts;
inherit theme;
};
@ -32,6 +32,6 @@
};
})
(with pkgs; homePackages "nixos" [
(homePackages (with pkgs; [
carapace
])
]))

View file

@ -0,0 +1,5 @@
{ ulib, pkgs, ... }: with ulib;
graphicalPackages (with pkgs; [
openttd
])

View file

@ -1,4 +1,4 @@
{ systemConfiguration, enabled, ... }:
{ ulib, ... }: with ulib;
systemConfiguration {
security.rtkit = enabled {};

View file

@ -1,6 +1,6 @@
{ homeConfiguration, enabled, ... }:
{ ulib, ... }: with ulib;
homeConfiguration "nixos" {
homeConfiguration {
services.pueue = enabled {
settings = {
shared = {

View file

@ -1,15 +1,15 @@
{ lib, pkgs, systemPackages, homeConfiguration, ... }: lib.recursiveUpdate
{ ulib, pkgs, ... }: with ulib; merge
(with pkgs; systemPackages [
(systemPackages (with pkgs; [
(python311.withPackages (pkgs: with pkgs; [
pip
requests
]))
virtualenv
poetry
])
]))
(homeConfiguration [ "nixos" "root" ] {
(homeConfiguration {
programs.nushell.shellAliases = {
venv = "virtualenv venv";
};

View file

@ -1,6 +1,6 @@
{ pkgs, homeConfiguration, enabled, ... }:
{ ulib, pkgs, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
qt = enabled {
platformTheme = "gnome";
style.name = "adwaita-dark";

15
modules/rust/default.nix Normal file
View file

@ -0,0 +1,15 @@
{ inputs, ulib, pkgs, ... }: with ulib; merge
(systemConfiguration {
nixpkgs.overlays = [ inputs.fenix.overlays.default ];
})
(systemPackages (with pkgs; [
(fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
]))

View file

@ -1,10 +1,12 @@
{ lib, pkgs, systemConfiguration, homePackages, ... }: lib.recursiveUpdate
{ ulib, pkgs, ... }: with ulib; merge
(systemConfiguration {
# Steam uses 32-bit drivers for some unholy fucking reason.
hardware.opengl.driSupport32Bit = true;
nixpkgs.config.allowUnfree = true;
})
(with pkgs; homePackages "nixos" [
(graphicalPackages (with pkgs; [
steam
])
]))

View file

@ -0,0 +1,9 @@
{ ulib, pkgs, ... }: with ulib; merge
(systemPackages (with pkgs; [
steck
]))
(homeConfiguration {
programs.nushell.shellAliases.share = "steck paste";
})

View file

@ -1,6 +1,6 @@
{ theme, homeConfiguration, enabled, ... }:
{ ulib, theme, ... }: with ulib;
homeConfiguration "nixos" {
graphicalConfiguration {
programs.waybar = with theme.withHashtag; enabled {
systemd = enabled {};