From 035bb3eaab3f9011800ffff3ac355fc3c6eaa72e Mon Sep 17 00:00:00 2001 From: Leonhard Kost Date: Sun, 25 Jan 2026 23:57:06 +0100 Subject: [PATCH] chore: prepare config structure for multiple hosts --- flake.nix | 34 +++----------- nixos/{configuration.nix => base.nix} | 27 +----------- nixos/desktop/default.nix | 44 +++++++++++++++++++ .../{ => desktop}/hardware-configuration.nix | 3 -- 4 files changed, 51 insertions(+), 57 deletions(-) rename nixos/{configuration.nix => base.nix} (73%) create mode 100644 nixos/desktop/default.nix rename nixos/{ => desktop}/hardware-configuration.nix (97%) diff --git a/flake.nix b/flake.nix index 8042854..e20c038 100644 --- a/flake.nix +++ b/flake.nix @@ -1,15 +1,8 @@ { - description = "Your new nix config"; - inputs = { - # Nixpkgs nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; - # You can access packages and modules from different nixpkgs revs - # at the same time. Here's an working example: nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; - # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. - # Home manager home-manager.url = "github:nix-community/home-manager/release-25.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; @@ -27,44 +20,27 @@ }@inputs: let inherit (self) outputs; - # Supported systems for your flake packages, shell, etc. - systems = [ - "x86_64-linux" - ]; - # This is a function that generates an attribute by calling a function you - # pass to it, with each system as an argument - forAllSystems = nixpkgs.lib.genAttrs systems; + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; in { - # Your custom packages - # Accessible through 'nix build', 'nix shell', etc - packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); - - # Your custom packages and modifications, exported as overlays + packages = import ./pkgs pkgs; overlays = import ./overlays { inherit inputs; }; - # Reusable nixos modules you might want to export - # These are usually stuff you would upstream into nixpkgs nixosModules = import ./modules/nixos; - # Reusable home-manager modules you might want to export - # These are usually stuff you would upstream into home-manager homeManagerModules = import ./modules/home-manager; - # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { desktop = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs; }; modules = [ - ./nixos/configuration.nix + ./nixos/desktop ]; }; }; - # Standalone home-manager configuration entrypoint - # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { "leonhard@desktop" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance + inherit pkgs; extraSpecialArgs = { inherit inputs outputs; }; modules = [ ./home-manager/home.nix diff --git a/nixos/configuration.nix b/nixos/base.nix similarity index 73% rename from nixos/configuration.nix rename to nixos/base.nix index 0aa528e..6ebb0a9 100644 --- a/nixos/configuration.nix +++ b/nixos/base.nix @@ -1,5 +1,3 @@ -# This is your system's configuration file. -# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) { inputs, outputs, @@ -10,7 +8,6 @@ }: { imports = [ - ./hardware-configuration.nix outputs.nixosModules ]; @@ -73,32 +70,12 @@ LC_TIME = "de_DE.UTF-8"; }; - # Enable CUPS to print documents. - #services.printing.enable = true; - - # Enable firmware - #hardware.enableAllFirmware = true; - - # Enable bluetooth - #hardware.bluetooth.enable = true; - - # Enable sound with pipewire. - # security.rtkit.enable = true; - # services.pipewire = { - # enable = true; - # alsa.enable = true; - # alsa.support32Bit = true; - # pulse.enable = true; - # }; - - networking.hostName = "desktop"; - users.users = { leonhard = { - # TODO: You can set an initial password for your user. + # You can set an initial password for your user. # If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install. # Be sure to change it (using passwd) after rebooting! - initialPassword = "correcthorsebatterystaple"; + initialPassword = "leonhard"; isNormalUser = true; extraGroups = [ "wheel" ]; }; diff --git a/nixos/desktop/default.nix b/nixos/desktop/default.nix new file mode 100644 index 0000000..4cb272a --- /dev/null +++ b/nixos/desktop/default.nix @@ -0,0 +1,44 @@ +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: +{ + imports = [ + (import ../base.nix { + inherit + inputs + outputs + config + lib + pkgs + ; + }) + (import ./hardware-configuration.nix { + inherit lib; + }) + ]; + + # Enable CUPS to print documents. + #services.printing.enable = true; + + # Enable firmware + #hardware.enableAllFirmware = true; + + # Enable bluetooth + #hardware.bluetooth.enable = true; + + # Enable sound with pipewire. + # security.rtkit.enable = true; + # services.pipewire = { + # enable = true; + # alsa.enable = true; + # alsa.support32Bit = true; + # pulse.enable = true; + # }; + + networking.hostName = "desktop"; +} diff --git a/nixos/hardware-configuration.nix b/nixos/desktop/hardware-configuration.nix similarity index 97% rename from nixos/hardware-configuration.nix rename to nixos/desktop/hardware-configuration.nix index 55b7d48..f085698 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/desktop/hardware-configuration.nix @@ -1,8 +1,5 @@ { - config, lib, - pkgs, - modulesPath, ... }: