From f28ec054cdc9222b4093afa29d56c1856b3698f8 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Thu, 9 May 2024 10:49:44 -0400 Subject: [PATCH] added nix-less home-manager config --- flake.nix | 12 +++- src/system/machines/nix-less/default.nix | 8 +++ src/system/machines/nix-less/home.nix | 38 +++++++++++ src/system/machines/nix-less/system.nix | 84 ++++++++++++++++++++++++ src/system/machines/nix-less/wsl.nix | 21 ++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/system/machines/nix-less/default.nix create mode 100644 src/system/machines/nix-less/home.nix create mode 100644 src/system/machines/nix-less/system.nix create mode 100644 src/system/machines/nix-less/wsl.nix diff --git a/flake.nix b/flake.nix index 44ab66e..b2d76f1 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; - home-manager= { + home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -22,6 +22,7 @@ allowUnfree = true; }; }; + config = import ./user.config.nix; in { @@ -55,5 +56,14 @@ ]; }; }; + + homeConfigurations = { + ${config.user.name} = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./src/system/machines/nix-less + ]; + }; + }; }; } diff --git a/src/system/machines/nix-less/default.nix b/src/system/machines/nix-less/default.nix new file mode 100644 index 0000000..4f15952 --- /dev/null +++ b/src/system/machines/nix-less/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ../../../user/configs + ./system.nix + ]; +} diff --git a/src/system/machines/nix-less/home.nix b/src/system/machines/nix-less/home.nix new file mode 100644 index 0000000..80f34b1 --- /dev/null +++ b/src/system/machines/nix-less/home.nix @@ -0,0 +1,38 @@ +{ config, ... }: + +{ + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${config.user.name} = { + imports = [ + ../../../user + ]; + + programs.home-manager.enable = true; + programs.bash.shellAliases = { + nixup = "sudo nixos-rebuild switch --flake /etc/nixos/.#windows"; + }; + + home.stateVersion = "23.11"; + + home.username = "${config.user.name}"; + home.homeDirectory = "/home/${config.user.name}"; + + modules = { + user = { + bash.enable = true; + git.enable = true; + gpg.enable = true; + gui.enable = false; + security.enable = true; + utils = { + enable = true; + dev.enable = true; + email.enable = true; + irc.enable = true; + vim.enable = true; + }; + }; + }; + }; +} diff --git a/src/system/machines/nix-less/system.nix b/src/system/machines/nix-less/system.nix new file mode 100644 index 0000000..332885e --- /dev/null +++ b/src/system/machines/nix-less/system.nix @@ -0,0 +1,84 @@ +{ pkgs, lib, config, ... }: + +{ system.stateVersion = "23.11"; + +# Users + users.users = { + ${config.user.name} = { + isNormalUser = true; + extraGroups = config.user.groups; + openssh.authorizedKeys.keys = config.user.sshKeys; + }; + }; + boot.isContainer = true; + +# Nix + nix = { + channel.enable = false; + package = pkgs.nixFlakes; + extraOptions = "experimental-features = nix-command flakes"; + settings = { + auto-optimise-store = true; + trusted-users = [ "${config.user.name}" ]; + }; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + }; + +# Sudo Options + security.sudo = { + wheelNeedsPassword = false; + execWheelOnly = true; + }; + +# System Services + services = { + cron = { + enable = true; + systemCronJobs = []; + }; + }; + +# Locale + time = { + timeZone = "America/New_York"; + }; + + services.timesyncd = { + enable = true; + servers = [ + "0.pool.ntp.org" + "1.pool.ntp.org" + "2.pool.ntp.org" + "3.pool.ntp.org" + ]; + }; + + i18n.defaultLocale = "en_US.UTF-8"; + + console = { + font = "Lat2-Terminus16"; + useXkbConfig = true; + }; + +# Networking + networking = { + useDHCP = lib.mkDefault true; + firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 ]; + }; + }; + + services.openssh = { + enable = true; + startWhenNeeded = true; + settings = { + X11Forwarding = false; + PasswordAuthentication = false; + }; + }; +} diff --git a/src/system/machines/nix-less/wsl.nix b/src/system/machines/nix-less/wsl.nix new file mode 100644 index 0000000..bcde209 --- /dev/null +++ b/src/system/machines/nix-less/wsl.nix @@ -0,0 +1,21 @@ +{ pkgs, config, ... }: + +{ + imports = [ + ../../../user + ]; + + wsl = { + enable = true; + defaultUser = pkgs.lib.mkDefault "${config.user.name}"; + nativeSystemd = true; + + wslConf = { + boot.command = "cd"; + network = { + hostname = "plato"; + generateHosts = true; + }; + }; + }; +}