Refactor every role to have .enable option

NOTE: any config other than stella will not be working for a while

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2023-08-22 19:39:11 +03:00
parent 595cc4d833
commit 4afe642684
No known key found for this signature in database
GPG key ID: 9F6DDABE11A2674D
13 changed files with 219 additions and 201 deletions

View file

@ -1,6 +1,13 @@
{ config, pkgs, ... }: { config, pkgs, lib, ... }:
{ let
cfg = config.my.laptop;
in {
options = {
my.laptop.enable = lib.mkEnableOption "Laptop-specific configuration";
};
config = lib.mkIf (cfg.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
powertop powertop
lm_sensors lm_sensors
@ -11,4 +18,5 @@
services.tlp.enable = true; services.tlp.enable = true;
services.upower.enable = true; services.upower.enable = true;
};
} }

View file

@ -5,7 +5,7 @@
i18n.defaultLocale = "ru_RU.UTF-8"; i18n.defaultLocale = "ru_RU.UTF-8";
console = { console = {
font = "${pkgs.terminus_font}/share/consolefonts/ter-u16b.psf.gz"; font = "${pkgs.terminus_font}/share/consolefonts/ter-u24b.psf.gz";
keyMap = "us"; keyMap = "us";
packages = with pkgs; [ terminus_font ]; packages = with pkgs; [ terminus_font ];
}; };

View file

@ -13,9 +13,7 @@
enable = true; enable = true;
killUnconfinedConfinables = true; killUnconfinedConfinables = true;
}; };
allowUserNamespaces = true; allowUserNamespaces = true;
}; };
boot.kernel.sysctl = { boot.kernel.sysctl = {

View file

@ -14,7 +14,7 @@ in rec {
cargo cargo
rustc rustc
neofetch neofetch
gitFull htop
]; ];
shell = pkgs.zsh; shell = pkgs.zsh;
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keys = [

View file

@ -18,22 +18,7 @@
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
./common/base.nix ./machines/stella
./common/laptop.nix
./common/locale.nix
./common/networking.nix
./common/remote-access.nix
./common/security.nix
./common/user.nix
./roles/design.nix
./roles/devel.nix
./roles/gaming.nix
./roles/graphical.nix
./roles/latex.nix
./roles/virtualisation.nix
./roles/yggdrasil-client.nix
./machines/stella/configuration.nix
./machines/stella/hardware.nix
]; ];
}; };

View file

@ -1,20 +0,0 @@
{ config, pkgs, ... }:
{
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "stella";
services.xserver.videoDrivers=["amdgpu"];
boot.initrd.kernelModules=["amdgpu"];
powerManagement = {
enable = true;
cpuFreqGovernor = "performance";
};
system.stateVersion = "23.05";
}

View file

@ -1,9 +1,14 @@
{ pkgs, ... }: { config, lib, pkgs, ... }:
{ let
cfg = config.my.roles.design;
in {
options.my.roles.design.enable = lib.mkEnableOption "Enable design-specific programs";
config = lib.mkIf (cfg.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
inkscape inkscape
gimp gimp
imagemagick imagemagick
]; ];
};
} }

View file

@ -1,13 +1,15 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ let
config = lib.mkMerge [{ cfg = config.my.roles.devel;
in {
options.my.roles.devel.enable = lib.mkEnableOption "Enable tools for development programs";
config = lib.mkIf (cfg.enable) ( lib.mkMerge [{
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
rustc rustc
cargo cargo
rustup rustup
vscode
clang clang
llvm llvm
lld lld
@ -16,10 +18,23 @@
autoconf autoconf
meson meson
ninja ninja
picocom
screen
]; ];
} }
# Architecture-specific packages and configuration
(lib.mkIf (!pkgs.stdenv.isAarch64) {boot.binfmt.emulatedSystems = [ "aarch64-linux" ];}) (lib.mkIf (!pkgs.stdenv.isAarch64) {boot.binfmt.emulatedSystems = [ "aarch64-linux" ];})
(lib.mkIf (!pkgs.stdenv.isx86_64) {boot.binfmt.emulatedSystems = [ "x86_64-linux" ];}) (lib.mkIf (!pkgs.stdenv.isx86_64) {boot.binfmt.emulatedSystems = [ "x86_64-linux" "i686-linux" ];})
# Remove CLion from builds while I'm semi-online
/*(lib.mkIf (pkgs.stdenv.isx86_64) {
environment.systemPackages = with pkgs; [
jetbrains.clion
]; ];
})*/
(lib.mkIf (pkgs.stdenv.isx86_64 || pkgs.stdenv.isAarch64 || pkgs.stdenv.isAarch32) {
environment.systemPackages = with pkgs; [
vscode
];
})
]);
} }

View file

@ -1,13 +1,15 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, ... }: let
cfg = config.my.roles.gaming;
{ in {
options.my.roles.gaming.enable = lib.mkEnableOption "Enable wine & steam";
config = lib.mkIf (cfg.enable) {
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
hardware.opengl.driSupport32Bit = true; hardware.opengl.driSupport32Bit = true;
services.pipewire.alsa.support32Bit = true; services.pipewire.alsa.support32Bit = true;
programs.steam.enable = true; programs.steam.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
prismlauncher
steam steam
wineWowPackages.stable wineWowPackages.stable
wine wine
@ -16,4 +18,5 @@
winetricks winetricks
wineWowPackages.waylandFull wineWowPackages.waylandFull
]; ];
};
} }

View file

@ -1,6 +1,10 @@
{ config, pkgs, ... }: { config, pkgs, lib, ... }:
{ let
cfg = config.my.roles.graphical;
in {
options.my.roles.graphical.enable = lib.mkEnableOption "Enable GUI";
config = lib.mkIf (cfg.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
firefox firefox
alacritty alacritty
@ -114,4 +118,5 @@
x11.defaultCursor = "Catppuccin-Macchiato-Dark-Cursors"; x11.defaultCursor = "Catppuccin-Macchiato-Dark-Cursors";
}; };
}; };
};
} }

View file

@ -1,7 +1,12 @@
{ config, pkgs, ... }: { config, pkgs, lib, ... }:
{ let
cfg = config.my.roles.latex;
in {
options.my.roles.latex.enable = lib.mkEnableOption "Enable latex stuff";
config = lib.mkIf (cfg.enable){
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
texlive.combined.scheme-full texlive.combined.scheme-full
]; ];
};
} }

View file

@ -1,5 +1,14 @@
{ pkgs, ... }: { pkgs, config, lib, ... }:
{ let
cfg = config.my.roles.virtualisation;
in {
options.my.roles.virtualisation.enable = lib.mkEnableOption "Enable tools for virtualisation";
config = lib.mkIf (cfg.enable) {
virtualisation.libvirtd.enable = true; virtualisation.libvirtd.enable = true;
environment.systemPackages = with pkgs; [
qemu_full
qemu-utils
];
};
} }

View file

@ -1,6 +1,10 @@
{ ... }: { config, lib, ... }:
{ let
cfg = config.my.roles.yggdrasil-client;
in {
options.my.roles.yggdrasil-client.enable = lib.mkEnableOption "Enable yggdrasil";
config = lib.mkIf (cfg.enable) {
services.yggdrasil = { services.yggdrasil = {
enable = true; enable = true;
persistentKeys = true; persistentKeys = true;
@ -10,4 +14,5 @@
]; ];
}; };
}; };
};
} }