From d446d04ad70ab7943da6d5c3bdd3c1e1bf9a235c Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:11:54 +0100 Subject: [PATCH] Switch to single-user design --- flake.nix | 5 +++-- hosts/adalbert/default.nix | 1 - hosts/common/global/default.nix | 2 ++ .../common/{users/ghoscht/default.nix => global/user.nix} | 8 ++++++-- vars.nix | 7 +++++++ 5 files changed, 18 insertions(+), 5 deletions(-) rename hosts/common/{users/ghoscht/default.nix => global/user.nix} (72%) create mode 100644 vars.nix diff --git a/flake.nix b/flake.nix index 81dec07..2f57185 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,7 @@ # 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; + vars = import ./vars.nix; in { # Your custom packages # Accessible through 'nix build', 'nix shell', etc @@ -59,7 +60,7 @@ # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { adalbert = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs;}; + specialArgs = {inherit inputs outputs vars;}; modules = [ ./hosts/adalbert ]; @@ -71,7 +72,7 @@ homeConfigurations = { "ghoscht@adalbert" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = {inherit inputs outputs;}; + extraSpecialArgs = {inherit inputs outputs vars;}; modules = [ ./home/ghoscht/adalbert.nix ]; diff --git a/hosts/adalbert/default.nix b/hosts/adalbert/default.nix index e0d16f0..a211395 100644 --- a/hosts/adalbert/default.nix +++ b/hosts/adalbert/default.nix @@ -25,7 +25,6 @@ ./hardware-configuration.nix ../common/global - ../common/users/ghoscht ../common/optional/desktop/awesome.nix ../common/optional/systemd-boot.nix diff --git a/hosts/common/global/default.nix b/hosts/common/global/default.nix index 7ad5703..6f66581 100644 --- a/hosts/common/global/default.nix +++ b/hosts/common/global/default.nix @@ -2,11 +2,13 @@ { inputs, outputs, + config, ... }: { imports = [ inputs.home-manager.nixosModules.home-manager + ./user.nix ./fish.nix ./locale.nix ./nix.nix diff --git a/hosts/common/users/ghoscht/default.nix b/hosts/common/global/user.nix similarity index 72% rename from hosts/common/users/ghoscht/default.nix rename to hosts/common/global/user.nix index 05e1241..7b6a690 100644 --- a/hosts/common/users/ghoscht/default.nix +++ b/hosts/common/global/user.nix @@ -1,11 +1,15 @@ { + inputs, + outputs, pkgs, config, + vars, ... }: let ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups; in { - users.users.ghoscht = { + imports = builtins.attrValues outputs.nixosModules; #propagates imports downwards + users.users.${vars.user} = { isNormalUser = true; shell = pkgs.fish; extraGroups = @@ -38,5 +42,5 @@ in { packages = [pkgs.home-manager]; }; - home-manager.users.ghoscht = import ../../../../home/ghoscht/${config.networking.hostName}.nix; + home-manager.users.${vars.user} = import ../../../home/${vars.user}/${config.networking.hostName}.nix; } diff --git a/vars.nix b/vars.nix new file mode 100644 index 0000000..2b5c5da --- /dev/null +++ b/vars.nix @@ -0,0 +1,7 @@ +{ + # Global variables used in NixOS and HomeManager which will probably never change + user = "ghoscht"; + location = "$HOME/.setup"; + terminal = "alacritty"; + editor = "nvim"; +}