Skip to content

Commit

Permalink
feat: extend and use fonts update base images for linode and new DO s…
Browse files Browse the repository at this point in the history
…erver definition
  • Loading branch information
tcarrio committed Nov 21, 2024
1 parent b611cbd commit a05667e
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 69 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.direnv*
/result
*.img
*.img
*.iso
*.*.gz
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
)) // {
x86_64-linux = {
# TODO: image is still too large: reduction with `qemu-img resize --shrink ./nixos.img 5.5G` didn't error out but image will not boot
# linode-base-image = libx.mkGeneratorImage { systemType = "server"; hostname = "generic-base-image"; username = "archon"; format = "linode"; diskSize = 5120; };
linode-base-image = libx.mkGeneratorImage { systemType = "server"; hostname = "linode-base-image"; username = "archon"; format = "linode"; diskSize = 5120; };

digital-ocean-base-image = libx.mkGeneratorImage { systemType = "server"; hostname = "generic-base-image"; username = "archon"; format = "do"; };
};
Expand Down
48 changes: 0 additions & 48 deletions nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ in
./mixins/services/firewall.nix
./mixins/services/fwupd.nix
./mixins/services/kmscon.nix
./mixins/services/networkmanager.nix
./mixins/services/openssh.nix
./mixins/services/smartmon.nix
./mixins/users/root
Expand Down Expand Up @@ -90,46 +89,6 @@ in
};
};

fonts = {
fontDir.enable = true;
packages = with pkgs; [
# (nerdfonts.override { fonts = [ "FiraCode" "SourceCodePro" "UbuntuMono" ]; })
# fira
# fira-go
# ipafont # Japanese characters
# kochi-substitute # Japanese characters
# joypixels # Emojis
# liberation_ttf
# noto-fonts-emoji # Emojis
# source-serif
# ubuntu_font_family
# work-sans
];

# Enable a basic set of fonts providing several font styles and families and reasonable coverage of Unicode.
enableDefaultPackages = false;

# fontconfig = {
# antialias = true;
# defaultFonts = {
# serif = [ "Source Serif" "IPAPMincho" ];
# sansSerif = [ "Work Sans" "Fira Sans" "FiraGO" "IPAGothic" ];
# monospace = [ "FiraCode Nerd Font Mono" "SauceCodePro Nerd Font Mono" "IPAGothic" ];
# emoji = [ "Joypixels" "Noto Color Emoji" ];
# };
# enable = true;
# hinting = {
# autohint = false;
# enable = true;
# style = "slight";
# };
# subpixel = {
# rgba = "rgb";
# lcdfilter = "light";
# };
# };
};

# Use passed hostname to configure basic networking
networking = {
inherit hostName domain;
Expand All @@ -156,13 +115,6 @@ in
# });
# })
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
# Accept the joypixels license
joypixels.acceptLicense = true;
};
};

nix = {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions nixos/mixins/services/cups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
imports = [
./avahi.nix
];

services = {
printing.enable = true;
#printing.drivers = with pkgs; [ gutenprint hplipWithPlugin ];
Expand Down
12 changes: 0 additions & 12 deletions nixos/mixins/services/networkmanager.nix

This file was deleted.

1 change: 1 addition & 0 deletions nixos/modules/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ _: {
./ente.nix
./evolution.nix
./firefox.nix
./fonts.nix
./fractal.nix
./google-chrome.nix
./logseq.nix
Expand Down
78 changes: 78 additions & 0 deletions nixos/modules/desktop/fonts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{ lib, config, pkgs, ... }:
let
cfg = config.oxc.desktop.fonts;

enabled = cfg.enable || cfg.ultraMode;
in
{
options.oxc.desktop.fonts = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the minimal suite of font configurations";
};
ultraMode = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the ultra, over the top suite of font configurations";
};
emoji = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable emoji font sets";
};
japanese = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable Japanese font sets";
};
};

config = lib.mkIf cfg.ultraMode {
fonts = {
fontDir.enable = true;
packages = with pkgs; lib.optional cfg.ultraMode [
(nerdfonts.override { fonts = [ "FiraCode" "SourceCodePro" "UbuntuMono" ]; })
fira
fira-go
liberation_ttf
source-serif
ubuntu_font_family
work-sans
] // lib.optional (cfg.ultraMode || cfg.japanese) [
ipafont
kochi-substitute
] // lib.optional (cfg.ultraMode || cfg.emoji) [
joypixels
noto-fonts-emoji
];

# Enable a basic set of fonts providing several font styles and families and reasonable coverage of Unicode.
enableDefaultPackages = cfg.ultraMode;

fontconfig = lib.mkIf cfg.ultraMode {
antialias = true;
defaultFonts = {
serif = [ "Source Serif" "IPAPMincho" ];
sansSerif = [ "Work Sans" "Fira Sans" "FiraGO" "IPAGothic" ];
monospace = [ "FiraCode Nerd Font Mono" "SauceCodePro Nerd Font Mono" "IPAGothic" ];
emoji = [ "Joypixels" "Noto Color Emoji" ];
};
enable = true;
hinting = {
autohint = false;
enable = true;
style = "slight";
};
subpixel = {
rgba = "rgb";
lcdfilter = "light";
};
};
};

