From e65c6bc1599a51ab085a09b9612e1b165fbaa7e0 Mon Sep 17 00:00:00 2001 From: ooks-io Date: Mon, 15 Jan 2024 22:12:53 +1300 Subject: [PATCH] restructure system configuration --- flake.nix | 8 +++++++- hosts/common/features/bluetooth.nix | 13 ------------- hosts/ooksdesk/{ooksdesk.nix => default.nix} | 0 hosts/ooksmicro/{ooksmicro.nix => default.nix} | 0 hosts/ookst480s/{ookst480s.nix => default.nix} | 1 - hosts/ooksx1/{ooksx1.nix => default.nix} | 0 {hosts/common => system}/base/auto-upgrade.nix | 0 {hosts/common => system}/base/default.nix | 11 ----------- {hosts/common => system}/base/fish.nix | 0 {hosts/common => system}/base/locale.nix | 1 + {hosts/common => system}/base/pipewire.nix | 0 {hosts/common => system}/base/security.nix | 1 + {hosts/common => system}/base/systemdboot.nix | 0 system/modules/default.nix | 9 +++++++++ .../modules/displayManager/greetd/default.nix | 0 system/modules/hardware/backlight.nix | 14 ++++++++++++++ system/modules/hardware/bluetooth/default.nix | 17 +++++++++++++++++ system/modules/networking/default.nix | 18 ++++++++++++++++++ system/modules/nix/default.nix | 8 ++++++++ system/modules/nix/nh.nix | 16 ++++++++++++++++ .../common/base => system/modules/nix}/nix.nix | 17 +++-------------- system/modules/nix/nixpkgs.nix | 13 +++++++++++++ system/modules/nix/subs.nix | 18 ++++++++++++++++++ .../modules/programs}/greetd.nix | 0 .../modules/programs}/vm.nix | 0 system/profiles/laptop/default.nix | 18 ++++++++++++++++++ {hosts/common => system}/user/ooks/default.nix | 4 ---- 27 files changed, 143 insertions(+), 44 deletions(-) delete mode 100644 hosts/common/features/bluetooth.nix rename hosts/ooksdesk/{ooksdesk.nix => default.nix} (100%) rename hosts/ooksmicro/{ooksmicro.nix => default.nix} (100%) rename hosts/ookst480s/{ookst480s.nix => default.nix} (98%) rename hosts/ooksx1/{ooksx1.nix => default.nix} (100%) rename {hosts/common => system}/base/auto-upgrade.nix (100%) rename {hosts/common => system}/base/default.nix (67%) rename {hosts/common => system}/base/fish.nix (100%) rename {hosts/common => system}/base/locale.nix (85%) rename {hosts/common => system}/base/pipewire.nix (100%) rename {hosts/common => system}/base/security.nix (96%) rename {hosts/common => system}/base/systemdboot.nix (100%) create mode 100644 system/modules/default.nix create mode 100644 system/modules/displayManager/greetd/default.nix create mode 100644 system/modules/hardware/backlight.nix create mode 100644 system/modules/hardware/bluetooth/default.nix create mode 100644 system/modules/networking/default.nix create mode 100644 system/modules/nix/default.nix create mode 100644 system/modules/nix/nh.nix rename {hosts/common/base => system/modules/nix}/nix.nix (57%) create mode 100644 system/modules/nix/nixpkgs.nix create mode 100644 system/modules/nix/subs.nix rename {hosts/common/features => system/modules/programs}/greetd.nix (100%) rename {hosts/common/features => system/modules/programs}/vm.nix (100%) create mode 100644 system/profiles/laptop/default.nix rename {hosts/common => system}/user/ooks/default.nix (85%) diff --git a/flake.nix b/flake.nix index d66377b..0b78650 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,12 @@ url = "github:helix-editor/helix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + nh = { + url = "github:viperML/nh"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; @@ -64,7 +70,7 @@ nixosConfigurations = { # T480s ookst480s = lib.nixosSystem { - modules = [ ./hosts/ookst480s/ookst480s.nix ]; + modules = [ ./hosts/ookst480s ]; specialArgs = { inherit inputs outputs; }; }; }; diff --git a/hosts/common/features/bluetooth.nix b/hosts/common/features/bluetooth.nix deleted file mode 100644 index 757a079..0000000 --- a/hosts/common/features/bluetooth.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - hardware.bluetooth.enable = true; - - # services.blueman.enable = true; - - environment.systemPackages = with pkgs; [ - galaxy-buds-client - live-buds-cli - bluetuith - ]; -} diff --git a/hosts/ooksdesk/ooksdesk.nix b/hosts/ooksdesk/default.nix similarity index 100% rename from hosts/ooksdesk/ooksdesk.nix rename to hosts/ooksdesk/default.nix diff --git a/hosts/ooksmicro/ooksmicro.nix b/hosts/ooksmicro/default.nix similarity index 100% rename from hosts/ooksmicro/ooksmicro.nix rename to hosts/ooksmicro/default.nix diff --git a/hosts/ookst480s/ookst480s.nix b/hosts/ookst480s/default.nix similarity index 98% rename from hosts/ookst480s/ookst480s.nix rename to hosts/ookst480s/default.nix index 3a5200b..386eac5 100644 --- a/hosts/ookst480s/ookst480s.nix +++ b/hosts/ookst480s/default.nix @@ -26,7 +26,6 @@ networking = { hostName = "ookst480s"; - networkmanager.enable = true; }; diff --git a/hosts/ooksx1/ooksx1.nix b/hosts/ooksx1/default.nix similarity index 100% rename from hosts/ooksx1/ooksx1.nix rename to hosts/ooksx1/default.nix diff --git a/hosts/common/base/auto-upgrade.nix b/system/base/auto-upgrade.nix similarity index 100% rename from hosts/common/base/auto-upgrade.nix rename to system/base/auto-upgrade.nix diff --git a/hosts/common/base/default.nix b/system/base/default.nix similarity index 67% rename from hosts/common/base/default.nix rename to system/base/default.nix index 569a538..faa1d84 100644 --- a/hosts/common/base/default.nix +++ b/system/base/default.nix @@ -11,17 +11,6 @@ ]; home-manager.extraSpecialArgs = { inherit inputs outputs; }; - - nixpkgs = { - overlays = builtins.attrValues outputs.overlays; - config = { - allowUnfree = true; - permittedInsecurePackages = [ - "openssl-1.1.1u" - ]; - }; - }; - #hardware.enableRedistibutableFirmware = true; environment.enableAllTerminfo = true; diff --git a/hosts/common/base/fish.nix b/system/base/fish.nix similarity index 100% rename from hosts/common/base/fish.nix rename to system/base/fish.nix diff --git a/hosts/common/base/locale.nix b/system/base/locale.nix similarity index 85% rename from hosts/common/base/locale.nix rename to system/base/locale.nix index cd24d78..db9bbfb 100644 --- a/hosts/common/base/locale.nix +++ b/system/base/locale.nix @@ -6,4 +6,5 @@ ]; }; time.timeZone = lib.mkDefault "Pacific/Auckland"; + services.geoclue2.enable = true; } diff --git a/hosts/common/base/pipewire.nix b/system/base/pipewire.nix similarity index 100% rename from hosts/common/base/pipewire.nix rename to system/base/pipewire.nix diff --git a/hosts/common/base/security.nix b/system/base/security.nix similarity index 96% rename from hosts/common/base/security.nix rename to system/base/security.nix index 12cce9b..74b6f49 100644 --- a/hosts/common/base/security.nix +++ b/system/base/security.nix @@ -28,6 +28,7 @@ polkit = { enable = true; }; + pam.services = { swaylock = { }; }; sudo = { enable = true; extraConfig = '' diff --git a/hosts/common/base/systemdboot.nix b/system/base/systemdboot.nix similarity index 100% rename from hosts/common/base/systemdboot.nix rename to system/base/systemdboot.nix diff --git a/system/modules/default.nix b/system/modules/default.nix new file mode 100644 index 0000000..0125f7c --- /dev/null +++ b/system/modules/default.nix @@ -0,0 +1,9 @@ +{ + imports = [ + ./hardware + ./networking + ./nix + ./programs + ./user + ]; +} diff --git a/system/modules/displayManager/greetd/default.nix b/system/modules/displayManager/greetd/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/system/modules/hardware/backlight.nix b/system/modules/hardware/backlight.nix new file mode 100644 index 0000000..7fed314 --- /dev/null +++ b/system/modules/hardware/backlight.nix @@ -0,0 +1,14 @@ +{ + hardware.brillo.enable = true; + services.clight = { + enable = true; + settings = { + verbose = true; + backlight.disabled = true; + dpms.timeouts = [900 300]; + dimmer.timeouts = [870 270]; + gamma.long_transition = true; + screen.disabled = true; + }; + }; +} diff --git a/system/modules/hardware/bluetooth/default.nix b/system/modules/hardware/bluetooth/default.nix new file mode 100644 index 0000000..503f38e --- /dev/null +++ b/system/modules/hardware/bluetooth/default.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +{ + hardware.bluetooth = { + enable = true; + package = pkgs.bluez5-experimental; + }; + + environment.systemPackages = with pkgs; [ + galaxy-buds-client + live-buds-cli + bluetuith + ]; + + # https://github.com/NixOS/nixpkgs/issues/114222 + systemd.user.services.telephony_client.enable = false; +} diff --git a/system/modules/networking/default.nix b/system/modules/networking/default.nix new file mode 100644 index 0000000..e9d2c8a --- /dev/null +++ b/system/modules/networking/default.nix @@ -0,0 +1,18 @@ +{ lib, ... }: +{ + networking.networkmanager = { + enable = true; + dns = "systemd-resolved"; + }; + networking.firewall.allowedTCPPorts = [57621]; + + services = { + openssh = { + enable = true; + settings.UseDns = true; + }; + resolved.enable = true; + }; + + systemd.services.NetworkManager-wait-online.enable = lib.mkForce false; +} diff --git a/system/modules/nix/default.nix b/system/modules/nix/default.nix new file mode 100644 index 0000000..1891600 --- /dev/null +++ b/system/modules/nix/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./nh.nix + ./nix.nix + ./nixpkgs + ./subs.nix + ]; +} diff --git a/system/modules/nix/nh.nix b/system/modules/nix/nh.nix new file mode 100644 index 0000000..007e4bc --- /dev/null +++ b/system/modules/nix/nh.nix @@ -0,0 +1,16 @@ +{ inputs, ... }: { + + imports = [ + inputs.nh.nixosModules.default + ]; + + environment.variables.FLAKE = "/home/ooks/Coding/nix/ooks-io/nix"; + + nh = { + enable = true; + clean = { + enable = true; + extraArgs = "--keep-since 30d"; + }; + }; +} diff --git a/hosts/common/base/nix.nix b/system/modules/nix/nix.nix similarity index 57% rename from hosts/common/base/nix.nix rename to system/modules/nix/nix.nix index 7c1c861..3a9c3dc 100644 --- a/hosts/common/base/nix.nix +++ b/system/modules/nix/nix.nix @@ -1,5 +1,5 @@ -{ inputs, lib, ... }: -{ +{ config, lib, pkgs, inputs, ... }: { + nix = { settings = { trusted-users = [ "root" "@wheel" ]; @@ -9,18 +9,7 @@ system-features = [ "kvm" "big-parallel" "nixos-test" ]; flake-registry = ""; }; - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 2d"; - }; - - # Add each flake input as a registry - # To make nix3 commands consistent with the flake registry = lib.mapAttrs (_: value: { flake = value; }) inputs; - - # Add nixpkgs input to NIX_PATH - # This lets nix2 commands still use nixPath = [ "nixpkgs=${inputs.nixpkgs.outPath}" ]; - }; + }; } diff --git a/system/modules/nix/nixpkgs.nix b/system/modules/nix/nixpkgs.nix new file mode 100644 index 0000000..466c27d --- /dev/null +++ b/system/modules/nix/nixpkgs.nix @@ -0,0 +1,13 @@ +{ outputs, ... }: { + + nixpkgs = { + overlays = builtins.attrValues outputs.overlays; + config = { + allowUnfree = true; + permittedInsecurePackages = [ + "openssl-1.1.1u" + "electron-25.9.0" + ]; + }; + }; +} diff --git a/system/modules/nix/subs.nix b/system/modules/nix/subs.nix new file mode 100644 index 0000000..e5d9146 --- /dev/null +++ b/system/modules/nix/subs.nix @@ -0,0 +1,18 @@ +{ + nix.settings = { + substituters = [ + "https://cache.nixos.org?priority=10" + "https://fufexan.cachix.org" + "https://helix.cachix.org" + "https://hyprland.cachix.org" + "https://nix-community.cachix.org" + ]; + + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; +} diff --git a/hosts/common/features/greetd.nix b/system/modules/programs/greetd.nix similarity index 100% rename from hosts/common/features/greetd.nix rename to system/modules/programs/greetd.nix diff --git a/hosts/common/features/vm.nix b/system/modules/programs/vm.nix similarity index 100% rename from hosts/common/features/vm.nix rename to system/modules/programs/vm.nix diff --git a/system/profiles/laptop/default.nix b/system/profiles/laptop/default.nix new file mode 100644 index 0000000..11881df --- /dev/null +++ b/system/profiles/laptop/default.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: +let + cfg = config.system.profile.laptop; +in +{ + imports = [ + ../modules + ]; + config = cfg.enable { + system = { + hardware = { + bluetooth.enable = true; + powerSettings.enable = true + backlight.enable = true; + }; + }; + }; +} diff --git a/hosts/common/user/ooks/default.nix b/system/user/ooks/default.nix similarity index 85% rename from hosts/common/user/ooks/default.nix rename to system/user/ooks/default.nix index 6933319..c42cf63 100644 --- a/hosts/common/user/ooks/default.nix +++ b/system/user/ooks/default.nix @@ -20,8 +20,4 @@ in }; home-manager.users.ooks = import ../../../../home/user/ooks/${config.networking.hostName}; - - services.geoclue2.enable = true; - security.pam.services = { swaylock = { }; }; - }