Merge pull request #1 from JustScreaMy/refactor-config

Refactor config
This commit is contained in:
Jakub Kropáček 2024-09-23 19:40:33 +02:00 committed by GitHub
commit 3fd894bffd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 572 additions and 149 deletions

View file

@ -1,5 +1,23 @@
{ {
"nodes": { "nodes": {
"disko": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1726842196,
"narHash": "sha256-u9h03JQUuQJ607xmti9F9Eh6E96kKUAGP+aXWgwm70o=",
"owner": "nix-community",
"repo": "disko",
"rev": "51994df8ba24d5db5459ccf17b6494643301ad28",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -7,11 +25,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1726611255, "lastModified": 1726785354,
"narHash": "sha256-/bxaYvIK6/d3zqpW26QFS0rqfd0cO4qreSNWvYLTl/w=", "narHash": "sha256-SLorVhoorZwjM1aS04bBX4fufEXIfkMdAGkj9bu2QAQ=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "d2493de5cd1da06b6a4c3e97f4e7d5dd791df457", "rev": "1786e2afdbc48e9038f7cff585069736e1d0ed44",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -36,6 +54,22 @@
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1725194671,
"narHash": "sha256-tLGCFEFTB5TaOKkpfw3iYT9dnk4awTP/q4w+ROpMfuw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b833ff01a0d694b910daca6e2ff4a3f26dee478c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1726583932, "lastModified": 1726583932,
"narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=", "narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=",
@ -53,9 +87,10 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-flatpak": "nix-flatpak", "nix-flatpak": "nix-flatpak",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs_2",
"stable": "stable" "stable": "stable"
} }
}, },

View file

@ -11,25 +11,36 @@
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
disko.url = "github:nix-community/disko";
}; };
outputs = inputs@{ self, nixpkgs, ... }: { outputs =
inputs@{ self, nixpkgs, ... }:
{
# Please replace my-nixos with your hostname # Please replace my-nixos with your hostname
nixosConfigurations = { nixosConfigurations = {
work-ntb = nixpkgs.lib.nixosSystem { work-ntb = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
./hosts/work-ntb ./hosts/work-ntb
inputs.nix-flatpak.nixosModules.nix-flatpak ./hosts/base
inputs.home-manager.nixosModules.home-manager
]; ];
specialArgs = { specialArgs = {
hostname = "work-ntb"; inherit inputs;
}; };
}; };
extraSpecialArgs = { lenar = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hosts/lenar
./hosts/base
];
specialArgs = {
inherit inputs; inherit inputs;
}; };
}; };
}; };
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
};
} }

View file