nixpkgs.config = lib.mkIf (cfg.ultraMode || cfg.emoji) {
joypixels.acceptLicense = true;
};
};
}
1 change: 1 addition & 0 deletions nixos/modules/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _: {
imports = [
./acme.nix
./flatpak.nix
./networkmanager.nix
./nextdns.nix
./noisetorch.nix
./remote-builder.nix
Expand Down
10 changes: 7 additions & 3 deletions nixos/modules/services/flatpak.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ pkgs, lib, config, ... }: {
{ pkgs, lib, config, ... }:
let
cfg = config.oxc.services.flatpak;
in
{
options.oxc.services.flatpak = {
enable = lib.mkOption {
type = lib.types.bool;
Expand All @@ -15,11 +19,11 @@
};
};

config = lib.mkIf config.oxc.services.flatpak.enable {
config = lib.mkIf cfg.enable {
services.flatpak.enable = true;

# unit file idempotently adds flathub to flatpak repositories
systemd.services.configure-flathub-repo = lib.mkIf config.oxc.services.flatpak.flathub.enable {
systemd.services.configure-flathub-repo = lib.mkIf cfg.flathub.enable {
wantedBy = [ "multi-user.target" ];
path = [ pkgs.flatpak ];
script = ''
Expand Down
35 changes: 35 additions & 0 deletions nixos/modules/services/networkmanager.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ config, lib, ... }:
let
cfg = config.oxc.services.networkmanager;
in
{
options.oxc.services.networkmanager = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable NetworkManager";
};

wireless = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable support for wireless networking with NetworkManager";
};
};
};

config = lib.mkIf cfg.enable {
networking = {
networkmanager = {
enable = true;
wifi = lib.mkIf cfg.wireless.enable {
backend = "iwd";
};
};
wireless = lib.mkIf cfg.wireless.enable {
enable = false;
};
};
};
}
10 changes: 7 additions & 3 deletions nixos/modules/services/nextdns.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ pkgs, lib, config, ... }: {
{ pkgs, lib, config, ... }:
let
cfg = config.oxc.services.nextdns;
in
{
options.oxc.services.nextdns = {
enable = lib.mkOption {
type = lib.types.bool;
Expand All @@ -13,13 +17,13 @@
};
};

config = lib.mkIf config.oxc.services.nextdns.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
nextdns
];
services.nextdns = {
enable = true;
arguments = [ "-profile" config.oxc.services.nextdns.profile "-cache-size" "10MB" "-report-client-info" "-auto-activate" ];
arguments = [ "-profile" cfg.profile "-cache-size" "10MB" "-report-client-info" "-auto-activate" ];
};
};
}
2 changes: 1 addition & 1 deletion nixos/server/dotest.carrio.dev/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
in
{
imports = [
../../mixins/disks/do.nix
../../mixins/disks/digital-ocean.nix
];

security.acme = {
Expand Down
37 changes: 37 additions & 0 deletions nixos/server/drop0/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ pkgs, lib, ... }:
let
webRootHostDir = "/etc/web-server/";
fqdn = "dotest.carrio.dev";
in
{
imports = [
../../mixins/disks/digital-ocean.nix
];

security.acme = {
acceptTerms = true;
defaults.email = "[email protected]";
};
services.nginx = {
enable = true;
virtualHosts = {
"foo.carrio.dev" = {
forceSSL = true;
enableACME = true;
# All serverAliases will be added as extra domain names on the certificate.
serverAliases = [ "bar.carrio.dev" ];
locations."/" = {
root = "/etc/web-server";
};
};
};
};

# Configure hosted web content directory
environment.etc.web-server.source = ./webroot;

# Now we need to open port 80 for the ACME challenge and port 443 for TLS itself
networking.firewall.allowedTCPPorts = [ 80 443 ];

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}
4 changes: 4 additions & 0 deletions nixos/server/drop0/webroot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<html lang="en">
<head></head>
<body><h1>Test Web Server</h1></body>
</html>
6 changes: 6 additions & 0 deletions nixos/server/generic-base-image/default.nix
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# The base image does not define anything outside of the automatically inherited
# configurations from the nixos/default.nix module.
# After a system boots and you switch NixOS configurations, you must either
# 1. Copy the /etc/nixos/hardware-configuration.nix file
# 2. Include a disk definition for the platform
# For #2, see the mixins/disks/digital-ocean.nix for an example configuration
_: { }
5 changes: 5 additions & 0 deletions nixos/server/linode-base-image/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_: {
imports = [../generic-base-image];

oxc.services.networkmanager.enable = false;
}

0 comments on commit a05667e

Please sign in to comment.