moving toward a multi-machine configuration !

This commit is contained in:
boyreau 2026-08-01 20:29:56 +02:00
commit 4cef631a8c
18 changed files with 250 additions and 181 deletions

35
README.md Normal file
View file

@ -0,0 +1,35 @@
Top-level files are global configurations
- machines/
- server.nix # Abstract default
- desktop.nix
- name/ # A concrete machine
- default.nix # Machine configuration
- home/ # Home-manager configuration
- pkgs/ # custom derivations
- jailed-packages.nix # Security-wrapped packages
.
├── security.nix # Global security settings
├── configuration.nix
├── machines/ # Machines configurations
│   ├── desktop.nix # Global desktop settings
│ │
│   ├── memere/ # Machine-specific configuration
│   │ ├── default.nix
│   │ └── hardware-configuration.nix
│   └── niczos/ # Machine-specific configuration
│   ├── default.nix
│   ├── hardware-configuration.nix
│   ├── kernel.nix
│   └── security.nix # Specializes the global security.nix
│
├── nix.nix # Package manager config
├── npins # Pins to ensure coherent packages versions
│   ├── default.nix
│   └── sources.json
├── pkgs # Custom derivations and overlay
│   ├── default.nix
│   └── jailed-packages.nix
├── README.md
└── shell.nix

View file

@ -1,112 +1,3 @@
{ {
config, _ = abort "please set a configuration using -I /etc/nixos/machines/some-machine/default.nix";
...
}:
let
pkgs = import ./jailed-packages.nix;
more_pkgs = {
rayfish = pkgs.callPackage ./pkgs/rayfish.nix { };
};
in
{
imports = [
./security.nix
./hardware-configuration.nix
./hardware.nix
./bootloader.nix
./kernel.nix
./nix.nix
./users.nix
];
programs.fuse.userAllowOther = true;
networking.hostName = "niczos";
networking.networkmanager.enable = true;
time.timeZone = "Europe/Paris";
i18n.defaultLocale = "en_US.UTF-8";
virtualisation = {
waydroid = {
enable = true;
package = pkgs.waydroid-nftables.unjailed;
};
docker = {
enable = true;
storageDriver = "btrfs";
};
};
programs.steam.enable = true;
services.pipewire = {
enable = true;
audio.enable = true;
pulse.enable = true;
alsa = {
enable = true;
};
wireplumber.enable = true;
};
security = {
rtkit.enable = true;
wrappers = {
waydroid = {
source = "${pkgs.waydroid}/bin/waydroid";
capabilities = "cap_net_admin=ep";
enable = true;
owner = "root";
group = "root";
program = "waydroid";
};
};
};
systemd = {
defaultUnit = "graphical.target";
services."getty@tty1" = {
overrideStrategy = "asDropin";
serviceConfig.ExecStart = [
""
"@${pkgs.util-linux}/sbin/agetty agetty --login-program ${config.services.getty.loginProgram} --autologin zo --noclear --keep-baud %I 115200,38400,9600 $TERM"
];
};
packages = [
more_pkgs.rayfish
];
services."rayfish" = {
wantedBy = [ "multi-user.target" ];
enable = true;
};
};
environment.systemPackages = with pkgs; [
curl
wget
cryptsetup
cachix
more_pkgs.rayfish
];
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-color-emoji
liberation_ttf
fira-code
fira-code-symbols
mplus-outline-fonts.githubRelease
dina-font
proggyfonts
font-awesome
];
system.copySystemConfiguration = true;
system.stateVersion = "26.05"; # Not here to update, here for data models backward compatibility. Don't change.
} }

38
machines/desktop.nix Normal file
View file

@ -0,0 +1,38 @@
{
config,
pkgs ? import (config.root + /pkgs),
...
}:
{
programs.dconf.enable = true;
systemd = {
defaultUnit = "graphical.target";
};
services.pipewire = {
enable = true;
audio.enable = true;
pulse.enable = true;
alsa = {
enable = true;
};
wireplumber.enable = true;
};
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-color-emoji
liberation_ttf
fira-code
fira-code-symbols
mplus-outline-fonts.githubRelease
dina-font
proggyfonts
font-awesome
];
time.timeZone = "Europe/Paris";
i18n.defaultLocale = pkgs.lib.mkDefault "fr_FR.UTF-8";
}

View file

@ -0,0 +1,31 @@
{
config,
pkgs ? import <nixpkgs>, # Do not use jail.nix packages
...
}:
{
imports = [
/etc/nixos/security.nix
/etc/nixos/nix.nix
./users.nix
];
services.desktopManager.gnome.enable = true;
services.gnome = {
core-apps.enable = true;
core-shell.enable = true;
gnome-software.enable = true;
};
nix.nixPath = [
"nixos-config=/etc/nixos/machines/memere/default.nix"
"nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
"/nix/var/nix/profiles/per-user/root/channels"
];
networking.hostName = "pepere";
networking.networkmanager.enable = true;
i18n.defaultLocale = "fr_FR.UTF-8";
}

