From 7eaaae30236402ad00cb4099ab5913bc95e12627 Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Sun, 17 Nov 2024 21:14:36 +0100 Subject: [PATCH] Add base system config --- flake.nix | 3 +- systems/base.nix | 74 ++++++++++++++++++++++++++++++++++++++++++------ utils.nix | 7 ++--- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index 5573e95..5bb8033 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,8 @@ in { nixosConfigurations = { - "nix-test" = utils.mkSystem ./systems/nix-test.nix; + "base" = utils.mkSystem [ ]; + "nix-test" = utils.mkSystem [ ./systems/nix-test.nix ]; }; }; } diff --git a/systems/base.nix b/systems/base.nix index 357664f..a1e1a5b 100644 --- a/systems/base.nix +++ b/systems/base.nix @@ -1,14 +1,70 @@ -{ ... }: { - nix.settings = { - # Enable flakes and new 'nix' command - experimental-features = "nix-command flakes"; - # Deduplicate and optimize nix store - auto-optimise-store = true; - }; - - services.openssh.enable = true; + modulesPath, + lib, + pkgs, + ... +}: +{ + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; time.timeZone = "Europe/Amsterdam"; i18n.defaultLocale = "en_US.UTF-8"; + + config = { + #Provide a default hostname + networking.hostName = lib.mkDefault "base"; + + # Enable QEMU Guest for Proxmox + services.qemuGuest.enable = lib.mkDefault true; + + # Use the boot drive for grub + boot.loader.grub.enable = lib.mkDefault true; + boot.loader.grub.devices = [ "nodev" ]; + + boot.growPartition = lib.mkDefault true; + + # Allow remote updates with flakes and non-root users + nix.settings.trusted-users = [ + "root" + "@wheel" + ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + + # Enable mDNS for `hostname.local` addresses + services.avahi.enable = true; + services.avahi.nssmdns = true; + services.avahi.publish = { + enable = true; + addresses = true; + }; + + # Some sane packages we need on every system + environment.systemPackages = with pkgs; [ + vim + git + ]; + + # Don't ask for passwords + security.sudo.wheelNeedsPassword = false; + + # Enable ssh + services.openssh = { + enable = true; + settings.PasswordAuthentication = false; + settings.KbdInteractiveAuthentication = false; + }; + programs.ssh.startAgent = true; + + # Default filesystem + fileSystems."/" = lib.mkDefault { + device = "/dev/disk/by-label/nixos"; + autoResize = true; + fsType = "ext4"; + }; + + system.stateVersion = lib.mkDefault "24.05"; + }; } diff --git a/utils.nix b/utils.nix index 5ed2a44..71b6df4 100644 --- a/utils.nix +++ b/utils.nix @@ -6,15 +6,12 @@ }: { mkSystem = - config: + configs: nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs outputs; }; - modules = [ - ./systems/base.nix - config - ]; + modules = [ ./systems/base.nix ] ++ configs; }; }