add generators and clean up directories

This commit is contained in:
Noah Masur 2025-03-14 00:13:56 +00:00
parent bdf163a50a
commit a3ad019f4b
11 changed files with 145 additions and 115 deletions

View File

@ -300,63 +300,48 @@
root = import ./hosts/x86_64-linux/swan/root.nix; root = import ./hosts/x86_64-linux/swan/root.nix;
}; };
# packages = # generators = {
# let # arrow.aws.x86_64-linux = lib.generateImage {
# staff =
# system:
# import ./hosts/staff {
# inherit
# inputs
# globals
# overlays
# system
# ;
# };
# neovim =
# system:
# let
# pkgs = import nixpkgs { inherit system overlays; };
# in
# import ./modules/common/neovim/package {
# inherit pkgs;
# colors = (import ./colorscheme/gruvbox-dark).dark;
# };
# in
# {
# x86_64-linux.staff = staff "x86_64-linux";
# x86_64-linux.arrow = inputs.nixos-generators.nixosGenerate rec {
# system = "x86_64-linux";
# format = "iso";
# modules = import ./hosts/arrow/modules.nix { inherit inputs globals overlays; };
# };
# x86_64-linux.arrow-aws = inputs.nixos-generators.nixosGenerate rec {
# system = "x86_64-linux"; # system = "x86_64-linux";
# format = "amazon"; # format = "amazon";
# modules = import ./hosts/arrow/modules.nix { inherit inputs globals overlays; } ++ [ # specialArgs = { inherit (globals) hostnames; };
# ( # };
# { ... }: # arrow.iso.x86_64-linux = lib.generateImage {
# { # system = "x86_64-linux";
# boot.kernelPackages = inputs.nixpkgs.legacyPackages.x86_64-linux.linuxKernel.packages.linux_6_6; # format = "iso";
# amazonImage.sizeMB = 16 * 1024; # specialArgs = { inherit (globals) hostnames; };
# permitRootLogin = "prohibit-password"; # };
# boot.loader.systemd-boot.enable = inputs.nixpkgs.lib.mkForce false;
# boot.loader.efi.canTouchEfiVariables = inputs.nixpkgs.lib.mkForce false;
# services.amazon-ssm-agent.enable = true;
# users.users.ssm-user.extraGroups = [ "wheel" ];
# }
# )
# ];
# }; # };
# # Package Neovim config into standalone package generators = builtins.mapAttrs (
# x86_64-linux.neovim = neovim "x86_64-linux"; system: hosts:
# x86_64-darwin.neovim = neovim "x86_64-darwin"; builtins.mapAttrs (name: module: {
# aarch64-linux.neovim = neovim "aarch64-linux"; aws = lib.generateImage {
# aarch64-darwin.neovim = neovim "aarch64-darwin"; inherit system module;
# }; format = "amazon";
specialArgs = { inherit (globals) hostnames; };
};
iso = lib.generateImage {
inherit system module;
format = "iso";
specialArgs = { inherit (globals) hostnames; };
};
}) hosts
) lib.linuxHosts;
packages = lib.forAllSystems (
system:
# Get the configurations that we normally use
{
nixosConfigurations = nixosConfigurations.${system};
darwinConfigurations = darwinConfigurations.${system};
homeConfigurations = homeConfigurations.${system};
generators = generators.${system};
}
//
# Get the custom packages that I have placed under the nmasur namespace # Get the custom packages that I have placed under the nmasur namespace
packages = lib.forAllSystems (system: lib.pkgsBySystem.${system}.nmasur); lib.pkgsBySystem.${system}.nmasur
);
# Development environments # Development environments
devShells = lib.forAllSystems (system: { devShells = lib.forAllSystems (system: {

View File

@ -102,6 +102,18 @@ lib
colorscheme = defaultFilesToAttrset ../colorscheme; colorscheme = defaultFilesToAttrset ../colorscheme;
homeModule = {
home-manager = {
# Include home-manager config in NixOS
sharedModules = nixFiles ../platforms/home-manager;
# Use the system-level nixpkgs instead of Home Manager's
useGlobalPkgs = lib.mkDefault true;
# Install packages to /etc/profiles instead of ~/.nix-profile, useful when
# using multiple profiles for one user
useUserPackages = lib.mkDefault true;
};
};
buildHome = buildHome =
{ {
system, system,
@ -111,7 +123,7 @@ lib
inputs.home-manager.lib.homeManagerConfiguration { inputs.home-manager.lib.homeManagerConfiguration {
pkgs = pkgsBySystem.${system}; pkgs = pkgsBySystem.${system};
modules = [ modules = [
../platforms/home-manager { imports = (nixFiles ../platforms/home-manager); }
module module
]; ];
extraSpecialArgs = { extraSpecialArgs = {
@ -131,7 +143,7 @@ lib
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko inputs.disko.nixosModules.disko
inputs.wsl.nixosModules.wsl inputs.wsl.nixosModules.wsl
../platforms/nixos { imports = (nixFiles ../platforms/nixos); }
module module
{ {
home-manager.extraSpecialArgs = { home-manager.extraSpecialArgs = {
@ -150,9 +162,46 @@ lib
modules = [ modules = [
inputs.home-manager.darwinModules.home-manager inputs.home-manager.darwinModules.home-manager
inputs.mac-app-util.darwinModules.default inputs.mac-app-util.darwinModules.default
./platforms/nix-darwin { imports = (nixFiles ../platforms/nix-darwin); }
module module
]; ];
}; };
generatorOptions = {
amazon = {
aws.enable = true;
};
iso = { };
};
generateImage =
{
system,
module,
format,
specialArgs,
}:
inputs.nixos-generators.nixosGenerate {
inherit system format;
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko
inputs.wsl.nixosModules.wsl
{
imports = (nixFiles ../platforms/nixos) ++ (nixFiles ../platforms/generators);
}
generatorOptions.${format}
module
{
home-manager = {
extraSpecialArgs = {
inherit colorscheme;
} // specialArgs;
} // homeModule.home-manager;
}
];
specialArgs = {
} // specialArgs;
};
} }

View File

@ -11,6 +11,25 @@
options.colors = lib.mkOption { options.colors = lib.mkOption {
type = lib.types.attrsOf lib.types.str; type = lib.types.attrsOf lib.types.str;
description = "Attrset of base16 colorscheme key value pairs."; description = "Attrset of base16 colorscheme key value pairs.";
default = {
# Nord
base00 = "#2E3440";
base01 = "#3B4252";
base02 = "#434C5E";
base03 = "#4C566A";
base04 = "#D8DEE9";
base05 = "#E5E9F0";
base06 = "#ECEFF4";
base07 = "#8FBCBB";
base08 = "#88C0D0";
base09 = "#81A1C1";
base0A = "#5E81AC";
base0B = "#BF616A";
base0C = "#D08770";
base0D = "#EBCB8B";
base0E = "#A3BE8C";
base0F = "#B48EAD";
};
}; };
config = { config = {

View File

@ -28,7 +28,7 @@
{ {
pkgs, pkgs,
colors ? (import ../../../../../../colorscheme/nord).dark, colors ? null,
terraform ? false, terraform ? false,
github ? false, github ? false,
kubernetes ? false, kubernetes ? false,

View File

@ -14,17 +14,16 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# AWS settings require this nmasur.presets.services.openssh-aws.enable = lib.mkDefault true;
permitRootLogin = "prohibit-password";
# Make sure disk size is large enough # Make sure disk size is large enough
# https://github.com/nix-community/nixos-generators/issues/150 # https://github.com/nix-community/nixos-generators/issues/150
amazonImage.sizeMB = 16 * 1024; virtualisation.diskSize = lib.mkDefault (16 * 1024); # In MB
boot.kernelPackages = pkgs.legacyPackages.x86_64-linux.linuxKernel.packages.linux_6_6; boot.kernelPackages = lib.mkDefault pkgs.linuxKernel.packages.linux_6_6;
boot.loader.systemd-boot.enable = lib.mkForce false; boot.loader.systemd-boot.enable = false;
boot.loader.efi.canTouchEfiVariables = lib.mkForce false; boot.loader.efi.canTouchEfiVariables = false;
services.amazon-ssm-agent.enable = true; services.amazon-ssm-agent.enable = lib.mkDefault true;
users.users.ssm-user.extraGroups = [ "wheel" ]; users.users.ssm-user.extraGroups = [ "wheel" ];
}; };

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -0,0 +1,27 @@
# SSHD settings for AWS machines
{
config,
lib,
...
}:
let
cfg = config.nmasur.presets.services.openssh-aws;
in
{
options.nmasur.presets.services.openssh-aws = {
enable = lib.mkEnableOption "OpenSSH on AWS VMs";
};
config = lib.mkIf cfg.enable {
services.openssh = {
settings = {
# AWS settings require this
PermitRootLogin = lib.mkForce "prohibit-password";
};
};
};
}

View File

@ -52,19 +52,6 @@ in
pkgs.curl pkgs.curl
]; ];
# Include home-manager config in NixOS
home-manager = {
sharedModules = [ ../../../../home-manager ];
# Use the system-level nixpkgs instead of Home Manager's
useGlobalPkgs = lib.mkDefault true;
# Install packages to /etc/profiles instead of ~/.nix-profile, useful when
# using multiple profiles for one user
useUserPackages = lib.mkDefault true;
};
# Extending time for home-manager build for things like nix-index cache # Extending time for home-manager build for things like nix-index cache
systemd.services."home-manager-${username}" = { systemd.services."home-manager-${username}" = {
serviceConfig.TimeoutStartSec = lib.mkForce "45m"; serviceConfig.TimeoutStartSec = lib.mkForce "45m";