Make deployment work again on cobalt

This commit is contained in:
Christopher Mühl 2025-08-07 10:19:25 +02:00
parent 53b8448159
commit 6e433cff6f
No known key found for this signature in database
GPG key ID: E919B0F59E14FD47
7 changed files with 71 additions and 58 deletions

View file

@ -1,6 +1,5 @@
set shell := ["bash", "-c"]
editor := env('EDITOR')
rebuild := if os() == "linux" { "nixos-rebuild" } else { "darwin-rebuild" }
default:
@just --list --justfile {{justfile()}}
@ -10,7 +9,12 @@ default:
# Runs `nixos-rebuild` or `darwin-rebuild` depending on the OS
[group('nix')]
deploy:
sudo {{rebuild}} switch --flake .
{{if os() == "linux" { \
"nixos-rebuild switch --flake . --sudo" \
} else { \
"sudo darwin-rebuild switch --flake ." \
} \
}}
europium:
nixos-rebuild switch --flake .#europium --target-host europium --build-host europium --use-remote-sudo

View file

@ -12,9 +12,7 @@
./misc/gaming.nix
./misc/onedrive.nix
./misc/everything.nix # TODO: Determine if we really always want all these programs or they should be composable
./global/terminal
./global/current-packages.nix
./editors/helix
./editors/jetbrains
]
++ (import ./config.nix all);

View file

@ -1,42 +0,0 @@
{pkgs, ...}: let
# The command to run in order to shut down the computer
command = "${pkgs.systemd}/bin/systemctl poweroff -i";
# Write this command into a shell script
bin = pkgs.writeShellScriptBin "shutdown" command;
in {
users.users.hass = {
isNormalUser = true;
home = "/home/hass";
description = "HomeAssistant automations";
extraGroups = [];
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICzLKowPwiQtAIgrY1wSvdolcDkbXokWrda//EEzQfR5 root@homeassistant"];
};
# Create a symlink to the shell script we created to the absolute path
# /etc/shutdown-script
environment.etc.shutdown-script.source = "${bin}/bin/shutdown";
security.sudo.extraRules = [
{
users = ["hass"];
commands = [
{
# Allow the 'hass' user to run the shutdown script
command = "/etc/shutdown-script";
options = ["NOPASSWD"];
}
];
}
];
# Allow the 'hass' user to log in, but not via password authentication.
# The authorized key is specified above.
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
AllowUsers = ["hass"];
};
};
}

View file

@ -1,9 +0,0 @@
{pkgs, ...}: {
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
AllowUsers = ["christopher"];
};
};
}

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./shutdown.nix
];
}

View file

@ -0,0 +1,58 @@
{
pkgs,
config,
lib,
...
}:
with lib; let
# The command to run in order to shut down the computer
command = "${pkgs.systemd}/bin/systemctl poweroff -i";
# Write this command into a shell script
bin = pkgs.writeShellScriptBin "shutdown" command;
cfg = config.services.homeassistant-shutdown;
in {
options.services = {
homeassistant-shutdown = {
enable = mkEnableOption "HomeAssistant shutdown service";
};
};
config = mkIf cfg.enable {
users.users.hass = {
isNormalUser = true;
home = "/home/hass";
description = "HomeAssistant automations";
extraGroups = [];
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICzLKowPwiQtAIgrY1wSvdolcDkbXokWrda//EEzQfR5 root@homeassistant"];
};
# Create a symlink to the shell script we created to the absolute path
# /etc/shutdown-script
environment.etc.shutdown-script.source = "${bin}/bin/shutdown";
security.sudo.extraRules = [
{
users = ["hass"];
commands = [
{
# Allow the 'hass' user to run the shutdown script
command = "/etc/shutdown-script";
options = ["NOPASSWD"];
}
];
}
];
# Allow the 'hass' user to log in, but not via password authentication.
# The authorized key is specified above.
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
AllowUsers = ["hass"];
};
};
};
}

View file

@ -19,9 +19,6 @@ with lib._elements; {
./beszel-agent.nix
./wayland.nix
# TODO: Add config settings like "services.shutdown.enable = true;"
"${inputs.self}/modules/nixos/common/services/shutdown.nix"
];
elements = {
@ -95,6 +92,8 @@ with lib._elements; {
# Bluetooth manager
blueman.enable = true;
homeassistant-shutdown.enable = true;
pulseaudio.enable = true;
pulseaudio.support32Bit = true;
pipewire.enable = lib.mkForce false;