diff --git a/flake.nix b/flake.nix index 0b7d13a..826e68b 100644 --- a/flake.nix +++ b/flake.nix @@ -24,23 +24,15 @@ outputs = { self, nixpkgs, - lix-module, - sops-nix, - home-manager, ... } @ inputs: let inherit (self) outputs; in { - # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { wodan = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs;}; - # > Our main nixos configuration file < + specialArgs = { inherit inputs outputs; }; modules = [ - lix-module.nixosModules.default - sops-nix.nixosModules.sops - ./hosts/wodan/configuration.nix + ./hosts/wodan ]; }; }; diff --git a/home-manager/home.nix b/home-manager/home.nix deleted file mode 100644 index 5beab6c..0000000 --- a/home-manager/home.nix +++ /dev/null @@ -1,68 +0,0 @@ -# This is your home-manager configuration file -# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) -{ - inputs, - lib, - config, - pkgs, - ... -}: { - # You can import other home-manager modules here - imports = [ - # If you want to use home-manager modules from other flakes (such as nix-colors): - # inputs.nix-colors.homeManagerModule - - # You can also split up your configuration and import pieces of it here: - # ./nvim.nix - ./git - ]; - - nixpkgs = { - # You can add overlays here - overlays = [ - # If you want to use overlays exported from other flakes: - # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - # Workaround for https://github.com/nix-community/home-manager/issues/2942 - allowUnfreePredicate = _: true; - }; - }; - - home = { - username = "lander"; - homeDirectory = "/home/lander"; - }; - - # Add stuff for your user as you see fit: - # programs.neovim.enable = true; - # home.packages = with pkgs; [ steam ]; - - # Enable home-manager and git - programs.home-manager.enable = true; - programs.git.enable = true; - - programs.neovim = { - enable = true; - vimAlias = true; - vimdiffAlias = true; - defaultEditor = false; - }; - - - # Nicely reload system units when changing configs - systemd.user.startServices = "sd-switch"; - - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "23.05"; -} diff --git a/home/lander/global/default.nix b/home/lander/global/default.nix new file mode 100644 index 0000000..d37a0ba --- /dev/null +++ b/home/lander/global/default.nix @@ -0,0 +1,33 @@ +{ + inputs, + lib, + config, + pkgs, + ... +}: { + imports = [ + ./git + ]; + + home = { + username = "lander"; + homeDirectory = "/home/lander"; + }; + + programs.home-manager.enable = true; + programs.git.enable = true; + + programs.neovim = { + enable = true; + vimAlias = true; + vimdiffAlias = true; + defaultEditor = false; + }; + + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "23.05"; +} diff --git a/home-manager/git/default.nix b/home/lander/global/git/default.nix similarity index 100% rename from home-manager/git/default.nix rename to home/lander/global/git/default.nix diff --git a/home-manager/git/git-identity b/home/lander/global/git/git-identity similarity index 100% rename from home-manager/git/git-identity rename to home/lander/global/git/git-identity diff --git a/home/lander/wodan.nix b/home/lander/wodan.nix new file mode 100644 index 0000000..15966a8 --- /dev/null +++ b/home/lander/wodan.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./global + ]; +} diff --git a/hosts/common/global/default.nix b/hosts/common/global/default.nix new file mode 100644 index 0000000..1dab59b --- /dev/null +++ b/hosts/common/global/default.nix @@ -0,0 +1,20 @@ +# This config will be applied to all hosts +{ + inputs, + outputs, + ... +}: +{ + imports = [ + inputs.home-manager.nixosModules.home-manager + inputs.lix-module.nixosModules.default + inputs.sops-nix.nixosModules.sops + + ./locale.nix + ]; + + home-manager.useGlobalPkgs = true; + home-manager.extraSpecialArgs = { inherit inputs outputs; }; + + networking.domain = "lndr.be"; +} diff --git a/hosts/common/global/locale.nix b/hosts/common/global/locale.nix new file mode 100644 index 0000000..d5ce303 --- /dev/null +++ b/hosts/common/global/locale.nix @@ -0,0 +1,21 @@ +{ lib, ... }: +{ + time.timeZone = lib.mkDefault "Europe/Brussels"; + + location.provider = "geoclue2"; + + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "nl_BE.UTF-8"; + LC_IDENTIFICATION = "nl_BE.UTF-8"; + LC_MEASUREMENT = "nl_BE.UTF-8"; + LC_MONETARY = "nl_BE.UTF-8"; + LC_NAME = "nl_BE.UTF-8"; + LC_NUMERIC = "nl_BE.UTF-8"; + LC_PAPER = "nl_BE.UTF-8"; + LC_TELEPHONE = "nl_BE.UTF-8"; + LC_TIME = "nl_BE.UTF-8"; + }; + }; +} diff --git a/hosts/wodan/virt.nix b/hosts/common/optional/virt.nix similarity index 100% rename from hosts/wodan/virt.nix rename to hosts/common/optional/virt.nix diff --git a/hosts/wodan/yubikey-gpg.nix b/hosts/common/optional/yubikey-gpg.nix similarity index 100% rename from hosts/wodan/yubikey-gpg.nix rename to hosts/common/optional/yubikey-gpg.nix diff --git a/hosts/common/users/lander/default.nix b/hosts/common/users/lander/default.nix new file mode 100644 index 0000000..ffe87a5 --- /dev/null +++ b/hosts/common/users/lander/default.nix @@ -0,0 +1,20 @@ +{ pkgs, config, lib, ... }: +let + ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups; +in +{ + users.users.lander = { + isNormalUser = true; + description = "Lander"; + extraGroups = ifTheyExist [ + "networkmanager" + "wheel" + ]; + + packages = with pkgs; [ + pkgs.home-manager + ]; + }; + + home-manager.users.lander = import ../../../../home/lander/${config.networking.hostName}.nix; +} diff --git a/hosts/wodan/configuration.nix b/hosts/wodan/default.nix similarity index 77% rename from hosts/wodan/configuration.nix rename to hosts/wodan/default.nix index 01777fc..c4399c5 100644 --- a/hosts/wodan/configuration.nix +++ b/hosts/wodan/default.nix @@ -1,16 +1,15 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - { config, pkgs, ... }: { imports = - [ # Include the results of the hardware scan. + [ ./hardware-configuration.nix - ./home-manager.nix - ./yubikey-gpg.nix - ./virt.nix + + ../common/global + ../common/users/lander + + ../common/optional/yubikey-gpg.nix + ../common/optional/virt.nix ]; # Bootloader. @@ -28,24 +27,6 @@ # Enable networking networking.networkmanager.enable = true; - # Set your time zone. - time.timeZone = "Europe/Brussels"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "nl_BE.UTF-8"; - LC_IDENTIFICATION = "nl_BE.UTF-8"; - LC_MEASUREMENT = "nl_BE.UTF-8"; - LC_MONETARY = "nl_BE.UTF-8"; - LC_NAME = "nl_BE.UTF-8"; - LC_NUMERIC = "nl_BE.UTF-8"; - LC_PAPER = "nl_BE.UTF-8"; - LC_TELEPHONE = "nl_BE.UTF-8"; - LC_TIME = "nl_BE.UTF-8"; - }; - # Enable the X11 windowing system. services.xserver.enable = true; @@ -82,14 +63,6 @@ # services.xserver.libinput.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.lander = { - isNormalUser = true; - description = "Lander"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - # thunderbird - ]; - }; # Install firefox. programs.firefox.enable = true; diff --git a/hosts/wodan/home-manager.nix b/hosts/wodan/home-manager.nix deleted file mode 100644 index 49f4517..0000000 --- a/hosts/wodan/home-manager.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ inputs, outputs, ... }: { - imports = [ - inputs.home-manager.nixosModules.home-manager - ]; - - home-manager = { - extraSpecialArgs = { inherit inputs outputs; }; - users = { - lander = import ../../home-manager/home.nix; - }; - }; -}