Compare commits

...
18 Commits
Author SHA1 Message Date
Jan-Bulthuis 4b7c62d00b Gave local passwordless sudo, rerolled and encrypted the authorized key. 2025-05-30 16:05:00 +02:00
Jan-Bulthuis cfc276184f Updated README.md 2025-05-30 15:37:19 +02:00
Jan-Bulthuis 87b50bfb4d Updated secrets 2025-05-30 15:26:05 +02:00
Jan-Bulthuis 1bc34518e1 Added deployment key to root account 2025-05-30 15:11:22 +02:00
Jan-Bulthuis f1dcb8c72b Updated sops-nix to also directly point at /persist 2025-05-30 14:35:59 +02:00
Jan-Bulthuis ec002467fa Updated secrets 2025-05-30 14:03:14 +02:00
Jan-Bulthuis 5a228cb375 Updated update script 2025-05-30 14:03:05 +02:00
Jan-Bulthuis d53e395d42 Added a module for SOPS 2025-05-30 13:56:50 +02:00
Jan-Bulthuis cb39f82a48 Updated flake.lock 2025-05-30 12:42:35 +02:00
Jan-Bulthuis 0efee5bceb Added dependency on nixos-secrets 2025-05-30 12:06:21 +02:00
Jan-Bulthuis 844118055c Updated README.md 2025-05-29 21:00:40 +02:00
Jan-Bulthuis 0ba9de0030 Set disk device for vm disko 2025-05-29 20:46:44 +02:00
Jan-Bulthuis a745b35c84 Added update script 2025-05-29 20:37:12 +02:00
Jan-Bulthuis 6c74dcbc22 Automatically login to user 2025-05-29 20:32:19 +02:00
Jan-Bulthuis 76e609372f Added persistence to ssh host keys 2025-05-29 20:28:07 +02:00
Jan-Bulthuis cd91944b1e Updated local user configuration 2025-05-29 20:20:18 +02:00
Jan-Bulthuis bebd2748d1 Moved bitwarden to a module 2025-05-29 19:23:52 +02:00
Jan 12a4ba0482 Merge pull request 'Add disko support' (#2) from disko into main
Reviewed-on: Jan/dotfiles#2
2025-05-29 16:33:31 +00:00
11 changed files with 222 additions and 14 deletions

No files matched your search

+33 -2
View File
@@ -4,8 +4,39 @@ My NixOS configuration.
## Installation ## Installation
For disk configuration we use disko, this means that installing the system from the configuration is just a single command: For disk configuration we use disko, but for secrets management we use sops-nix and the particular setup makes the installation process a bit more involved. It is required that the computer from which the installation is being run has access to the `nixos-secrets` repository, otherwise you will need to manually add the required ssh keys to the installation image.
```bash
# Load into the installer
sudo passwd # Set a root password
# From a machine with network access to the installer
# and access to the nixos-secrets repo
ssh -A root@(installer-ip)
# Set up disks
nix-shell -p disko
disko --mode disko --flake git+https://git.bulthuis.dev/Jan/nixos-config#(system)
exit
# Install NixOS
nixos-install --no-channel-copy --no-root-password --flake git+https://git.bulthuis.dev/Jan/nixos-config#(system)
cd /mnt/persist/system/etc/sops
# Set up host credentials for access to the secrets
touch sops_ed25519_key
chmod 600 sops_ed25519_key
nano sops_ed25519_key
``` ```
sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/latest#disko-install" -- --flake git+https://git.bulthuis.dev/Jan/dotfiles#<hostname> --disk main /dev/sda If `nixos-install` is being stopped by the OOM-killer, you can try adding `-j 1` to limit the amount of jobs that will be executed at the same time to 1. It might require running nixos-install multiple times untill it has managed to download all requirements and slowly start building the rest of the system.
## Updating
To update the system configuration, it is a single command:
```bash
sudo system-update
``` ```
Or if this shell script has not been installed for some reason:
```bash
sudo nixos-rebuild switch --flake git+https://git.bulthuis.dev/Jan/nixos-config
```
Sometimes it may be necessary to reboot of course.
Generated
+38 -1
View File
@@ -154,7 +154,44 @@
"impermanence": "impermanence", "impermanence": "impermanence",
"nix-minecraft": "nix-minecraft", "nix-minecraft": "nix-minecraft",
"nix-modpack": "nix-modpack", "nix-modpack": "nix-modpack",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"secrets": "secrets",
"sops-nix": "sops-nix"
}
},
"secrets": {
"locked": {
"lastModified": 1748613807,
"narHash": "sha256-awE+2QvMkGP4OOPGniFMldvYnLYj60n4izgEJXcJUv0=",
"ref": "refs/heads/main",
"rev": "d120fcc272429517649402cf2ccefb9334f50535",
"revCount": 7,
"type": "git",
"url": "ssh://gitea@git.bulthuis.dev/Jan/nixos-secrets"
},
"original": {
"type": "git",
"url": "ssh://gitea@git.bulthuis.dev/Jan/nixos-secrets"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1747603214,
"narHash": "sha256-lAblXm0VwifYCJ/ILPXJwlz0qNY07DDYdLD+9H+Wc8o=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "8d215e1c981be3aa37e47aeabd4e61bb069548fd",
"type": "github"
},
"original": {
"owner": "Mic92",
"repo": "sops-nix",
"type": "github"
} }
}, },
"systems": { "systems": {
+7
View File
@@ -6,6 +6,13 @@
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager"; home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Secrets
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
secrets.url = "git+ssh://gitea@git.bulthuis.dev/Jan/nixos-secrets";
# Disk setup
disko.url = "github:nix-community/disko"; disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs"; disko.inputs.nixpkgs.follows = "nixpkgs";
impermanence.url = "github:nix-community/impermanence"; impermanence.url = "github:nix-community/impermanence";
+22
View File
@@ -0,0 +1,22 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.bitwarden;
in
{
options.modules.bitwarden = {
enable = mkEnableOption "Bitwarden";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
bitwarden-desktop
];
};
}
+39
View File
@@ -0,0 +1,39 @@
{
inputs,
lib,
config,
...
}:
with lib;
let
cfg = config.modules.secrets;
secrets = inputs.secrets;
in
{
options.modules.secrets = {
enable = mkEnableOption "secrets";
defaultFile = mkOption {
type = types.str;
default = "${secrets}/secrets/common.enc.yaml";
description = ''
The default file to use for SOPS.
'';
};
secrets = mkOption {
type = types.attrs;
default = { };
description = ''
All secrets that should be made available.
'';
};
};
config = mkIf cfg.enable {
# Set up SOPS
sops.defaultSopsFile = cfg.defaultFile;
sops.age.sshKeyPaths = [ "${config.home.homeDirectory}/.config/sops/sops_ed25519_key" ];
sops.secrets = cfg.secrets;
modules.impermanence.directories = [ ".config/sops" ];
};
}
+43
View File
@@ -0,0 +1,43 @@
{
inputs,
lib,
config,
...
}:
with lib;
let
cfg = config.modules.secrets;
secrets = inputs.secrets;
in
{
options.modules.secrets = {
enable = mkEnableOption "secrets";
defaultFile = mkOption {
type = types.str;
default = "${secrets}/secrets/common.enc.yaml";
description = ''
The default file to use for SOPS.
'';
};
secrets = mkOption {
type = types.attrs;
default = { };
description = ''
All secrets that should be made available.
'';
};
};
config = mkIf cfg.enable {
# Set up SOPS
# TODO: Fix the key not being present in /etc/sops before sops-nix runs
sops.defaultSopsFile = cfg.defaultFile;
sops.age.sshKeyPaths = [
"/etc/sops/sops_ed25519_key"
"/persist/system/etc/sops/sops_ed25519_key"
];
sops.secrets = cfg.secrets;
modules.impermanence.directories = [ "/etc/sops" ];
};
}
+12
View File
@@ -11,5 +11,17 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.openssh.enable = true; services.openssh.enable = true;
# TODO: Is this default configuration secure? # TODO: Is this default configuration secure?
services.openssh.hostKeys = mkIf (config.modules.impermanence.enable) [
{
type = "ed25519";
path = "/persist/system/etc/ssh/ssh_host_ed25519_key";
}
{
type = "rsa";
bits = 4096;
path = "/persist/system/etc/ssh/ssh_host_rsa_key";
}
];
}; };
} }
+1
View File
@@ -3,6 +3,7 @@
disk = { disk = {
main = { main = {
type = "disk"; type = "disk";
device = "/dev/sda";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
+1 -1
View File
@@ -24,7 +24,6 @@ in
freecad-wayland freecad-wayland
inkscape inkscape
ente-auth ente-auth
bitwarden
carla carla
winbox winbox
whatsapp-for-linux whatsapp-for-linux
@@ -61,6 +60,7 @@ in
"flake.lock" "flake.lock"
]; ];
}; };
bitwarden.enable = true;
xpra = { xpra = {
enable = true; enable = true;
hosts = [ hosts = [
+9 -5
View File
@@ -1,5 +1,4 @@
{ {
mkModule,
pkgs, pkgs,
lib, lib,
config, config,
@@ -20,13 +19,18 @@ in
bootloader.enable = mkDefault true; bootloader.enable = mkDefault true;
ssh.enable = mkDefault true; ssh.enable = mkDefault true;
# Setup sensible default persistent data
impermanence.directories = [ impermanence.directories = [
"/var/lib/nixos" "/var/lib/nixos"
]; ];
impermanence.files = [
"/etc/shadow" secrets = {
]; enable = true;
secrets = {
"ssh-keys/deploy-priv" = {
path = "/root/.ssh/id_ed25519";
};
};
};
}; };
# Localization # Localization
+17 -5
View File
@@ -1,5 +1,4 @@
{ {
mkModule,
pkgs, pkgs,
lib, lib,
config, config,
@@ -33,15 +32,28 @@ in
ssh.enable = true; ssh.enable = true;
}; };
# Admin users # Local user
services.getty.autologinUser = "local";
security.sudo.extraRules = [
{
users = [ "local" ];
options = [ "NOPASSWD" ];
}
];
users.mutableUsers = false;
users.users.local = { users.users.local = {
initialPassword = "local";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keyFiles = [
"ssh-ed25519 jan@bulthuis.dev" config.sops.secrets."ssh-keys/admin-pub".path
]; ];
}; };
# System packages
environment.systemPackages = with pkgs; [
# TODO: Make module for utilities/scripts
(writeShellScriptBin "system-update" "nixos-rebuild switch --flake git+https://git.bulthuis.dev/Jan/nixos-config")
];
# Enable qemu guest agent # Enable qemu guest agent
services.qemuGuest.enable = true; services.qemuGuest.enable = true;