24
machines/memere/users.nix Normal file
View file

@ -0,0 +1,24 @@
{ config, pkgs, ... }:
let
source = import (config.root + /npins);
home-manager = source.home-manager;
in
{
imports = [
(import "${home-manager}/nixos")
];
home-manager.useGlobalPkgs = true;
users.users.memere.isNormalUser = true;
home-manager.users.memere =
{ pkgs, ... }:
{
home.packages = [ ];
programs.bash.enable = true;
# The state version is required and should stay at the version you
# originally installed.
home.stateVersion = "26.05";
};
}

View file

@ -0,0 +1,80 @@
{
config,
...
}:
let
pkgs = import /etc/nixos/pkgs/jailed-packages.nix;
in
{
imports = [
/etc/nixos/security.nix
/etc/nixos/nix.nix
/etc/nixos/machines/desktop.nix
./bootloader.nix
./hardware-configuration.nix
./hardware.nix
./kernel.nix
./security.nix
./users.nix
];
nix.nixPath = [
"nixos-config=/etc/nixos/machines/niczos/default.nix"
"nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
"/nix/var/nix/profiles/per-user/root/channels"
];
networking.hostName = "niczos";
networking.networkmanager.enable = true;
systemd = {
services."getty@tty1" = {
overrideStrategy = "asDropin";
serviceConfig.ExecStart = [
""
"@${pkgs.util-linux}/sbin/agetty agetty --login-program ${config.services.getty.loginProgram} --autologin zo --noclear --keep-baud %I 115200,38400,9600 $TERM"
];
};
};
programs = {
steam.enable = true;
fuse.userAllowOther = true;
};
virtualisation.docker = {
enable = true;
storageDriver = "btrfs";
};
# Waydroid configuration
virtualisation.waydroid = {
enable = true;
package = pkgs.waydroid-nftables.unjailed;
};
security = {
rtkit.enable = true;
wrappers = {
waydroid = {
source = "${pkgs.waydroid}/bin/waydroid";
capabilities = "cap_net_admin=ep";
enable = true;
owner = "root";
group = "root";
program = "waydroid";
};
};
};
environment.systemPackages = [
pkgs.curl
pkgs.wget
pkgs.cryptsetup
pkgs.cachix
];
i18n.defaultLocale = "en_US.UTF-8";
system.copySystemConfiguration = true;
system.stateVersion = "26.05";
}

View file