@ -2,26 +2,28 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, hostname, ... }: {
config,
pkgs,
inputs,
...
}:
{ {
imports =
[ # Include the results of the hardware scan. imports = [
../${hostname}/hardware-configuration.nix inputs.home-manager.nixosModules.home-manager # TODO: move to base
../../modules/dev inputs.nix-flatpak.nixosModules.nix-flatpak # TODO: move to base
../../nixosModules
]; ];
# Bootloader. # Bootloader.
boot.loader.systemd-boot.enable = true; boot.loader = {
boot.loader.efi.canTouchEfiVariables = true; systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
networking.hostName = hostname; # Define your hostname. };
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. Not needed if using GNOME # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. Not needed if using GNOME
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
@ -44,11 +46,13 @@
}; };
# Enable the X11 windowing system. # Enable the X11 windowing system.
services.xserver.enable = true; services.xserver = {
enable = true;
# Enable the GNOME Desktop Environment. # Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true; displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true; desktopManager.gnome.enable = true;
};
services.gnome.gnome-browser-connector.enable = true; services.gnome.gnome-browser-connector.enable = true;
environment.gnome.excludePackages = with pkgs; [ environment.gnome.excludePackages = with pkgs; [
@ -96,17 +100,21 @@
users.users.krop = { users.users.krop = {
isNormalUser = true; isNormalUser = true;
description = "Jakub Kropacek"; description = "Jakub Kropacek";
extraGroups = [ "networkmanager" "wheel" ]; extraGroups = [
"networkmanager"
"wheel"
];
shell = pkgs.zsh; shell = pkgs.zsh;
}; };
# Allow unfree packages # Allow unfree packages
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
# Enable flakes # Enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [
"nix-command"
"flakes"
];
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
@ -125,9 +133,9 @@
prismlauncher # REMOVE AND MOVE TO games module after refactoring prismlauncher # REMOVE AND MOVE TO games module after refactoring
gnome-extension-manager # DEBUG gnome-extension-manager # DEBUG
gnomeExtensions.grand-theft-focus gnomeExtensions.grand-theft-focus
joplin-desktop
]; ];
programs = { programs = {
tmux.enable = true; tmux.enable = true;
zsh.enable = true; zsh.enable = true;
@ -142,8 +150,14 @@
services.flatpak = { services.flatpak = {
enable = true; enable = true;
remotes = [ remotes = [
{ name = "flathub"; location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; } {
{ name = "flathub-beta"; location = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo"; } name = "flathub";
location = "https://dl.flathub.org/repo/flathub.flatpakrepo";
}
{
name = "flathub-beta";
location = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo";
}
]; ];
packages = [ packages = [
"org.gnome.World.PikaBackup" "org.gnome.World.PikaBackup"

34
hosts/lenar/default.nix Normal file
View file

@ -0,0 +1,34 @@
{
config,
pkgs,
inputs,
...
}:
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
inputs.disko.nixosModules.disko
./disko.nix
];
networking.hostName = "lenar"; # Define your hostname.
# My own modules configuration
krop = {
ide = {
enable = true;
install-pycharm = true;
};
python.install-older = true;
};
home-manager = {
extraSpecialArgs = {
inherit inputs;
};
users = {
"krop" = import ./home.nix;
};
};
}

53
hosts/lenar/disko.nix Normal file
View file

@ -0,0 +1,53 @@
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
name = "ESP";
start = "1M";
end = "128M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
# Subvolume name is different from mountpoint
"/rootfs" = {
mountpoint = "/";
};
# Subvolume name is the same as the mountpoint
"/home" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/home";
};
# Parent is not mounted so the mountpoint must be set
"/nix" = {
mountOptions = [ "compress=zstd" "noatime" ];
mountpoint = "/nix";
};
};
mountpoint = "/partition-root";
};
};
};
};
};
};
};
}

View file

@ -0,0 +1,22 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

147
hosts/lenar/home.nix Normal file
View file

