Update configuration.nix
This commit is contained in:
@@ -1,28 +1,26 @@
|
|||||||
# Edit this configuration file to define what should be installed on
|
# NixOS USB configuration with auto-update from public Git repo
|
||||||
# your system. Help is available in the configuration.nix(5) man page
|
# Repo: https://git.skarockoi.de/ska/nixos-production.git
|
||||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
|
||||||
|
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
gitRepoUrl = "https://git.skarockoi.de/ska/nixos-production.git";
|
||||||
|
gitLocalPath = "/var/lib/nixos-config";
|
||||||
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
[ # Include the results of the hardware scan.
|
[ ./hardware-configuration.nix ];
|
||||||
./hardware-configuration.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
# Bootloader.
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
networking.hostName = "nixos-usb"; # Define your hostname.
|
networking.hostName = "nixos-usb";
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
|
|
||||||
# Set your time zone.
|
|
||||||
time.timeZone = "Europe/Berlin";
|
time.timeZone = "Europe/Berlin";
|
||||||
|
|
||||||
# Select internationalisation properties.
|
|
||||||
i18n.defaultLocale = "de_DE.UTF-8";
|
i18n.defaultLocale = "de_DE.UTF-8";
|
||||||
|
|
||||||
i18n.extraLocaleSettings = {
|
i18n.extraLocaleSettings = {
|
||||||
LC_ADDRESS = "de_DE.UTF-8";
|
LC_ADDRESS = "de_DE.UTF-8";
|
||||||
LC_IDENTIFICATION = "de_DE.UTF-8";
|
LC_IDENTIFICATION = "de_DE.UTF-8";
|
||||||
@@ -35,29 +33,13 @@
|
|||||||
LC_TIME = "de_DE.UTF-8";
|
LC_TIME = "de_DE.UTF-8";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Enable the X11 windowing system.
|
|
||||||
services.xserver.enable = true;
|
services.xserver.enable = true;
|
||||||
|
|
||||||
# Enable the GNOME Desktop Environment.
|
|
||||||
services.xserver.displayManager.gdm.enable = true;
|
services.xserver.displayManager.gdm.enable = true;
|
||||||
services.xserver.desktopManager.gnome.enable = true;
|
services.xserver.desktopManager.gnome.enable = true;
|
||||||
|
services.xserver.xkb.layout = "de";
|
||||||
# Configure keymap in X11
|
services.xserver.libinput.enable = true;
|
||||||
services.xserver.xkb = {
|
|
||||||
layout = "de";
|
|
||||||
variant = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Configure console keymap
|
|
||||||
console.keyMap = "de";
|
console.keyMap = "de";
|
||||||
|
|
||||||
# Enable touchpad support
|
|
||||||
services.xserver.libinput.enable = true;
|
|
||||||
|
|
||||||
# Enable CUPS to print documents.
|
|
||||||
services.printing.enable = true;
|
|
||||||
|
|
||||||
# Enable sound with pipewire.
|
|
||||||
services.pulseaudio.enable = false;
|
services.pulseaudio.enable = false;
|
||||||
security.rtkit.enable = true;
|
security.rtkit.enable = true;
|
||||||
services.pipewire = {
|
services.pipewire = {
|
||||||
@@ -67,28 +49,23 @@
|
|||||||
pulse.enable = true;
|
pulse.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Define a user account.
|
services.printing.enable = true;
|
||||||
|
|
||||||
users.users.user = {
|
users.users.user = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
description = "user";
|
description = "Default USB user";
|
||||||
extraGroups = [ "networkmanager" "wheel" ];
|
extraGroups = [ "networkmanager" "wheel" ];
|
||||||
shell = pkgs.bash;
|
shell = pkgs.bash;
|
||||||
# Set password after first boot with: passwd user
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Allow unfree packages (required for Obsidian, etc.)
|
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
# List packages installed in system profile.
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
# Core utilities
|
|
||||||
nano
|
|
||||||
git
|
git
|
||||||
curl
|
curl
|
||||||
wget
|
wget
|
||||||
openssh # for ssh/scp if needed
|
vim
|
||||||
|
openssh # optional, for scp etc.
|
||||||
# Requested applications
|
|
||||||
obsidian
|
obsidian
|
||||||
libreoffice
|
libreoffice
|
||||||
keepassxc
|
keepassxc
|
||||||
@@ -97,17 +74,66 @@
|
|||||||
inkscape
|
inkscape
|
||||||
gimp
|
gimp
|
||||||
pdfarranger
|
pdfarranger
|
||||||
|
epiphany
|
||||||
apostrophe
|
apostrophe
|
||||||
|
|
||||||
# GNOME & web apps
|
|
||||||
epiphany # GNOME Web — can install web apps
|
|
||||||
gnomeExtensions.gsconnect
|
gnomeExtensions.gsconnect
|
||||||
gnomeExtensions.dash-to-dock
|
gnomeExtensions.dash-to-dock
|
||||||
];
|
];
|
||||||
|
|
||||||
# Enable Firefox.
|
|
||||||
programs.firefox.enable = true;
|
programs.firefox.enable = true;
|
||||||
|
|
||||||
# This value determines the NixOS release compatibility.
|
# === Auto-update script: fetch config from public Git repo ===
|
||||||
|
environment.etc."update-nixos-config.sh".text = ''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export PATH="${pkgs.git}/bin:${pkgs.nix}/bin:/run/current-system/sw/bin"
|
||||||
|
|
||||||
|
LOCAL_PATH="${gitLocalPath}"
|
||||||
|
REPO_URL="${gitRepoUrl}"
|
||||||
|
|
||||||
|
if [ ! -d "$LOCAL_PATH/.git" ]; then
|
||||||
|
mkdir -p "$LOCAL_PATH"
|
||||||
|
chmod 700 "$LOCAL_PATH"
|
||||||
|
echo "Cloning config from $REPO_URL..."
|
||||||
|
git clone "$REPO_URL" "$LOCAL_PATH"
|
||||||
|
else
|
||||||
|
cd "$LOCAL_PATH"
|
||||||
|
echo "Fetching updates..."
|
||||||
|
git fetch origin
|
||||||
|
LOCAL_HEAD=$(git rev-parse HEAD)
|
||||||
|
REMOTE_HEAD=$(git rev-parse origin/main)
|
||||||
|
if [ "$LOCAL_HEAD" != "$REMOTE_HEAD" ]; then
|
||||||
|
echo "New config available. Updating..."
|
||||||
|
git reset --hard origin/main
|
||||||
|
nixos-rebuild switch -I nixos-config="$LOCAL_PATH/configuration.nix"
|
||||||
|
echo "System updated successfully."
|
||||||
|
else
|
||||||
|
echo "Config is already up to date."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
environment.etc."update-nixos-config.sh".mode = "0700";
|
||||||
|
|
||||||
|
# === Systemd timer for automatic updates ===
|
||||||
|
systemd.services.nixos-git-update = {
|
||||||
|
description = "Update NixOS from public Git config";
|
||||||
|
script = "/etc/update-nixos-config.sh";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "root";
|
||||||
|
Group = "root";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers.nixos-git-update = {
|
||||||
|
description = "Check for config updates hourly";
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnBootSec = "60s";
|
||||||
|
OnUnitActiveSec = "1h";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
system.stateVersion = "25.11";
|
system.stateVersion = "25.11";
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user