From edcbfaf37971523d1321b349a330c47ba3e1524a Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sat, 25 May 2024 15:16:08 +0200 Subject: [PATCH] Continue refactoring --- flake.nix | 6 +++- home/common-home-manager.nix | 8 ----- home/default.nix | 14 --------- hosts/nixos-test/{system.nix => default.nix} | 22 +++++++++++++- hosts/nixos-test/home.nix | 8 ----- hosts/perso-desktop/default.nix | 31 ++++++++++++-------- hosts/perso-laptop/default.nix | 30 ++++++++++++------- hosts/pro-laptop/default.nix | 30 ++++++++++++------- lib/default.nix | 14 +++++++-- 9 files changed, 95 insertions(+), 68 deletions(-) delete mode 100644 home/common-home-manager.nix delete mode 100644 home/default.nix rename hosts/nixos-test/{system.nix => default.nix} (60%) delete mode 100644 hosts/nixos-test/home.nix diff --git a/flake.nix b/flake.nix index 8f4085f..6207a51 100644 --- a/flake.nix +++ b/flake.nix @@ -37,11 +37,15 @@ ${s.name} = nixpkgs.lib.nixosSystem { inherit (s) system; modules = [ + ./lib ./hosts/${s.name} home-manager.nixosModules.home-manager agenix.nixosModules.default - (import ./home/common-home-manager.nix { inherit inputs; }) ]; + + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = inputs; }; }) {} systems; }; diff --git a/home/common-home-manager.nix b/home/common-home-manager.nix deleted file mode 100644 index 3dd0d04..0000000 --- a/home/common-home-manager.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ inputs, ... }: - -{ - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = inputs; - home-manager.users.florian = import ../home; -} \ No newline at end of file diff --git a/home/default.nix b/home/default.nix deleted file mode 100644 index 4238c12..0000000 --- a/home/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, ... }: - -{ - home = { - username = "florian"; - homeDirectory = "/home/florian"; - - stateVersion = "24.05"; - }; - - programs.home-manager.enable = true; - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; -} diff --git a/hosts/nixos-test/system.nix b/hosts/nixos-test/default.nix similarity index 60% rename from hosts/nixos-test/system.nix rename to hosts/nixos-test/default.nix index 2e086ab..e25ea98 100644 --- a/hosts/nixos-test/system.nix +++ b/hosts/nixos-test/default.nix @@ -7,6 +7,8 @@ { imports = [ + ../../modules + # Include the results of the hardware scan. ./hardware-configuration.nix ]; @@ -21,8 +23,26 @@ }; }; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.florian = { + isNormalUser = true; + initialPassword = "test"; + description = "florian"; + extraGroups = [ "networkmanager" "wheel" ]; + }; + home-manager.users.florian = { + home = { + username = "florian"; + homeDirectory = "/home/florian"; + + stateVersion = "24.05"; + }; + + programs.home-manager.enable = true; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + }; + # Configure for testing in vm - users.users.florian.initialPassword = "test"; virtualisation.vmVariant = { # following configuration is added only when building VM with build-vm virtualisation = { diff --git a/hosts/nixos-test/home.nix b/hosts/nixos-test/home.nix deleted file mode 100644 index 86211b2..0000000 --- a/hosts/nixos-test/home.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - - ]; -} \ No newline at end of file diff --git a/hosts/perso-desktop/default.nix b/hosts/perso-desktop/default.nix index 8bb5d4c..f2e0303 100644 --- a/hosts/perso-desktop/default.nix +++ b/hosts/perso-desktop/default.nix @@ -7,18 +7,7 @@ { imports = [ - ../../modules/linux_gaming.nix - ../../modules/system.nix - ../../modules/network.nix - ../../modules/nvidia.nix - ../../modules/plasma.nix - ../../modules/keymaps/us.nix - ../../modules/bluetooth.nix - ../../modules/pipewire.nix - ../../modules/plymouth.nix - ../../modules/waydroid.nix - - ../../modules # Import optional configuration + ../../modules # Include the results of the hardware scan. ./hardware-configuration.nix @@ -28,5 +17,23 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.florian = { + isNormalUser = true; + description = "florian"; + extraGroups = [ "networkmanager" "wheel" ]; + }; + home-manager.users.florian = { + home = { + username = "florian"; + homeDirectory = "/home/florian"; + + stateVersion = "24.05"; + }; + + programs.home-manager.enable = true; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + }; + networking.hostName = "nixos-desktop-perso"; # Define your hostname. } diff --git a/hosts/perso-laptop/default.nix b/hosts/perso-laptop/default.nix index 10e6930..f1b07cd 100644 --- a/hosts/perso-laptop/default.nix +++ b/hosts/perso-laptop/default.nix @@ -7,17 +7,7 @@ { imports = [ - ../../modules/linux_gaming.nix - ../../modules/system.nix - ../../modules/network.nix - ../../modules/nvidia.nix - ../../modules/plasma.nix - ../../modules/keymaps/fr.nix - ../../modules/bluetooth.nix - ../../modules/pipewire.nix - ../../modules/plymouth.nix - - ../../modules # Import optional configuration + ../../modules # Include the results of the hardware scan. ./hardware-configuration.nix @@ -27,6 +17,24 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.florian = { + isNormalUser = true; + description = "florian"; + extraGroups = [ "networkmanager" "wheel" ]; + }; + home-manager.users.florian = { + home = { + username = "florian"; + homeDirectory = "/home/florian"; + + stateVersion = "24.05"; + }; + + programs.home-manager.enable = true; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + }; + networking.hostName = "nixos-laptop-perso"; # Define your hostname. hardware.nvidia.prime = { diff --git a/hosts/pro-laptop/default.nix b/hosts/pro-laptop/default.nix index a32c402..6c9d88d 100644 --- a/hosts/pro-laptop/default.nix +++ b/hosts/pro-laptop/default.nix @@ -7,17 +7,7 @@ { imports = [ - ../../modules/linux_gaming.nix - ../../modules/system.nix - ../../modules/network.nix - ../../modules/nvidia.nix - ../../modules/plasma.nix - ../../modules/keymaps/fr.nix - ../../modules/bluetooth.nix - ../../modules/pipewire.nix - ../../modules/plymouth.nix - - ../../modules # Import optional configuration + ../../modules # Include the results of the hardware scan. ./hardware-configuration.nix @@ -27,6 +17,24 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.florian = { + isNormalUser = true; + description = "florian"; + extraGroups = [ "networkmanager" "wheel" ]; + }; + home-manager.users.florian = { + home = { + username = "florian"; + homeDirectory = "/home/florian"; + + stateVersion = "24.05"; + }; + + programs.home-manager.enable = true; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + }; + networking.hostName = "nixos-laptop-pro"; # Define your hostname. hardware.nvidia.prime = { diff --git a/lib/default.nix b/lib/default.nix index a7d6a57..cf7d3b3 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,15 @@ -{ config, ... }: +{ lib, ... }: +let + applyHomeManagerConfig = { home-manager, ... }: let + applyConfig = user: { + home-manager.users.${user.name} = user.config; + }; + in + { + home-manager.users = lib.foldl' (acc: user: acc // applyConfig user) {} (lib.attrValues home-manager.users); + }; +in { - + applyHomeManagerConfig = applyHomeManagerConfig; } \ No newline at end of file