diff --git a/hosts/common/default.nix b/hosts/common/default.nix index b0c234b..e950102 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -1,8 +1,6 @@ { - pkgs, username, outputs, - config, inputs, email, ... @@ -11,6 +9,7 @@ inputs.impermanence.nixosModules.impermanence inputs.home-manager.nixosModules.home-manager + ../../modules/base ../../modules/nixos/fail2ban.nix ../../modules/nixos/sops.nix ../../modules/nixos/upstream-proxy.nix @@ -24,51 +23,6 @@ neededForUsers = true; }; - nixpkgs = { - overlays = [ - outputs.overlays.additions - outputs.overlays.modifications - outputs.overlays.stable-packages - outputs.overlays.nur - outputs.overlays.nix-vscode-extensions - ]; - - config = { - allowUnfree = true; - joypixels.acceptLicense = true; - }; - }; - - nix = { - package = pkgs.lix; - settings = { - experimental-features = "nix-command flakes"; - auto-optimise-store = true; - trusted-users = ["${username}"]; - warn-dirty = false; - substituters = [ - "https://cache.nixos.org?priority=10" - "https://anyrun.cachix.org" - "https://fufexan.cachix.org" - "https://helix.cachix.org" - "https://hyprland.cachix.org" - "https://nix-community.cachix.org" - "https://nix-gaming.cachix.org" - "https://yazi.cachix.org" - ]; - trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" - "fufexan.cachix.org-1:LwCDjCJNJQf5XD2BV+yamQIMZfcKWR9ISIFy5curUsY=" - "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" - "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" - "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k=" - ]; - }; - }; - time.timeZone = "Asia/Kolkata"; i18n = { defaultLocale = "en_US.UTF-8"; @@ -89,25 +43,6 @@ programs = { zsh.enable = true; - nh = { - enable = true; - clean.enable = true; - clean.extraArgs = "--keep-since 5d --keep 5"; - flake = "/home/${username}/Projects/nixos-config"; - }; - }; - - users = { - mutableUsers = false; - defaultUserShell = pkgs.zsh; - users.${username} = { - hashedPasswordFile = config.sops.secrets.tux-password.path; - isNormalUser = true; - extraGroups = ["networkmanager" "wheel" "storage"]; - openssh.authorizedKeys.keys = [ - ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D ${email}'' - ]; - }; }; home-manager = { diff --git a/modules/base/default.nix b/modules/base/default.nix new file mode 100644 index 0000000..a214a65 --- /dev/null +++ b/modules/base/default.nix @@ -0,0 +1,10 @@ +{ + imports = [ + ./nix.nix + ./nixpkgs.nix + ./nh.nix + ./overlays.nix + ./substituters.nix + ./user.nix + ]; +} diff --git a/modules/base/nh.nix b/modules/base/nh.nix new file mode 100644 index 0000000..1f099a0 --- /dev/null +++ b/modules/base/nh.nix @@ -0,0 +1,16 @@ +{ + config, + username, + ... +}: { + programs.nh = { + enable = true; + + clean = { + enable = !config.nix.gc.automatic; + dates = "weekly"; + }; + + flake = "/home/${username}/Projects/nixos-config"; + }; +} diff --git a/modules/base/nix.nix b/modules/base/nix.nix new file mode 100644 index 0000000..112b42c --- /dev/null +++ b/modules/base/nix.nix @@ -0,0 +1,15 @@ +{ + pkgs, + username, + ... +}: { + nix = { + package = pkgs.lix; + settings = { + experimental-features = "nix-command flakes"; + auto-optimise-store = true; + trusted-users = ["${username}"]; + warn-dirty = false; + }; + }; +} diff --git a/modules/base/nixpkgs.nix b/modules/base/nixpkgs.nix new file mode 100644 index 0000000..9915423 --- /dev/null +++ b/modules/base/nixpkgs.nix @@ -0,0 +1,8 @@ +{ + nixpkgs = { + config = { + allowUnfree = true; + joypixels.acceptLicense = true; + }; + }; +} diff --git a/modules/base/overlays.nix b/modules/base/overlays.nix new file mode 100644 index 0000000..7ff88b8 --- /dev/null +++ b/modules/base/overlays.nix @@ -0,0 +1,9 @@ +{outputs, ...}: { + nixpkgs.overlays = [ + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.stable-packages + outputs.overlays.nur + outputs.overlays.nix-vscode-extensions + ]; +} diff --git a/modules/base/substituters.nix b/modules/base/substituters.nix new file mode 100644 index 0000000..c8653b1 --- /dev/null +++ b/modules/base/substituters.nix @@ -0,0 +1,24 @@ +{ + nix.settings = { + substituters = [ + "https://cache.nixos.org?priority=10" + "https://anyrun.cachix.org" + "https://fufexan.cachix.org" + "https://helix.cachix.org" + "https://hyprland.cachix.org" + "https://nix-community.cachix.org" + "https://nix-gaming.cachix.org" + "https://yazi.cachix.org" + ]; + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" + "fufexan.cachix.org-1:LwCDjCJNJQf5XD2BV+yamQIMZfcKWR9ISIFy5curUsY=" + "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" + "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k=" + ]; + }; +} diff --git a/modules/base/user.nix b/modules/base/user.nix new file mode 100644 index 0000000..c63052e --- /dev/null +++ b/modules/base/user.nix @@ -0,0 +1,20 @@ +{ + config, + pkgs, + username, + email, + ... +}: { + users = { + mutableUsers = false; + defaultUserShell = pkgs.zsh; + users.${username} = { + hashedPasswordFile = config.sops.secrets.tux-password.path; + isNormalUser = true; + extraGroups = ["networkmanager" "wheel" "storage"]; + openssh.authorizedKeys.keys = [ + ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D ${email}'' + ]; + }; + }; +}