@ -14,11 +14,13 @@
pkgs.epsonscan2 pkgs.epsonscan2
]; ];
boot.kernelParams = [ boot = {
"nvidia.NVreg_PreserveVideoMemoryAllocations=1" kernelParams = [
"nvidia.NVreg_TemporaryFilePath=/var/tmp" "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"usb-storage.quirks=152d:0578:u" "nvidia.NVreg_TemporaryFilePath=/var/tmp"
]; "usb-storage.quirks=152d:0578:u"
];
};
hardware = { hardware = {
enableRedistributableFirmware = lib.mkDefault true; enableRedistributableFirmware = lib.mkDefault true;
@ -26,7 +28,7 @@
########## Printers and scanners ########## ########## Printers and scanners ##########
sane.enable = true; sane.enable = true;
######### nVidia Quadro RTX 3000m ######### ######### Nvidia Quadro RTX 3000m #########
graphics.enable = true; graphics.enable = true;
nvidia = { nvidia = {
open = false; # Not compatible with current GPU open = false; # Not compatible with current GPU

View file

@ -1,5 +1,5 @@
let let
sources = import ./npins/default.nix; sources = import /etc/nixos/npins/default.nix;
cachy-source = import sources.nix-cachyos-kernel; cachy-source = import sources.nix-cachyos-kernel;
cachy-kernel = cachy-kernel =
cachy-source.outputs.legacyPackages.x86_64-linux.linuxPackages-cachyos-bore-lto-x86_64-v3; cachy-source.outputs.legacyPackages.x86_64-linux.linuxPackages-cachyos-bore-lto-x86_64-v3;

View file

@ -0,0 +1,7 @@
{
# Classic deny all
networking.firewall = {
allowedTCPPorts = [ 1716 ];
allowedUDPPorts = [ 1716 ];
};
}

View file

@ -1,6 +1,6 @@
{ pkgs, ... }: { pkgs, ... }:
let let
source = import ./npins; source = import /etc/nixos/npins;
home-manager = source.home-manager; home-manager = source.home-manager;
in in
{ {

View file

@ -1,6 +1,6 @@
{ {
nix.gc = { nix.gc = {
automatic = true; automatic = false;
dates = "weekly"; dates = "weekly";
options = "--delete-older-than 30d"; options = "--delete-older-than 30d";
}; };

View file

@ -9,9 +9,9 @@
}, },
"branch": "release-26.05", "branch": "release-26.05",
"submodules": false, "submodules": false,
"revision": "3cd22efe6471dc7365c822bd9ad73a21e55f38fb", "revision": "d4fd24667c8cbef124bb70a20380cab75ec8474d",
"url": "https://github.com/nix-community/home-manager/archive/3cd22efe6471dc7365c822bd9ad73a21e55f38fb.tar.gz", "url": "https://github.com/nix-community/home-manager/archive/d4fd24667c8cbef124bb70a20380cab75ec8474d.tar.gz",
"hash": "sha256-qajyHfZY29G2oEQk+uHxmsJcRoBUBXP9maTpFlwP/dI=" "hash": "sha256-Rgs2xKnGLFWQscxUaXX07oyZeuMDOHEbqDOsgliLFGM="
}, },
"jail.nix": { "jail.nix": {
"type": "Git", "type": "Git",
@ -34,30 +34,14 @@
}, },
"branch": "release", "branch": "release",
"submodules": false, "submodules": false,
"revision": "4673c8f6d48baf2ec3f14b6a9f8c4ecfb0810d6f", "revision": "4f3c8ca048091c5fbad5447c660133ac1a151ac7",
"url": "https://github.com/xddxdd/nix-cachyos-kernel/archive/4673c8f6d48baf2ec3f14b6a9f8c4ecfb0810d6f.tar.gz", "url": "https://github.com/xddxdd/nix-cachyos-kernel/archive/4f3c8ca048091c5fbad5447c660133ac1a151ac7.tar.gz",
"hash": "sha256-w5ALD125oHIa5MVhoBXo3qx2ktvRvJ+1p8UScV9f8OI=" "hash": "sha256-QeJMNuRgY5E7pAYTjgMO8Te9Rg0AEI5CgS8EYQpZzHw="
}, },
"nixpkgs": { "nixpkgs": {
"type": "Tarball", "type": "Tarball",
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.2462.e8210c649915/nixexprs.tar.xz", "url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.2462.e8210c649915/nixexprs.tar.xz",
"hash": "sha256-2khLdWQw7Z9psJUEORs8dKPwivbhLbiBTas81jEZtJs=" "hash": "sha256-2khLdWQw7Z9psJUEORs8dKPwivbhLbiBTas81jEZtJs="
},
"rayfish": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "rayfish",
"repo": "rayfish"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"submodules": false,
"version": "v0.2.0",
"revision": "21239b1c2007e42eba1552ed2c2cf4bb0d1b7bc3",
"url": "https://api.github.com/repos/rayfish/rayfish/tarball/refs/tags/v0.2.0",
"hash": "sha256-Y9XQt6HhGWXI7Uwpw4TjqMavqEE/+pa0gEhQ0Gh/SqM="
} }
}, },
"version": 7 "version": 7

1
pkgs/default.nix Normal file
View file

@ -0,0 +1 @@
(import ./jailed-packages.nix)

View file

@ -1,5 +1,5 @@
let let
sources = import ./npins/default.nix; sources = import /etc/nixos/npins/default.nix;
jail-nix = import /home/zo/dev/jail.nix { }; jail-nix = import /home/zo/dev/jail.nix { };
jailOverlay = jailOverlay =
final: prev: final: prev:

View file

@ -1,36 +0,0 @@
{
fetchFromGitHub,
rustPlatform,
}:
let
sources = import ../npins/default.nix;
rayfish-repo = sources.rayfish;
in
rustPlatform.buildRustPackage {
pname = "rayfish";
version = "0.2.0";
src = fetchFromGitHub {
owner = rayfish-repo.repository.owner;
repo = rayfish-repo.repository.repo;
tag = rayfish-repo.version;
hash = rayfish-repo.hash;
};
cargoHash = "sha256-mh4lGbI3GUH32vf0FwVqyh737gCM7nEphQJr1rQed48=";
doCheck = false;
installPhase = /* bash */ ''
runHook installPhase
mkdir -p $out/bin/
mkdir -p $out/lib/systemd/system/
# Copy binary and service to out
cp ./target/x86_64-unknown-linux-gnu/release/ray $out/bin/
cp ./contrib/rayfish.service $out/lib/systemd/system/
# Patch binary path in service file to match derivation path
sed -i "s|/usr/local/bin/ray|$out/bin/ray|g" $out/lib/systemd/system/rayfish.service
'';
}

View file

@ -1,9 +1,21 @@
{ {
# Classic deny all
networking.nftables.enable = true; networking.nftables.enable = true;
networking.firewall = { networking.firewall = {
enable = true; enable = true;
# Lwk connect ports allowedTCPPorts = [ ];
allowedTCPPorts = [ 1716 ]; allowedUDPPorts = [ ];
allowedUDPPorts = [ 1716 ];
}; };
# No fork bomb
environment.etc."security/limits.conf".text = ''
* soft nproc 2000
* hard nproc 4000
'';
# Wheel group may edit the configuration.
systemd.tmpfiles.rules = [
"Z! /etc/nixos 4070 root wheel"
"A! /etc/nixos - - - - d:u::rwx,d:g::-,d:g:wheel:rwx,d:mask:rwx"
];
} }