From efe873d7143299a86b15d017ff537918a4f9a819 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Thu, 30 Oct 2025 18:16:10 +0100 Subject: [PATCH] cleaned up the flake --- flake.nix | 223 ++++++++++++++++++---------------------- modules/nixos/power.nix | 2 + 2 files changed, 103 insertions(+), 122 deletions(-) diff --git a/flake.nix b/flake.nix index 03f1677..ed00d40 100644 --- a/flake.nix +++ b/flake.nix @@ -5,21 +5,26 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Home manager - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Managing flatpak apps nix-flatpak.url = "github:gmodena/nix-flatpak"; + # hyprland, plugins and related utils hyprland.url = "github:hyprwm/Hyprland"; + stylix = { url = "github:nix-community/stylix"; inputs.nixpkgs.follows = "nixpkgs"; }; # zen browser - zen-browser.url = "github:0xc000022070/zen-browser-flake"; - # IMPORTANT: we're using "libgbm" and is only available in unstable so ensure - # to have it up-to-date or simply don't specify the nixpkgs input - zen-browser.inputs.nixpkgs.follows = "nixpkgs"; + zen-browser = { + url = "github:0xc000022070/zen-browser-flake"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # power management watt = { @@ -28,8 +33,10 @@ }; # secrets - sops-nix.url = "github:Mic92/sops-nix"; - sops-nix.inputs.nixpkgs.follows = "nixpkgs"; + sops-nix = { + url = "github:Mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # quickshell dms-cli = { @@ -42,7 +49,6 @@ inputs.dms-cli.follows = "dms-cli"; }; - nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions"; }; @@ -63,123 +69,96 @@ pkgs = nixpkgs.legacyPackages.${system}; pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; + + lib = nixpkgs.lib; + + systems = { + # HP Spectre x360 2018 + Nixtre = { + hostModules = [ + ./hosts/spectre-x360-2018 + ]; + userModules = [ + ./users/remy_spectre + inputs.nix-flatpak.homeManagerModules.nix-flatpak + ]; + extraModules = [ + inputs.stylix.nixosModules.stylix + inputs.sops-nix.nixosModules.sops + ]; + }; + + # Portable usb stick + nichts = { + hostModules = [ + ./hosts/mobile-usb + ]; + userModules = [ + ./users/remy_usb + inputs.nix-flatpak.homeManagerModules.nix-flatpak + ]; + extraModules = [ + inputs.stylix.nixosModules.stylix + inputs.sops-nix.nixosModules.sops + ]; + }; + + # Lenovo yoga 7 pro + nyx = { + hostModules = [ + ./hosts/yoga-7-pro + ]; + userModules = [ + ./users/remy_yoga + inputs.nix-flatpak.homeManagerModules.nix-flatpak + inputs.dankMaterialShell.homeModules.dankMaterialShell.default + ]; + extraModules = [ + inputs.stylix.nixosModules.stylix + inputs.sops-nix.nixosModules.sops + { nixpkgs.overlays = [ inputs.nix-vscode-extensions.overlays.default ]; } + ]; + }; + }; in { + # For each entry in `systems` create a nixosConfiguration + nixosConfigurations = lib.mapAttrs (_name: cfg: + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { inherit inputs pkgs-unstable; }; + modules = + cfg.hostModules ++ + cfg.extraModules ++ + [ home-manager.nixosModules.home-manager { + # Common home-manager flags + home-manager = { + backupFileExtension = ".backup"; + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { inherit inputs pkgs-unstable; }; + }; - ## NixOS configurations are the main output of this flake - # HP Spectre x360 2018 - nixosConfigurations.Nixtre = nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit pkgs-unstable; - }; - - modules = [ - ./hosts/spectre-x360-2018 - stylix.nixosModules.stylix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit inputs; - inherit pkgs-unstable; - }; - - home-manager.users.remy.imports = [ - ./users/remy_spectre - inputs.nix-flatpak.homeManagerModules.nix-flatpak - ]; - } - ]; - }; + # Merge in all the user fragments for this host + home-manager.users.remy = lib.mkMerge cfg.userModules; + } + ] + ; + } + ) systems; - nixosConfigurations.nichts = nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit pkgs-unstable; - }; - - modules = [ - ./hosts/mobile-usb - stylix.nixosModules.stylix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit inputs; - inherit pkgs-unstable; - }; - - home-manager.users.remy.imports = [ - ./users/remy_usb - inputs.nix-flatpak.homeManagerModules.nix-flatpak - ]; - } - ]; - }; - - - nixosConfigurations.nyx = nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit pkgs-unstable; - }; - - modules = [ - { - nixpkgs.overlays = [ - inputs.nix-vscode-extensions.overlays.default - ]; - } - ./hosts/yoga-7-pro - sops-nix.nixosModules.sops - stylix.nixosModules.stylix - home-manager.nixosModules.home-manager - { - home-manager.backupFileExtension = ".backup"; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit inputs; - inherit pkgs-unstable; - }; - - home-manager.users.remy.imports = [ - ./users/remy_yoga - inputs.nix-flatpak.homeManagerModules.nix-flatpak - inputs.dankMaterialShell.homeModules.dankMaterialShell.default - ]; - } - ]; - }; - - # nixosConfigurations.raspberry-pi = nixpkgs.lib.nixosSystem { - # system = "aarch64-linux"; - # modules = [ - # ./hosts/raspberry-pi/configuration.nix - # ]; - # }; - - ## Home Manager configurations here? - - - ## Useful nix build tools - # iso builder TODO - nixosConfigurations.bcachefs-iso = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix" - ({ lib, pkgs, ... }: { - boot.supportedFilesystems = [ "bcachefs" ]; - boot.kernelPackages = lib.mkOverride 0 pkgs.linuxPackages_latest; - }) - ]; - }; + # ## Useful nix build tools + # # iso builder TODO + # nixosConfigurations.bcachefs-iso = nixpkgs.lib.nixosSystem { + # system = "x86_64-linux"; + # modules = [ + # "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix" + # ({ lib, pkgs, ... }: { + # boot.supportedFilesystems = [ "bcachefs" ]; + # boot.kernelPackages = lib.mkOverride 0 pkgs.linuxPackages_latest; + # }) + # ]; + # }; }; } diff --git a/modules/nixos/power.nix b/modules/nixos/power.nix index 51128a9..cbe67e8 100644 --- a/modules/nixos/power.nix +++ b/modules/nixos/power.nix @@ -79,6 +79,8 @@ }; }; + services.upower.enable = true; + services.irqbalance = { enable = true;