From f96e27fecd10c030de705a7315200784c2fc6263 Mon Sep 17 00:00:00 2001 From: tristan Date: Sat, 15 Apr 2023 12:23:31 +0100 Subject: [PATCH] modularise a bit --- flake.nix | 21 ++------ system/configuration.nix => global.nix | 50 ------------------- .../zenix.nix | 0 lib/mkconf.nix | 17 +++++++ system/zenix.nix | 23 +++++++++ 5 files changed, 44 insertions(+), 67 deletions(-) rename system/configuration.nix => global.nix (67%) rename system/hardware-configuration.nix => hardware/zenix.nix (100%) create mode 100644 lib/mkconf.nix create mode 100644 system/zenix.nix diff --git a/flake.nix b/flake.nix index 8fc5a25..965a71e 100644 --- a/flake.nix +++ b/flake.nix @@ -10,29 +10,16 @@ outputs = { nixpkgs, home-manager, ... }: let system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - lib = nixpkgs.lib; + mkConf = import ./lib/mkconf.nix; + + user = "tristan"; in { - nixosConfigurations = { - zenix = lib.nixosSystem { - inherit system; - - modules = [ - ./system/configuration.nix - home-manager.nixosModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.tristan = { - imports = [ ./home.nix ]; - }; - } - ]; - }; + zenix = mkConf "zenix" { inherit nixpkgs system user home-manager; }; }; }; } diff --git a/system/configuration.nix b/global.nix similarity index 67% rename from system/configuration.nix rename to global.nix index 9151e5a..f637e5a 100644 --- a/system/configuration.nix +++ b/global.nix @@ -1,42 +1,22 @@ -# 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’). # https://search.nixos.org/options { config, pkgs, ... }: { - imports = [ - ./hardware-configuration.nix - ]; - nix.settings = { experimental-features = [ "nix-command" "flakes" ]; }; nix.settings.trusted-users = [ "root" "tristan" ]; - # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - # boot.loader.grub.enable = true; - # boot.loader.grub.version = 2; - # boot.loader.grub.devices = ["nodev"]; - # boot.loader.grub.useOSProber = true; - # boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "zenix"; networking.networkmanager.enable = true; time.timeZone = "Europe/London"; - i18n.defaultLocale = "en_GB.UTF-8"; - console = { - font = "Lat2-Terminus16"; - }; - # use pipewire hardware.pulseaudio.enable = false; security.rtkit.enable = true; @@ -158,35 +138,5 @@ bind-key -T copy-mode-vi y send-keys -X copy-selection ''; - # 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; - - services.tailscale.enable = true; - - # Open ports in the firewall. - networking.firewall.allowedTCPPorts = [ ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - networking.firewall.checkReversePath = "loose"; - - # Copy the NixOS configuration file and link it from the resulting system - # (/run/current-system/configuration.nix). This is useful in case you - # accidentally delete configuration.nix. - # system.copySystemConfiguration = true; - - system.stateVersion = "22.11"; # Did you read the comment? - } diff --git a/system/hardware-configuration.nix b/hardware/zenix.nix similarity index 100% rename from system/hardware-configuration.nix rename to hardware/zenix.nix diff --git a/lib/mkconf.nix b/lib/mkconf.nix new file mode 100644 index 0000000..5619b73 --- /dev/null +++ b/lib/mkconf.nix @@ -0,0 +1,17 @@ +name: { nixpkgs, home-manager, system, user, ... }: + +nixpkgs.lib.nixosSystem rec { + inherit system; + + modules = [ + + ../hardware/${name}.nix + ../system/${name}.nix + ../global.nix + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${user} = import ../home.nix; + } + ]; +} diff --git a/system/zenix.nix b/system/zenix.nix new file mode 100644 index 0000000..3fe7f44 --- /dev/null +++ b/system/zenix.nix @@ -0,0 +1,23 @@ +# https://search.nixos.org/options + +{ config, pkgs, ... }: +{ + + networking.hostName = "zenix"; + + i18n.defaultLocale = "en_GB.UTF-8"; + console = { + font = "Lat2-Terminus16"; + }; + + services.openssh.enable = true; + + services.tailscale.enable = true; + networking.firewall.checkReversePath = "loose"; + + networking.firewall.allowedTCPPorts = [ ]; + + system.stateVersion = "22.11"; # do not change + +} +