From ce30261865b23f4deb7eab426727be519b5facea Mon Sep 17 00:00:00 2001 From: Alexander Wainwright Date: Thu, 26 Jun 2025 21:38:14 +1000 Subject: [PATCH] Restructure --- flake.nix | 40 ++--- hosts/case/configuration.nix | 38 ++++ .../case/hardware-configuration.nix | 0 locutus.toml => hosts/case/locutus.toml | 0 configuration.nix => hosts/modules/base.nix | 165 +++++------------- hosts/modules/desktop.nix | 48 +++++ 6 files changed, 146 insertions(+), 145 deletions(-) create mode 100644 hosts/case/configuration.nix rename hardware-configuration.nix => hosts/case/hardware-configuration.nix (100%) rename locutus.toml => hosts/case/locutus.toml (100%) rename configuration.nix => hosts/modules/base.nix (52%) create mode 100644 hosts/modules/desktop.nix diff --git a/flake.nix b/flake.nix index 4399740..7e369b4 100644 --- a/flake.nix +++ b/flake.nix @@ -16,30 +16,30 @@ }; outputs = { self, nixpkgs, home-manager, ... }@inputs: { - nixosConfigurations.case = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; + nixosConfigurations = { + case = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ - # Import the previous configuration.nix we used, - # so the old configuration file still takes effect - ./configuration.nix + specialArgs = { inherit inputs; }; + modules = [ - # make home-manager as a module of nixos so that home-manager - # configuration will be deployed automatically when executing - # `nixos-rebuild switch` - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; + ./hosts/case/configuration.nix - home-manager.users.alex = import ./alex/home.nix; + # enable home manager + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; - # Optionally, use home-manager.extraSpecialArgs to pass arguments to - # home.nix - home-manager.extraSpecialArgs = { inherit inputs; }; - } - ]; + home-manager.users.alex = import ./alex/home.nix; + + # Optionally, use home-manager.extraSpecialArgs to pass arguments to + # home.nix + home-manager.extraSpecialArgs = { inherit inputs; }; + } + ]; + # other hosts... + }; }; }; } diff --git a/hosts/case/configuration.nix b/hosts/case/configuration.nix new file mode 100644 index 0000000..030216d --- /dev/null +++ b/hosts/case/configuration.nix @@ -0,0 +1,38 @@ +# 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, inputs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ../modules/base.nix + ../modules/desktop.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "case"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # run locutus every hour + services.cron = { + enable = true; + systemCronJobs = [ + "27 * * * * root locutus backup 2>&1 | logger -t locutus-backup" + ]; + }; + environment.etc."locutus/locutus.toml".source = ./locutus.toml; + + # 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 = "25.05"; # Did you read the comment? +} diff --git a/hardware-configuration.nix b/hosts/case/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to hosts/case/hardware-configuration.nix diff --git a/locutus.toml b/hosts/case/locutus.toml similarity index 100% rename from locutus.toml rename to hosts/case/locutus.toml diff --git a/configuration.nix b/hosts/modules/base.nix similarity index 52% rename from configuration.nix rename to hosts/modules/base.nix index cfb035d..d816250 100644 --- a/configuration.nix +++ b/hosts/modules/base.nix @@ -1,25 +1,15 @@ -# 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, inputs, ... }: - { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.alex = { + isNormalUser = true; + description = "Alexander Wainwright"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + # thunderbird ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "case"; # 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"; + shell = pkgs.fish; + }; # Enable networking networking.networkmanager.enable = true; @@ -44,50 +34,28 @@ LC_TIME = "en_AU.UTF-8"; }; - # Enable the X11 windowing system. - services.xserver.enable = true; - - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - # Configure keymap in X11 - services.xserver.xkb = { - layout = "us"; - variant = "dvorak"; - }; - # Configure console keymap console.keyMap = "dvorak"; - # Enable CUPS to print documents. - services.printing.enable = true; + # fish shell + programs.fish.enable = true; - # Enable sound with pipewire. - services.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; + # Create a library path that only applies to unpackaged programs by using + # nix-ldo + # https://nix.dev/guides/faq#how-to-run-non-nix-executables + programs.nix-ld.enable = true; + programs.nix-ld.libraries = with pkgs; [ + # Add any missing dynamic libraries for unpackaged programs + # here, NOT in environment.systemPackages + ]; - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # run locutus every hour - services.cron = { - enable = true; - systemCronJobs = [ - "27 * * * * root locutus backup 2>&1 | logger -t locutus-backup" - ]; - }; + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + # Enable the Flakes feature and the accompanying new nix command-line tool + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + # Enable zeroconf services.avahi = { enable = true; nssmdns4 = true; # Enables Avahi for name service lookups (e.g., in /etc/nsswitch.conf) @@ -104,42 +72,26 @@ # services.resolved.extraConfig = "MulticastDNS=yes"; }; - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; + environment.variables.EDITOR = "nvim"; - # Create a library path that only applies to unpackaged programs by using - # nix-ldo - # https://nix.dev/guides/faq#how-to-run-non-nix-executables - programs.nix-ld.enable = true; - programs.nix-ld.libraries = with pkgs; [ - # Add any missing dynamic libraries for unpackaged programs - # here, NOT in environment.systemPackages - ]; + # 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; + # }; - programs.fish.enable = true; + # Enable the OpenSSH daemon. + services.openssh.enable = true; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.alex = { - isNormalUser = true; - description = "Alexander Wainwright"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - # thunderbird - ]; - shell = pkgs.fish; - }; + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; - # Install firefox. - programs.firefox.enable = true; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # Enable the Flakes feature and the accompanying new nix command-line tool - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # List packages installed in system profile. To search, run: - # $ nix search wget + # Packages environment.systemPackages = with pkgs; [ avahi bat @@ -160,7 +112,6 @@ uv wget zip - mullvad-vpn binutils cmake @@ -168,41 +119,5 @@ clang gnumake libtool - - inputs.locutus.packages.${pkgs.system}.default ]; - - environment.etc."locutus/locutus.toml".source = ./locutus.toml; - - environment.variables.EDITOR = "nvim"; - - # 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.mullvad-vpn.package = pkgs.mullvad-vpn; - - # 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 = "25.05"; # Did you read the comment? - } diff --git a/hosts/modules/desktop.nix b/hosts/modules/desktop.nix new file mode 100644 index 0000000..e8d4998 --- /dev/null +++ b/hosts/modules/desktop.nix @@ -0,0 +1,48 @@ +{ config, pkgs, inputs, ... }: +{ + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = "dvorak"; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Mullvad vpn + services.mullvad-vpn.package = pkgs.mullvad-vpn; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Install firefox. + programs.firefox.enable = true; + + environment.systemPackages = with pkgs; [ + inputs.locutus.packages.${pkgs.system}.default + mullvad-vpn + ]; +}