From 9e890279e65f3f302661f48305e71e22b200b5eb Mon Sep 17 00:00:00 2001 From: Ahurac Date: Mon, 30 Sep 2024 13:54:20 +0200 Subject: [PATCH] feat: modularization --- ahrc-laptop/configuration.nix | 39 ++++++++ .../hardware-configuration.nix | 0 ahrc-laptop/home.nix | 2 + common/configuration.nix | 50 ++++++++++ configuration.nix | 93 ------------------- flake.nix | 2 +- 6 files changed, 92 insertions(+), 94 deletions(-) create mode 100644 ahrc-laptop/configuration.nix rename hardware-configuration.nix => ahrc-laptop/hardware-configuration.nix (100%) create mode 100644 common/configuration.nix delete mode 100644 configuration.nix diff --git a/ahrc-laptop/configuration.nix b/ahrc-laptop/configuration.nix new file mode 100644 index 0000000..58ca3f3 --- /dev/null +++ b/ahrc-laptop/configuration.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ ../common/configuration.nix ./hardware-configuration.nix ]; + + networking.hostName = "ahrc-laptop"; + + environment.systemPackages = with pkgs; [ powertop brightnessctl ]; + + services.libinput.enable = true; + + services.tlp = { + enable = true; + settings = { + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + + CPU_MIN_PERF_ON_AC = 100; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 20; + CPU_MAX_PERF_ON_BAT = 100; + }; + }; + + programs.bash.promptInit = '' + if [ "$(whoami)" = root ]; then + color=31 + else + color=32 + user='\u@' + fi + PS1="\[\033[0m\](\[\033[1;''${color}m\]''${user}\h\[\033[0m\] \[\033[1;34m\]\W\[\033[0m\])\\$ " + ''; + + system.stateVersion = "24.05"; +} diff --git a/hardware-configuration.nix b/ahrc-laptop/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to ahrc-laptop/hardware-configuration.nix diff --git a/ahrc-laptop/home.nix b/ahrc-laptop/home.nix index 0f02fdb..efb9b55 100644 --- a/ahrc-laptop/home.nix +++ b/ahrc-laptop/home.nix @@ -27,6 +27,7 @@ gcc valgrind weston + nixfmt-classic (nerdfonts.override { fonts = [ "Hack" ]; }) ]; @@ -110,6 +111,7 @@ l = "log"; graph = "log --graph --oneline"; sh = "show"; + ds = "diff --staged"; }; userEmail = "ahurac@mailbox.org"; userName = "Ahurac"; diff --git a/common/configuration.nix b/common/configuration.nix new file mode 100644 index 0000000..e5f2e65 --- /dev/null +++ b/common/configuration.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +{ + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.timeout = 0; + boot.kernelPackages = pkgs.linuxPackages_zen; + boot.tmp.useTmpfs = true; + + networking.networkmanager.enable = true; + + time.timeZone = "Europe/Paris"; + + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "fr-pc"; + }; + + services.pipewire = { + enable = true; + pulse.enable = true; + }; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + environment.systemPackages = with pkgs; [ + git + vim + curl + ncdu + htop + tmux + file + tree + ]; + + services.udisks2.enable = true; + + programs.hyprland.enable = true; + programs.zsh.enable = true; + + users.users.ahurac = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; + shell = pkgs.zsh; + }; + + system.stateVersion = "24.05"; +} diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index f1154c1..0000000 --- a/configuration.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - imports = [ ./hardware-configuration.nix ]; - - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.timeout = 0; - boot.kernelPackages = pkgs.linuxPackages_zen; - boot.tmp.useTmpfs = true; - - networking.hostName = "ahrc-laptop"; - networking.networkmanager.enable = true; - - time.timeZone = "Europe/Paris"; - - i18n.defaultLocale = "en_US.UTF-8"; - console = { - font = "Lat2-Terminus16"; - keyMap = "fr-pc"; - }; - - services.pipewire = { - enable = true; - pulse.enable = true; - }; - - #nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - environment.systemPackages = with pkgs; [ - vim - curl - ncdu - htop - tmux - powertop - file - nixfmt-classic - tree - brightnessctl - podman-compose - ]; - - services.libinput.enable = true; - services.udisks2.enable = true; - - services.tlp = { - enable = true; - settings = { - CPU_SCALING_GOVERNOR_ON_AC = "performance"; - CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; - - CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - - CPU_MIN_PERF_ON_AC = 100; - CPU_MAX_PERF_ON_AC = 100; - CPU_MIN_PERF_ON_BAT = 20; - CPU_MAX_PERF_ON_BAT = 100; - }; - }; - - programs.hyprland.enable = true; - programs.zsh.enable = true; - - programs.bash.promptInit = '' - if [ "$(whoami)" = root ]; then - color=31 - else - color=32 - user='\u@' - fi - PS1="\[\033[0m\](\[\033[1;''${color}m\]''${user}\h\[\033[0m\] \[\033[1;34m\]\W\[\033[0m\])\\$ " - ''; - - virtualisation.containers.enable = true; - virtualisation = { - podman = { - enable = true; - dockerCompat = true; - defaultNetwork.settings.dns_enabled = true; - }; - }; - boot.kernel.sysctl."net.ipv4.ip_unprivileged_port_start" = 0; - - users.users.ahurac = { - isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" ]; - shell = pkgs.zsh; - }; - - system.stateVersion = "24.05"; -} diff --git a/flake.nix b/flake.nix index 3c4e10b..3789ea6 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ nixosConfigurations.ahrc-laptop = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ - ./configuration.nix + ./ahrc-laptop/configuration.nix home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true;