Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ tags
result
result-*
ref
*.iso

.direnv/
.env
Expand Down
52 changes: 51 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,57 @@ nix-setup-offline: ## Set up offline environment.

##@ Named Hosts Specific Targets

.PHONY: build-vm
build-vm: ## Build a named host VM launcher (set HOST=<name>, e.g. make build-vm HOST=viper).
@host="$(HOST)"; \
if [ -z "$$host" ]; then \
host="$(DETECTED_HOST)"; \

@cubic-dev-ai cubic-dev-ai Bot Apr 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Restrict the auto-detected fallback to hosts that actually have a NixOS VM output. As written, HOST omitted on galactica resolves to a missing nixosConfigurations.galactica attribute and the target fails.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Makefile, line 645:

<comment>Restrict the auto-detected fallback to hosts that actually have a NixOS VM output. As written, `HOST` omitted on `galactica` resolves to a missing `nixosConfigurations.galactica` attribute and the target fails.</comment>

<file context>
@@ -638,6 +638,57 @@ nix-setup-offline: ## Set up offline environment.
+build-vm: ## Build a named host VM launcher (set HOST=<name>, e.g. make build-vm HOST=viper).
+	@host="$(HOST)"; \
+	if [ -z "$$host" ]; then \
+		host="$(DETECTED_HOST)"; \
+	fi; \
+	if [ -z "$$host" ]; then \
</file context>
Fix with Cubic