@ -0,0 +1,147 @@
{ config, pkgs, ... }:
{
home.username = "krop";
home.homeDirectory = "/home/krop";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "24.05"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = with pkgs; [
gnomeExtensions.grand-theft-focus
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# hello
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. These will be explicitly sourced when using a
# shell provided by Home Manager. If you don't want to manage your shell
# through Home Manager then you have to manually source 'hm-session-vars.sh'
# located at either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/krop/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
# EDITOR = "emacs";
};
dconf = {
enable = true;
settings."org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = with pkgs.gnomeExtensions; [
grand-theft-focus.extensionUuid
];
};
};
gtk = {
enable = true;
gtk3.extraConfig = {
Settings = ''
gtk-application-prefer-dark-theme=1
'';
};
gtk4.extraConfig = {
Settings = ''
gtk-application-prefer-dark-theme=1
'';
};
};
qt = {
enable = true;
platformTheme.name = "adwaita"; # TODO: fix themes
style.name = "adwaita-dark";
};
programs.git = {
enable = true;
userName = "Jakub Kropáček";
userEmail = "kropikuba@gmail.com";
includes =
let
workcfg = {
user = {
email = "jakub.kropacek@olc.cz";
name = "Jakub Kropáček";
};
};
in
[
{
condition = "gitdir:~/Repositories/OLC/**";
contents = workcfg;
}
{
condition = "gitdir:~/Repositories/OLC-Hexpol/**";
contents = workcfg;
}
];
extraConfig = {
init = {
defaultBranch = "master";
};
push = {
autoSetupRemote = true;
};
status = {
submoduleSummary = true;
};
diff = {
submodule = "log";
};
core = {
autocrlf = "input";
};
};
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

View file

@ -1,13 +1,30 @@
{config, pkgs, inputs, ...}: { {
config,
pkgs,
inputs,
...
}:
{
imports = [ imports = [
(import ../base {inherit config pkgs; hostname = "work-ntb"; }) # Include the results of the hardware scan.
./hardware-configuration.nix
]; ];
networking.hostName = "work-ntb"; # Define your hostname.
# My own modules configuration # My own modules configuration
krop.devtools.installIDE = true; krop = {
ide = {
enable = true;
install-pycharm = true;
};
python.install-older = true;
};
home-manager = { home-manager = {
extraSpecialArgs = { inherit inputs; }; extraSpecialArgs = {
inherit inputs;
};
users = { users = {
"krop" = import ./home.nix; "krop" = import ./home.nix;
}; };

View file

@ -1,27 +1,42 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"usb_storage"
"sd_mod"
"rtsx_pci_sdmmc"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/360cfb7a-07d9-445b-83e2-6ef19bd55948"; device = "/dev/disk/by-uuid/360cfb7a-07d9-445b-83e2-6ef19bd55948";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/5F8E-3C09"; device = "/dev/disk/by-uuid/5F8E-3C09";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ]; options = [
"fmask=0077"
"dmask=0077"
];
}; };
swapDevices = [ ]; swapDevices = [ ];

View file

@ -100,17 +100,20 @@
style.name = "adwaita-dark"; style.name = "adwaita-dark";
}; };
programs.git = { programs.git = {
enable = true; enable = true;
userName = "Jakub Kropáček"; userName = "Jakub Kropáček";
userEmail = "kropikuba@gmail.com"; userEmail = "kropikuba@gmail.com";
includes = let workcfg = { includes =
let
workcfg = {
user = { user = {
email = "jakub.kropacek@olc.cz"; email = "jakub.kropacek@olc.cz";
name = "Jakub Kropáček"; name = "Jakub Kropáček";
}; };
}; in [ };
in
[
{ {
condition = "gitdir:~/Repositories/OLC/**"; condition = "gitdir:~/Repositories/OLC/**";
contents = workcfg; contents = workcfg;

View file

@ -1,43 +0,0 @@
{ config, pkgs, lib, ... }@inputs:
let
cfg = config.krop.devtools;
in {
options.krop.devtools = {
installIDE = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether to install the ides";
};
installTools = lib.mkOption {
type = lib.types.bool;
default = true;
example = true;
description = "Whether to install the most used tools";
};
};
config = let
ides = with pkgs; [
jetbrains.pycharm-professional
zed-editor
vscodium
];
languages = with pkgs; [
python3
python311
python310
poetry
];
tools = with pkgs; [
lazygit
lazydocker
micro-with-wl-clipboard
albert
openssl_3_3
];
in {
environment.systemPackages = languages
++ (lib.optionals cfg.installIDE ides)
++ (lib.optionals cfg.installTools tools);
};
}

6
nixosModules/default.nix Normal file
View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = [
./dev
];
}

View file

@ -0,0 +1,37 @@
{
config,
pkgs,
lib,
...
}@inputs:
let
cfg = config.krop.devtools;
in
{
imports = [
./python.nix
./ide.nix
];
options.krop.devtools = {
installTools = lib.mkOption {
type = lib.types.bool;
default = true;
example = true;
description = "Whether to install the most used tools";
};
};
config =
let
tools = with pkgs; [
lazygit
lazydocker
micro-with-wl-clipboard
albert
openssl_3_3
];
in
{
environment.systemPackages = tools;
};
}

4
nixosModules/dev/go.nix Normal file
View file

@ -0,0 +1,4 @@
{
...
}:
{ }

32
nixosModules/dev/ide.nix Normal file
View file

@ -0,0 +1,32 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.krop.ide;
in
{
options.krop.ide = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
example = true;
};
install-pycharm = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages =
with pkgs;
[
zed-editor
vscodium
]
++ lib.optionals cfg.install-pycharm [ pkgs.jetbrains.pycharm-professional ];
};
}

View file

@ -0,0 +1,36 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.krop.python;
in
{
options.krop.python = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
};
install-older = lib.mkOption {
type = lib.types.bool;
default = true;
example = true;
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages =
with pkgs;
[
python3
poetry
]
++ lib.optionals cfg.install-older [
python311
python310
];
};
}