From ebe0e83f923b91a1f6bad0149ada515a8adb0a04 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 24 Feb 2024 22:24:22 +0100 Subject: [PATCH] Split everything up --- configuration.nix | 103 ------------------ flake.nix | 2 +- hosts/vbox_nix/default.nix | 17 +++ .../vbox_nix/hardware-configuration.nix | 0 system/default.nix | 13 +++ system/network.nix | 16 +++ system/nix.nix | 35 ++++++ system/packages.nix | 9 ++ system/users.nix | 8 ++ 9 files changed, 99 insertions(+), 104 deletions(-) delete mode 100644 configuration.nix create mode 100644 hosts/vbox_nix/default.nix rename hardware-configuration.nix => hosts/vbox_nix/hardware-configuration.nix (100%) create mode 100644 system/default.nix create mode 100644 system/network.nix create mode 100644 system/nix.nix create mode 100644 system/packages.nix create mode 100644 system/users.nix diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index a8e5349..0000000 --- a/configuration.nix +++ /dev/null @@ -1,103 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, ... }: - -{ - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. - time.timeZone = "Europe/Bratislava"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "sk_SK.UTF-8"; - LC_IDENTIFICATION = "sk_SK.UTF-8"; - LC_MEASUREMENT = "sk_SK.UTF-8"; - LC_MONETARY = "sk_SK.UTF-8"; - LC_NAME = "sk_SK.UTF-8"; - LC_NUMERIC = "sk_SK.UTF-8"; - LC_PAPER = "sk_SK.UTF-8"; - LC_TELEPHONE = "sk_SK.UTF-8"; - LC_TIME = "sk_SK.UTF-8"; - }; - - # Configure keymap in X11 - services.xserver = { - layout = "us"; - xkbVariant = ""; - }; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.itsdrike = { - isNormalUser = true; - description = "ItsDrike"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; []; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - vim - git - gnupg - delta - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "23.11"; # Did you read the comment? - - nix.package = pkgs.nixUnstable; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; -} - diff --git a/flake.nix b/flake.nix index 4fafe47..add9f4c 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ flake = { nixosConfigurations = { nixos = nixpkgs.lib.nixosSystem { - modules = [ ./configuration.nix ]; + modules = [ ./system ./hosts/vbox_nix ]; }; }; }; diff --git a/hosts/vbox_nix/default.nix b/hosts/vbox_nix/default.nix new file mode 100644 index 0000000..47f1b24 --- /dev/null +++ b/hosts/vbox_nix/default.nix @@ -0,0 +1,17 @@ +{lib, ...}: +{ + imports = [ ./hardware-configuration.nix ]; + + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + timeout = 3; + }; + + networking.hostName = "nixos"; + + # NixOS release from which this machine was first installed. + # (for stateful data, like file locations and db versions) + # Leave this alone! + system.stateVersion = lib.mkForce "23.11"; +} diff --git a/hardware-configuration.nix b/hosts/vbox_nix/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to hosts/vbox_nix/hardware-configuration.nix diff --git a/system/default.nix b/system/default.nix new file mode 100644 index 0000000..14b15d8 --- /dev/null +++ b/system/default.nix @@ -0,0 +1,13 @@ +{lib, ...}: +{ + imports = [ + ./network.nix + ./users.nix + ./nix.nix + ./packages.nix + ]; + + # Internationalisation properties + time.timeZone = "CET"; + i18n.defaultLocale = "en_US.UTF-8"; +} diff --git a/system/network.nix b/system/network.nix new file mode 100644 index 0000000..192cd31 --- /dev/null +++ b/system/network.nix @@ -0,0 +1,16 @@ +{lib, ...}: +{ + networking = { + firewall.enable = false; + + networkmanager = { + enable = true; + dns = "systemd-resolved"; + }; + }; + + services.resolved.enable = true; + + # Don't wait for network manager startup + systemd.services.NetworkManager-wait-online.enable = lib.mkForce false; +} diff --git a/system/nix.nix b/system/nix.nix new file mode 100644 index 0000000..6b22de5 --- /dev/null +++ b/system/nix.nix @@ -0,0 +1,35 @@ +{pkgs, ...}: +{ + nix = { + settings = { + # nix often takes up a lot of space, with /nix/store growing beyond reasonable sizes + # this turns on automatic optimisation of the nix store that will run during every build + # (alternatively, you can do this manually with `nix-store --optimise`) + auto-optimise-store = true; + # enable flakes support + experimental-features = [ "nix-command" "flakes" ]; + }; + + # Enable automatic garbage collection, deleting entries older than 14 days + # you can also run this manually with `nix-store --gc --delete-older-than 14d`. + # If a result still exists in the file system, all the dependencies used to build + # it will be kept. + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 14d"; + }; + + # Also run garbage colleciton whenever there is not enough space left, + # freeing up to 1 GiB whenever there is less than 512MiB left. + extraOptions = '' + min-free = ${toString (512 * 1024 * 1024)} + max-free = ${toString (1024 * 1024 * 1024)} + ''; + }; + + nixpkgs.config.allowUnfree = true; + + # Git is needed for flakes + environment.systemPackages = with pkgs; [git]; +} diff --git a/system/packages.nix b/system/packages.nix new file mode 100644 index 0000000..8c3140c --- /dev/null +++ b/system/packages.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: +{ + # Basic list of must-have packages for all systems + environment.systemPackages = with pkgs; [ + vim + gnupg + delta + ]; +} diff --git a/system/users.nix b/system/users.nix new file mode 100644 index 0000000..0717223 --- /dev/null +++ b/system/users.nix @@ -0,0 +1,8 @@ +{pkgs, ...}: +{ + users.users.itsdrike = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + initialPassword = "itsdrike"; + }; +}