1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: build a much more minimal config for installing

This commit is contained in:
oddlama 2023-09-26 21:43:23 +02:00
parent 73897f648d
commit 73d7a42879
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
11 changed files with 136 additions and 113 deletions

View file

@ -131,6 +131,7 @@
hosts hosts
microvmConfigurations microvmConfigurations
nixosConfigurations nixosConfigurations
nixosConfigurationsMinimal
; ;
# All nixosSystem instanciations are collected here, so that we can refer # All nixosSystem instanciations are collected here, so that we can refer
@ -141,11 +142,13 @@
# For each true NixOS system, we want to expose an installer package that # For each true NixOS system, we want to expose an installer package that
# can be used to do the initial setup on the node from a live environment. # can be used to do the initial setup on the node from a live environment.
# We use the minimal sibling configuration to reduce the amount of stuff
# we have to copy to the live system.
inherit inherit
(foldl' recursiveUpdate {} (foldl' recursiveUpdate {}
(mapAttrsToList (mapAttrsToList
(import ./nix/generate-installer-package.nix inputs) (import ./nix/generate-installer-package.nix inputs)
self.nixosConfigurations)) self.nixosConfigurationsMinimal))
packages packages
; ;
} }

View file

@ -1,4 +1,10 @@
{inputs, ...}: { {
inputs,
lib,
minimal,
...
}:
{
imports = [ imports = [
inputs.nixos-hardware.nixosModules.common-cpu-amd inputs.nixos-hardware.nixosModules.common-cpu-amd
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
@ -25,15 +31,17 @@
]; ];
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"]; boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"];
boot.binfmt.emulatedSystems = ["aarch64-linux"]; }
graphical.gaming.enable = true; // lib.optionalAttrs (!minimal) {
# TODO goodbye once -sk keys. # TODO goodbye once -sk keys.
environment.shellInit = '' environment.shellInit = ''
gpg-connect-agent /bye gpg-connect-agent /bye
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
''; '';
boot.binfmt.emulatedSystems = ["aarch64-linux"];
graphical.gaming.enable = true;
stylix.fonts.sizes = { stylix.fonts.sizes = {
#desktop = 20; #desktop = 20;
applications = 10; applications = 10;

View file

@ -44,18 +44,12 @@
options = "--delete-older-than 90d"; options = "--delete-older-than 90d";
}; };
# Define global flakes for this system # Define global flakes for this system
registry = { registry = rec {
nixpkgs.flake = inputs.nixpkgs; nixpkgs.flake = inputs.nixpkgs;
p.flake = inputs.nixpkgs; p = nixpkgs;
pkgs.flake = inputs.nixpkgs;
templates.flake = inputs.templates; templates.flake = inputs.templates;
}; };
}; };
system = { system.stateVersion = "23.11";
extraSystemBuilderCmds = ''
ln -sv ${pkgs.path} $out/nixpkgs
'';
stateVersion = "23.11";
};
} }

View file

@ -1,8 +1,11 @@
{ {
inputs, inputs,
pkgs, pkgs,
lib,
minimal,
... ...
}: { }:
lib.optionalAttrs (!minimal) {
imports = [ imports = [
inputs.nixseparatedebuginfod.nixosModules.default inputs.nixseparatedebuginfod.nixosModules.default
./documentation.nix ./documentation.nix

View file

@ -2,14 +2,24 @@
config, config,
inputs, inputs,
lib, lib,
minimal,
... ...
}: let }: let
inherit inherit
(lib) (lib)
mkOption mkOption
types types
optionalAttrs
; ;
in { in
{
options.graphical.gaming.enable = mkOption {
description = "Enables gaming on this machine and will add a lot of gaming related packages and configuration.";
default = false;
type = types.bool;
};
}
// optionalAttrs (!minimal) {
imports = [ imports = [
inputs.stylix.nixosModules.stylix inputs.stylix.nixosModules.stylix
@ -19,12 +29,6 @@ in {
./xserver.nix ./xserver.nix
]; ];
options.graphical.gaming.enable = mkOption {
description = "Enables gaming on this machine and will add a lot of gaming related packages and configuration.";
default = false;
type = types.bool;
};
config = { config = {
# Needed for gtk # Needed for gtk
programs.dconf.enable = true; programs.dconf.enable = true;

View file

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

View file

@ -1,8 +1,10 @@
{ {
lib, lib,
minimal,
pkgs, pkgs,
... ...
}: { }:
lib.optionalAttrs (!minimal) {
# Helpful utilities: # Helpful utilities:
# Show pipewire devices and application overview or specifics # Show pipewire devices and application overview or specifics
# > wpctl status; wpctl inspect <id> # > wpctl status; wpctl inspect <id>

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

@ -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; inherit (self) nodes;
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;});
nixosConfigurationsMinimal = 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
nixosConfigurationsMinimal
; ;
} }

View file

@ -1,10 +1,13 @@
{ {
config, config,
lib,
pkgs, pkgs,
minimal,
... ...
}: let }: let
myuser = config.repo.secrets.global.myuser.name; myuser = config.repo.secrets.global.myuser.name;
in { in
lib.optionalAttrs (!minimal) {
users.groups.${myuser}.gid = config.users.users.${myuser}.uid; users.groups.${myuser}.gid = config.users.users.${myuser}.uid;
users.users.${myuser} = { users.users.${myuser} = {
uid = 1000; uid = 1000;

View file

@ -37,6 +37,9 @@
zathura zathura
]; ];
# TODO audible bell in qt pinentry drives me nuts
# TODO secureboot -> use pam yubikey login
# TODO keyboard stays lit on poweroff -> add systemd service to disable it on shutdown
# TODO on neogit close do neotree update # TODO on neogit close do neotree update
# TODO kitty terminfo missing with ssh root@localhost # TODO kitty terminfo missing with ssh root@localhost
# TODO nix repl cltr+del doesnt work # TODO nix repl cltr+del doesnt work