feat: reimaged laptop

This commit is contained in:
Patrick 2023-09-26 22:25:58 +02:00
parent 4b81b90d50
commit df40786d28
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
18 changed files with 69 additions and 28 deletions

View file

@ -78,7 +78,7 @@
4. Run the installer script from the nix store of the live system 4. Run the installer script from the nix store of the live system
- you can get the path using `nix path-info .#packages.<target-system>.installer-package.<target>` - you can get the path using `nix path-info .#packages.<target-system>.installer-package.<target>`
4. Export all zpools and reboot into system 4. Export all zpools and reboot into system
6. Retrieve hostkeys using `ssh-keyscan <host> | grep -o 'ssh-ed25519.*' > host/<target>/secrets/host.pub 6. Retrieve hostkeys using `ssh-keyscan <host> | grep -o 'ssh-ed25519.*' > host/<target>/secrets/host.pub`
5. Deploy system 5. Deploy system
### Add secureboot to new systems ### Add secureboot to new systems

View file

@ -109,15 +109,15 @@
hosts hosts
microvmConfigurations microvmConfigurations
nixosConfigurations nixosConfigurations
minimalConfigurations
; ;
nodes = self.nixosConfigurations // self.microvmConfigurations; nodes = self.nixosConfigurations // self.microvmConfigurations;
top = lib.mapAttrs (_: x: x.config.system.build.toplevel) self.nodes;
inherit inherit
(lib.foldl' lib.recursiveUpdate {} (lib.foldl' lib.recursiveUpdate {}
(lib.mapAttrsToList (lib.mapAttrsToList
(import ./nix/generate-installer-package.nix inputs) (import ./nix/generate-installer-package.nix inputs)
self.nixosConfigurations)) self.minimalConfigurations))
packages packages
; ;
} }
@ -139,7 +139,7 @@
inherit pkgs; inherit pkgs;
modules = [ modules = [
./nix/installer-configuration.nix ./nix/installer-configuration.nix
./modules/os-conf/core/ssh.nix ./modules/config/ssh.nix
{system.stateVersion = stateVersion;} {system.stateVersion = stateVersion;}
]; ];
format = format =

View file

@ -12,9 +12,9 @@
type = "table"; type = "table";
format = "gpt"; format = "gpt";
partitions = [ partitions = [
(partEfiBoot "boot" "0%" "512MiB") (partEfiBoot "boot" "0%" "1GiB")
#(partSwap "swap" "1GiB" "17GiB") (partSwap "swap" "1GiB" "17GiB")
(partLuksZfs "rpool" "rpool" "512MiB" "100%") (partLuksZfs "rpool" "rpool" "17GiB" "100%")
]; ];
}; };
}; };

View file

@ -1 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJrr6bJgWzCuS+00EEBQRoylwput69tqvotgPjSF5xhz root@patricknix ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJLkYv7UrkdkTYj8YvoEwtwvaRBA4P/zYj5opl0+eDst root@patricknix

View file

@ -7,7 +7,7 @@
settings = { settings = {
auto-optimise-store = true; auto-optimise-store = true;
allowed-users = ["@wheel" "nixseparatedebuginfod"]; allowed-users = ["@wheel" "nixseparatedebuginfod"];
trusted-users = ["root" "@wheel"]; trusted-users = ["root"];
system-features = ["recursive-nix" "repl-flake" "big-parallel"]; system-features = ["recursive-nix" "repl-flake" "big-parallel"];
substituters = [ substituters = [
"https://nix-config.cachix.org" "https://nix-config.cachix.org"
@ -25,6 +25,8 @@
]; ];
cores = 0; cores = 0;
max-jobs = "auto"; max-jobs = "auto";
# make agenix rekey find the secrets even without trusted user
extra-sandbox-paths = ["/var/tmp/agenix-rekey?"];
}; };
daemonCPUSchedPolicy = "batch"; daemonCPUSchedPolicy = "batch";
daemonIOSchedPriority = 5; daemonIOSchedPriority = 5;

View file

@ -1,4 +1,9 @@
{ {
lib,
minimal,
...
}:
lib.optionalAttrs (!minimal) {
imports = [ imports = [
./docs.nix ./docs.nix
]; ];

View file

@ -1,4 +1,10 @@
{pkgs, ...}: { {
pkgs,
minimal,
lib,
...
}:
lib.optionalAttrs (!minimal) {
fonts = { fonts = {
enableGhostscriptFonts = false; enableGhostscriptFonts = false;
fontDir.enable = false; fontDir.enable = false;

View file

@ -1,8 +1,10 @@
{ {
lib, lib,
minimal,
pkgs, pkgs,
... ...
}: { }:
lib.optionalAttrs (!minimal) {
services.xserver.videoDrivers = lib.mkForce ["nvidia"]; services.xserver.videoDrivers = lib.mkForce ["nvidia"];
hardware = { hardware = {

View file

@ -1,8 +1,10 @@
{ {
lib, lib,
minimal,
pkgs, pkgs,
... ...
}: { }:
lib.optionalAttrs (!minimal) {
environment.systemPackages = with pkgs; [pulseaudio pulsemixer]; environment.systemPackages = with pkgs; [pulseaudio pulsemixer];
hardware.pulseaudio.enable = lib.mkForce false; hardware.pulseaudio.enable = lib.mkForce false;

View file

@ -5,19 +5,18 @@
}: let }: let
inherit inherit
(lib) (lib)
mdDoc
mkOption mkOption
types types
; ;
in { in {
options.node = { options.node = {
name = mkOption { name = mkOption {
description = mdDoc "A unique name for this node (host) in the repository. Defines the default hostname, but this can be overwritten."; description = "A unique name for this node (host) in the repository. Defines the default hostname, but this can be overwritten.";
type = types.str; type = types.str;
}; };
secretsDir = mkOption { secretsDir = mkOption {
description = mdDoc "Path to the secrets directory for this node."; description = "Path to the secrets directory for this node.";
type = types.path; type = types.path;
}; };
}; };

View file

@ -1,9 +1,11 @@
{ {
pkgs,
lib, lib,
minimal,
pkgs,
config, config,
... ...
}: { }:
lib.optionalAttrs (!minimal) {
environment.systemPackages = [ environment.systemPackages = [
# For debugging and troubleshooting Secure Boot. # For debugging and troubleshooting Secure Boot.
(pkgs.sbctl.override (pkgs.sbctl.override

View file

@ -1,4 +1,10 @@
{pkgs, ...}: { {
lib,
minimal,
pkgs,
...
}:
lib.optionalAttrs (!minimal) {
programs.steam = { programs.steam = {
enable = true; enable = true;
package = pkgs.steam.override { package = pkgs.steam.override {

View file

@ -1,4 +1,10 @@
{pkgs, ...}: { {
lib,
minimal,
pkgs,
...
}:
lib.optionalAttrs (!minimal) {
services.dbus.enable = true; services.dbus.enable = true;
xdg.portal = { xdg.portal = {
enable = true; enable = true;

View file

@ -1,4 +1,9 @@
{ {
lib,
minimal,
...
}:
lib.optionalAttrs (!minimal) {
# Configure keymap in X11 # Configure keymap in X11
services.xserver = { services.xserver = {
enable = true; enable = true;

View file

@ -45,6 +45,10 @@ in
package = pkgs.deadnix; package = pkgs.deadnix;
help = "Remove dead nix code"; help = "Remove dead nix code";
} }
{
package = pkgs.nix-tree;
help = "Show nix closure tree";
}
{ {
package = pkgs.update-nix-fetchgit; package = pkgs.update-nix-fetchgit;
help = "Update fetcher inside nix files"; help = "Update fetcher inside nix files";

View file

@ -12,15 +12,15 @@ inputs: let
; ;
# Creates a new nixosSystem with the correct specialArgs, pkgs and name definition # Creates a new nixosSystem with the correct specialArgs, pkgs and name definition
mkHost = name: system: let mkHost = {minimal}: name: hostCfg: let
pkgs = self.pkgs.${system}; pkgs = self.pkgs.${hostCfg.system};
in in
nixosSystem { nixosSystem {
specialArgs = { specialArgs = {
# Use the correct instance lib that has our overlays # Use the correct instance lib that has our overlays
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (self) nodes stateVersion; inherit (self) nodes stateVersion;
inherit inputs; inherit inputs minimal;
}; };
modules = [ modules = [
{ {
@ -28,7 +28,7 @@ inputs: let
# inputs.nixpkgs.nixosModules.readOnlyPkgs, since some nixosModules # inputs.nixpkgs.nixosModules.readOnlyPkgs, since some nixosModules
# like nixseparatedebuginfod depend on adding packages via nixpkgs.overlays. # like nixseparatedebuginfod depend on adding packages via nixpkgs.overlays.
# So we just mimic the options and overlays defined by the passed pkgs set. # So we just mimic the options and overlays defined by the passed pkgs set.
nixpkgs.hostPlatform = system; nixpkgs.hostPlatform = hostCfg.system;
nixpkgs.overlays = pkgs.overlays; nixpkgs.overlays = pkgs.overlays;
nixpkgs.config = pkgs.config; nixpkgs.config = pkgs.config;
node.name = name; node.name = name;
@ -45,7 +45,8 @@ inputs: let
# Get all hosts of type "nixos" # Get all hosts of type "nixos"
nixosHosts = filterAttrs (_: x: x.type == "nixos") hosts; nixosHosts = filterAttrs (_: x: x.type == "nixos") hosts;
# Process each nixosHosts declaration and generatea nixosSystem definitions # Process each nixosHosts declaration and generatea nixosSystem definitions
nixosConfigurations = flip mapAttrs nixosHosts (name: hostCfg: mkHost name hostCfg.system); nixosConfigurations = flip mapAttrs nixosHosts (mkHost {minimal = false;});
minimalConfigurations = flip mapAttrs nixosHosts (mkHost {minimal = true;});
# True NixOS nodes can define additional microvms (guest nodes) that are built # True NixOS nodes can define additional microvms (guest nodes) that are built
# together with the true host. We collect all defined microvm nodes # together with the true host. We collect all defined microvm nodes
@ -59,5 +60,6 @@ in {
hosts hosts
microvmConfigurations microvmConfigurations
nixosConfigurations nixosConfigurations
minimalConfigurations
; ;
} }

View file

@ -15,9 +15,6 @@
]; ];
}; };
# Grub broken
boot.loader.systemd-boot.enable = true;
environment = { environment = {
variables.EDITOR = "nvim"; variables.EDITOR = "nvim";
systemPackages = with pkgs; [ systemPackages = with pkgs; [

View file

@ -1,8 +1,11 @@
{ {
pkgs, pkgs,
config, config,
lib,
minimal,
... ...
}: { }:
lib.optionalAttrs (!minimal) {
imports = [ imports = [
../../modules/optional/steam.nix ../../modules/optional/steam.nix
./impermanence.nix ./impermanence.nix