fi; \
if [ -z "$$host" ]; then \
echo "❌ No HOST specified and no named host auto-detected"; \
exit 1; \
fi; \
echo "🏗️ Building VM for $$host"; \
$(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.$$host.config.system.build.vm $(NIX_FLAGS) --impure --show-trace

.PHONY: run-vm
run-vm: ## Run a named host VM launcher (set HOST=<name>, e.g. make run-vm HOST=viper).
@host="$(HOST)"; \
if [ -z "$$host" ]; then \
host="$(DETECTED_HOST)"; \
fi; \
if [ -z "$$host" ]; then \
echo "❌ No HOST specified and no named host auto-detected"; \
exit 1; \
fi; \
$(MAKE) build-vm HOST="$$host"; \
script=$$(find ./result/bin -maxdepth 1 -type f \( -name 'run-*-vm' -o -name 'run-nixos-vm' \) | head -n 1); \
Comment on lines +664 to +665

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of ; between the build command and the script lookup allows the recipe to continue even if the build fails. This can lead to executing a stale VM launcher from a previous build or a different host if ./result still exists. Use && to ensure the build succeeded before proceeding.

	$(MAKE) build-vm HOST="$$host" && \
	script=$$(find ./result/bin -maxdepth 1 -type f \( -name 'run-*-vm' -o -name 'run-nixos-vm' \) | head -n 1); \

if [ -z "$$script" ]; then \
echo "❌ Could not find a VM launcher under ./result/bin"; \
exit 1; \
fi; \
"$$script"

.PHONY: build-iso
build-iso: ## Build a named host live/install ISO and copy it to ./<host>.iso (set HOST=<name>, e.g. make build-iso HOST=viper).
@host="$(HOST)"; \
if [ -z "$$host" ]; then \
host="$(DETECTED_HOST)"; \
fi; \
if [ -z "$$host" ]; then \
echo "❌ No HOST specified and no named host auto-detected"; \
exit 1; \
fi; \
echo "💿 Building ISO for $$host"; \
$(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.$$host"Iso".config.system.build.isoImage $(NIX_FLAGS) --impure --show-trace; \
iso_path=$$(find ./result -type f -name '*.iso' | head -n 1); \
Comment on lines +683 to +684

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using ; here allows the find and cp commands to run even if the nix build command fails. This could result in copying an ISO from a previous build (potentially for a different host) to the current host's destination. Use && to chain these commands.

	$(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.$$host"Iso".config.system.build.isoImage $(NIX_FLAGS) --impure --show-trace && \
	iso_path=$$(find ./result -type f -name '*.iso' | head -n 1); \

if [ -z "$$iso_path" ]; then \
echo "❌ Could not find a built ISO under ./result"; \
exit 1; \
fi; \
cp -f "$$iso_path" "./$$host.iso"; \
echo "✅ Copied $$iso_path to ./$$host.iso"

.PHONY: switch-%
switch-%: ## Switch to a named host configuration (e.g., make switch-galactica).
@$(MAKE) nix-switch HOST=$*
Expand Down Expand Up @@ -1151,4 +1202,3 @@ gt-status: ## Show Gas Town health and Dolt server status.
.PHONY: gt-dolt-status
gt-dolt-status: ## Show Dolt server status and latency.
@gt dolt status

12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@
inherit inputs;
username = "skakinoki";
};
maticIso = import ./named-hosts/matic/iso.nix {
inherit inputs;
username = "skakinoki";
};
viper = import ./named-hosts/viper {
inherit inputs;
username = "shunkakinoki";
};
viperIso = import ./named-hosts/viper/iso.nix {
inherit inputs;
username = "shunkakinoki";
};
Comment on lines +137 to +148

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Username inconsistency between flake.nix and tests/eval.nix.

The maticIso configuration uses username = "skakinoki" here, but tests/eval.nix evaluates the same module with username = "shunkakinoki" (line 81). While the evaluation check will still pass, this means the test doesn't exercise the exact configuration that will be deployed.

Also note the username difference between hosts:

  • matic/maticIso: "skakinoki"
  • viper/viperIso: "shunkakinoki"

If this is intentional (different hosts for different users), no action needed. If "skakinoki" is a typo for "shunkakinoki", consider aligning them.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` around lines 137 - 148, The usernames are inconsistent: flake.nix
sets matic and maticIso to username = "skakinoki" while viper and viperIso use
"shunkakinoki", and tests/eval.nix evaluates the module with "shunkakinoki";
decide which is correct and make them consistent — either change matic and
maticIso in flake.nix (symbols: matic, maticIso) to username = "shunkakinoki" to
match tests and viper, or update tests/eval.nix to use "skakinoki" if the split
is intentional; ensure the same username value is used wherever the same
host/module is evaluated so the test exercises the deployed configuration.

};
homeConfigurations = {
"ubuntu@x86_64-linux" = import ./hosts/linux {
Expand Down
8 changes: 4 additions & 4 deletions home-manager/modules/local-scripts/clipboard-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

set -euo pipefail

if command -v pbcopy >/dev/null 2>&1; then
exec pbcopy
fi

if [[ -n ${WAYLAND_DISPLAY:-} ]] && command -v wl-copy >/dev/null 2>&1; then
exec wl-copy
fi

if command -v pbcopy >/dev/null 2>&1; then
exec pbcopy
fi

if command -v xclip >/dev/null 2>&1; then
exec xclip -selection clipboard
fi
Expand Down
7 changes: 4 additions & 3 deletions home-manager/modules/local-scripts/pushover-notify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ priority="${3:-0}"

[[ -z $message ]] && exit 0

# Source credentials if not already set
if [[ -z ${PUSHOVER_API_TOKEN:-} ]] || [[ -z ${PUSHOVER_USER_KEY:-} ]]; then
# Source credentials only when the vars are unset. Explicitly blank values
# should disable notifications instead of falling back to ~/.env.
if [[ -z ${PUSHOVER_API_TOKEN+x} ]] || [[ -z ${PUSHOVER_USER_KEY+x} ]]; then

@cubic-dev-ai cubic-dev-ai Bot Apr 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This fallback still loads ~/.env when one credential is intentionally blank and the other is unset, so an explicit disable can be overridden. Only source fallback credentials when both variables are truly unset.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/modules/local-scripts/pushover-notify.sh, line 17:

<comment>This fallback still loads `~/.env` when one credential is intentionally blank and the other is unset, so an explicit disable can be overridden. Only source fallback credentials when both variables are truly unset.</comment>

<file context>
@@ -12,8 +12,9 @@ priority="${3:-0}"
-if [[ -z ${PUSHOVER_API_TOKEN:-} ]] || [[ -z ${PUSHOVER_USER_KEY:-} ]]; then
+# Source credentials only when the vars are unset. Explicitly blank values
+# should disable notifications instead of falling back to ~/.env.
+if [[ -z ${PUSHOVER_API_TOKEN+x} ]] || [[ -z ${PUSHOVER_USER_KEY+x} ]]; then
   if [[ -f "$HOME/dotfiles/.env" ]]; then
     set -a
</file context>
Suggested change
if [[ -z ${PUSHOVER_API_TOKEN+x} ]] || [[ -z ${PUSHOVER_USER_KEY+x} ]]; then
if [[ -z ${PUSHOVER_API_TOKEN+x} ]] && [[ -z ${PUSHOVER_USER_KEY+x} ]]; then
Fix with Cubic

if [[ -f "$HOME/dotfiles/.env" ]]; then
set -a
# shellcheck source=/dev/null
Expand All @@ -35,4 +36,4 @@ curl -s \
--form-string "message=${message}" \
--form-string "priority=${priority}" \
--form-string "title=${title}" \
https://api.pushover.net/1/messages.json >/dev/null 2>&1
https://api.pushover.net/1/messages.json >/dev/null 2>&1 || exit 0
51 changes: 13 additions & 38 deletions named-hosts/matic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ inputs.nixpkgs.lib.nixosSystem {
(
{ config, lib, ... }:
{
imports = [
(import ../shared/linux-base.nix {
inherit inputs pkgs username;
hostname = "matic";
userExtraGroups = [
"input"
"video"
"audio"
"docker"
];
})
];

# Boot loader (EFI/systemd-boot)
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 10;
Expand Down Expand Up @@ -70,34 +83,11 @@ inputs.nixpkgs.lib.nixosSystem {
];

# Networking
networking.hostName = "matic";
networking.networkmanager.enable = true;
networking.networkmanager.wifi.powersave = true;

# Enable fish shell
programs.fish.enable = true;

# User configuration
users.users.${username} = {
isNormalUser = true;
extraGroups = [
"wheel"
"networkmanager"
"input"
"video"
"audio"
"docker"
];
home = "/home/${username}";
shell = pkgs.fish;
initialPassword = "changemeow"; # Change this after first login with: passwd
};

# Docker
virtualisation.docker.enable = true;

security.sudo.wheelNeedsPassword = false;

# Home Manager activation can take a long time (npm globals, cargo installs, etc.)
systemd.services."home-manager-${username}".serviceConfig.TimeoutStartSec = lib.mkForce "30m";

Expand Down Expand Up @@ -344,21 +334,6 @@ inputs.nixpkgs.lib.nixosSystem {
zlib
];

# NixOS-level nix settings (complements home-manager nix/)
nix = {
channel.enable = false;
settings = {
nix-path = lib.mkForce "nixpkgs=/etc/nix/inputs/nixpkgs";
trusted-users = [
username
"@wheel"
"root"
];
};
};
environment.etc."nix/inputs/nixpkgs".source = "${inputs.nixpkgs}";

system.stateVersion = "24.11";
}
)

Expand Down
29 changes: 29 additions & 0 deletions named-hosts/matic/iso.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
inputs,
username,
...
}:
let
system = "x86_64-linux";
nixpkgsConfig = import ../../lib/nixpkgs-config.nix {
nixpkgsLib = inputs.nixpkgs.lib;
};
overlays = import ../../overlays { inherit inputs; };
pkgs = import inputs.nixpkgs {
inherit system overlays;
config = nixpkgsConfig;
};
in
inputs.nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs username;
};
modules = [
(import ../shared/live-iso.nix {
inherit inputs pkgs username;
hostname = "matic";
userInitialPassword = "changemeow";
})
];
}
46 changes: 46 additions & 0 deletions named-hosts/shared/linux-base.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
inputs,
pkgs,
username,
hostname,
userExtraGroups ? [ ],
userInitialPassword ? "changemeow",

@cubic-dev-ai cubic-dev-ai Bot Apr 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: Do not ship this base module with a known default password; it creates a trivial path to root on fresh installs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At named-hosts/shared/linux-base.nix, line 7:

<comment>Do not ship this base module with a known default password; it creates a trivial path to root on fresh installs.</comment>

<file context>
@@ -0,0 +1,46 @@
+  username,
+  hostname,
+  userExtraGroups ? [ ],
+  userInitialPassword ? "changemeow",
+  stateVersion ? "24.11",
+}:
</file context>
Fix with Cubic

stateVersion ? "24.11",
}:
{ lib, ... }:
{
networking.hostName = hostname;
networking.networkmanager.enable = true;

programs.fish.enable = true;

users.users.${username} = {
isNormalUser = true;
extraGroups = [
"wheel"
"networkmanager"
]
++ userExtraGroups;
home = "/home/${username}";
shell = pkgs.fish;
initialPassword = userInitialPassword;
};

security.sudo.wheelNeedsPassword = false;

nix = {
channel.enable = false;
settings = {
nix-path = lib.mkForce "nixpkgs=/etc/nix/inputs/nixpkgs";
trusted-users = [
username
"@wheel"
"root"
];
};
};

environment.etc."nix/inputs/nixpkgs".source = "${inputs.nixpkgs}";

system.stateVersion = stateVersion;
}
33 changes: 33 additions & 0 deletions named-hosts/shared/live-iso.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
inputs,
pkgs,
username,
hostname,
userInitialPassword,
isoName ? "${hostname}.iso",
}:
{ lib, ... }:
{
imports = [
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
(import ./linux-base.nix {
inherit
inputs
pkgs
username
hostname
userInitialPassword
;
})
];

environment.systemPackages = with pkgs; [
curl
git
vim
];

image.fileName = isoName;
services.getty.helpLine = lib.mkForce "";
}
65 changes: 65 additions & 0 deletions named-hosts/viper/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
inputs,
username,
...
}:
let
system = "x86_64-linux";
nixpkgsConfig = import ../../lib/nixpkgs-config.nix {
nixpkgsLib = inputs.nixpkgs.lib;
};
overlays = import ../../overlays { inherit inputs; };
pkgs = import inputs.nixpkgs {
inherit system overlays;
config = nixpkgsConfig;
};
in
inputs.nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs username;
};
modules = [
(import ../shared/linux-base.nix {
inherit inputs pkgs username;
hostname = "viper";
userInitialPassword = "test";

@cubic-dev-ai cubic-dev-ai Bot Apr 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Do not ship this host with a hard-coded known password; it creates a trivially guessable admin login.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At named-hosts/viper/default.nix, line 26:

<comment>Do not ship this host with a hard-coded known password; it creates a trivially guessable admin login.</comment>

<file context>
@@ -0,0 +1,65 @@
+    (import ../shared/linux-base.nix {
+      inherit inputs pkgs username;
+      hostname = "viper";
+      userInitialPassword = "test";
+    })
+    (
</file context>
Fix with Cubic

})
(
{
lib,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];

boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/vda";
boot.loader.timeout = 3;

fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};

environment.systemPackages = with pkgs; [
curl
git
vim
];

services.openssh.enable = true;

virtualisation.vmVariant = {
virtualisation = {
graphics = false;
memorySize = 4096;
cores = 4;
};
users.users.${username}.initialPassword = lib.mkForce "test";
};
}
)
];
}
Loading
Loading