From c241b30e6bb5894ac483ea4b9ec799c9e26e6730 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Thu, 22 Jun 2023 09:54:46 +0100 Subject: [PATCH] Move some extra bits into flake expression --- common.nix | 40 ---------------- flake.nix | 86 +++++++++++++++++++++++++++++++--- hardware/audio.nix | 13 ----- hardware/bluetooth.nix | 6 --- hosts/Legion/configuration.nix | 16 +++++-- hosts/Legion/home.nix | 6 --- locales/en_GB.nix | 25 ---------- 7 files changed, 92 insertions(+), 100 deletions(-) delete mode 100644 common.nix delete mode 100644 hardware/audio.nix delete mode 100644 hardware/bluetooth.nix delete mode 100644 hosts/Legion/home.nix delete mode 100644 locales/en_GB.nix diff --git a/common.nix b/common.nix deleted file mode 100644 index 41333d61..00000000 --- a/common.nix +++ /dev/null @@ -1,40 +0,0 @@ -{lib, ...}: let - home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz"; -in { - imports = [(import "${home-manager}/nixos")]; - nix = { - settings.experimental-features = ["nix-command" "flakes"]; - gc = { - automatic = true; - dates = "daily"; - options = "--delete-older-than 7d"; - }; - extraOptions = '' - keep-outputs = true - keep-derivations = true - ''; - }; - system.autoUpgrade.enable = lib.mkDefault false; - nixpkgs.config.allowUnfree = true; - home-manager = { - useUserPackages = true; - useGlobalPkgs = true; - users.root = { - imports = [./home/env/bash.nix ./home/env/starship.nix]; - home.username = "root"; - home.homeDirectory = "/root"; - home.stateVersion = "22.11"; - }; - }; - networking.networkmanager.enable = true; - services.power-profiles-daemon.enable = true; - virtualisation.podman.enable = true; - programs = { - ssh.startAgent = true; - dconf.enable = true; - fish.enable = true; - zsh.enable = true; - }; - fonts.fontconfig.enable = true; - environment.localBinInPath = true; -} diff --git a/flake.nix b/flake.nix index fa8c5fb5..717b9840 100644 --- a/flake.nix +++ b/flake.nix @@ -13,15 +13,88 @@ self, nixpkgs, home-manager, - }: { + }: let + common-config = {...}: { + nix = { + settings.experimental-features = ["nix-command" "flakes"]; + gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than 7d"; + }; + extraOptions = '' + keep-outputs = true + keep-derivations = true + ''; + }; + nixpkgs.config.allowUnfree = true; + networking = { + networkmanager.enable = true; + firewall.enable = true; + }; + services.power-profiles-daemon.enable = true; + virtualisation.podman.enable = true; + programs = { + ssh.startAgent = true; + dconf.enable = true; + fish.enable = true; + zsh.enable = true; + }; + fonts.fontconfig.enable = true; + environment.localBinInPath = true; + }; + locale-en_GB = {...}: { + services.xserver = { + layout = "gb"; + xkbVariant = ""; + }; + console.keyMap = "uk"; + + # Set your time zone. + time.timeZone = "Europe/London"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_GB.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_GB.UTF-8"; + LC_IDENTIFICATION = "en_GB.UTF-8"; + LC_MEASUREMENT = "en_GB.UTF-8"; + LC_MONETARY = "en_GB.UTF-8"; + LC_NAME = "en_GB.UTF-8"; + LC_NUMERIC = "en_GB.UTF-8"; + LC_PAPER = "en_GB.UTF-8"; + LC_TELEPHONE = "en_GB.UTF-8"; + LC_TIME = "en_GB.UTF-8"; + }; + }; + audio = {...}: { + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + programs.noisetorch.enable = true; + }; + bluetooth = {...}: { + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; + }; + in { nixosConfigurations = { Legion = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ home-manager.nixosModules.home-manager + common-config + locale-en_GB ./hosts/Legion/configuration.nix - ./common.nix - ./locales/en_GB.nix ./services/Legion.nix ]; }; @@ -29,10 +102,11 @@ system = "x86_64-linux"; modules = [ home-manager.nixosModules.home-manager + common-config + locale-en_GB + audio + bluetooth ./hosts/N0245/configuration.nix - ./common.nix - ./hardware/audio.nix - ./hardware/bluetooth.nix ./locales/en_GB.nix ./wm/sway.nix ./services/syncthing/N0245.nix diff --git a/hardware/audio.nix b/hardware/audio.nix deleted file mode 100644 index 317d2cb7..00000000 --- a/hardware/audio.nix +++ /dev/null @@ -1,13 +0,0 @@ -{pkgs, ...}: { - # Enable sound with pipewire. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - }; - programs.noisetorch.enable = true; -} diff --git a/hardware/bluetooth.nix b/hardware/bluetooth.nix deleted file mode 100644 index 56358af9..00000000 --- a/hardware/bluetooth.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - hardware.bluetooth = { - enable = true; - powerOnBoot = true; - }; -} diff --git a/hosts/Legion/configuration.nix b/hosts/Legion/configuration.nix index 08372608..02bb0fa1 100644 --- a/hosts/Legion/configuration.nix +++ b/hosts/Legion/configuration.nix @@ -7,8 +7,6 @@ ./hardware-configuration.nix ]; - nix.extraOptions = ''experimental-features = nix-command flakes ''; - # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; @@ -16,7 +14,6 @@ networking = { hostName = "Legion"; # Define your hostname. nameservers = ["192.168.1.230" "127.0.0.1" "9.9.9.9"]; - firewall = {enable = true;}; }; system.autoUpgrade = { enable = true; @@ -35,7 +32,18 @@ shell = pkgs.fish; openssh.authorizedKeys.keys = import ../../auth/authorized_keys.nix; }; - home-manager.users.xenia = import ./home.nix; + home-manager.users.xenia = { + imports = [../../home/personal.nix]; + home.username = "xenia"; + home.homeDirectory = "/home/xenia"; + home.stateVersion = "22.11"; + }; + home-manager.users.root = { + imports = [../../home/env/bash.nix ../../home/env/starship.nix]; + home.username = "root"; + home.homeDirectory = "/root"; + home.stateVersion = "22.11"; + }; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/hosts/Legion/home.nix b/hosts/Legion/home.nix deleted file mode 100644 index 2d18b6f7..00000000 --- a/hosts/Legion/home.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - imports = [../../home/personal.nix]; - home.username = "xenia"; - home.homeDirectory = "/home/xenia"; - home.stateVersion = "22.11"; -} diff --git a/locales/en_GB.nix b/locales/en_GB.nix deleted file mode 100644 index e2a4742a..00000000 --- a/locales/en_GB.nix +++ /dev/null @@ -1,25 +0,0 @@ -{...}: { - services.xserver = { - layout = "gb"; - xkbVariant = ""; - }; - console.keyMap = "uk"; - - # Set your time zone. - time.timeZone = "Europe/London"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_GB.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_GB.UTF-8"; - LC_IDENTIFICATION = "en_GB.UTF-8"; - LC_MEASUREMENT = "en_GB.UTF-8"; - LC_MONETARY = "en_GB.UTF-8"; - LC_NAME = "en_GB.UTF-8"; - LC_NUMERIC = "en_GB.UTF-8"; - LC_PAPER = "en_GB.UTF-8"; - LC_TELEPHONE = "en_GB.UTF-8"; - LC_TIME = "en_GB.UTF-8"; - }; -}