diff --git a/common/autoUpgrade.nix b/common/autoUpgrade.nix new file mode 100644 index 00000000..1edb3e9d --- /dev/null +++ b/common/autoUpgrade.nix @@ -0,0 +1,23 @@ +{ + config, + lib, + ... +}: { + environment.variables.FLAKE = lib.mkDefault "github:alyraffauf/nixcfg"; + + system.autoUpgrade = { + enable = true; + allowReboot = false; + dates = "02:00"; + flags = ["--accept-flake-config"]; + flake = config.environment.variables.FLAKE; + operation = "switch"; + persistent = true; + randomizedDelaySec = "30min"; + + rebootWindow = { + lower = "02:00"; + upper = "06:00"; + }; + }; +} diff --git a/baseModules/default.nix b/common/base.nix similarity index 52% rename from baseModules/default.nix rename to common/base.nix index 851f3947..3f9e8e9d 100644 --- a/baseModules/default.nix +++ b/common/base.nix @@ -1,11 +1,5 @@ -self: {lib, ...}: { - boot = { - consoleLogLevel = 0; - initrd.verbose = false; - loader.systemd-boot.configurationLimit = lib.mkDefault 10; - plymouth.enable = true; - }; - +{lib, ...}: { + boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10; console.useXkbConfig = true; hardware.keyboard.qmk.enable = true; @@ -18,28 +12,7 @@ self: {lib, ...}: { nh.enable = true; }; - nix = { - gc = { - automatic = true; - dates = "daily"; - options = "--delete-older-than 3d"; - persistent = true; - randomizedDelaySec = "60min"; - }; - - # Run GC when there is less than 100MiB left. - extraOptions = '' - min-free = ${toString (100 * 1024 * 1024)} - max-free = ${toString (1024 * 1024 * 1024)} - ''; - - optimise.automatic = true; - - settings = { - auto-optimise-store = false; - experimental-features = ["nix-command" "flakes"]; - }; - }; + networking.networkmanager.enable = true; security = { polkit.enable = true; @@ -70,9 +43,6 @@ self: {lib, ...}: { openFirewall = true; settings.PasswordAuthentication = false; }; - - printing.enable = true; - system-config-printer.enable = true; }; sound.enable = true; diff --git a/hosts/common/locale.nix b/common/locale.nix similarity index 100% rename from hosts/common/locale.nix rename to common/locale.nix diff --git a/common/nix.nix b/common/nix.nix new file mode 100644 index 00000000..a0b2870b --- /dev/null +++ b/common/nix.nix @@ -0,0 +1,37 @@ +{ + nix = { + gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than 3d"; + persistent = true; + randomizedDelaySec = "60min"; + }; + + # Run GC when there is less than 100MiB left. + extraOptions = '' + min-free = ${toString (100 * 1024 * 1024)} + max-free = ${toString (1024 * 1024 * 1024)} + ''; + + optimise.automatic = true; + + settings = { + auto-optimise-store = false; + experimental-features = ["nix-command" "flakes"]; + + substituters = [ + "https://alyraffauf.cachix.org" + "https://cache.nixos.org/" + "https://nix-community.cachix.org" + ]; + + trusted-public-keys = [ + "alyraffauf.cachix.org-1:GQVrRGfjTtkPGS8M6y7Ik0z4zLt77O0N25ynv2gWzDM=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + + trusted-users = ["aly"]; + }; + }; +} diff --git a/common/overlays.nix b/common/overlays.nix new file mode 100644 index 00000000..f727ae66 --- /dev/null +++ b/common/overlays.nix @@ -0,0 +1,32 @@ +{ + pkgs, + self, + ... +}: let + unstable = import self.inputs.nixpkgs-unstable { + system = pkgs.system; + }; +in { + nixpkgs = { + config.allowUnfree = true; # Allow unfree packages + + overlays = [ + (final: prev: { + rofi-bluetooth = + prev.rofi-bluetooth.overrideAttrs + (old: { + version = "unstable-2024-07-25"; + + src = pkgs.fetchFromGitHub { + owner = "alyraffauf"; + repo = old.pname; + rev = "50252e4a9aebe4899a6ef2f7bc11d91b7e4aa8ae"; + sha256 = "sha256-o0Sr3/888L/2KzZZP/EcXx+8ZUzdHB/I/VIeVuJvJks="; + }; + }); + + zed-editor = unstable.zed-editor; + }) + ]; + }; +} diff --git a/common/pkgs.nix b/common/pkgs.nix new file mode 100644 index 00000000..735e2942 --- /dev/null +++ b/common/pkgs.nix @@ -0,0 +1,7 @@ +{ + pkgs, + self, + ... +}: { + environment.systemPackages = (with pkgs; [git inxi python3]) ++ [self.inputs.agenix.packages.${pkgs.system}.default]; +} diff --git a/hosts/common/samba.nix b/common/samba.nix similarity index 62% rename from hosts/common/samba.nix rename to common/samba.nix index ea0f3941..84f9f7ab 100644 --- a/hosts/common/samba.nix +++ b/common/samba.nix @@ -1,8 +1,4 @@ -{ - config, - lib, - ... -}: { +{config, ...}: { fileSystems = let fsType = "cifs"; options = [ @@ -17,19 +13,18 @@ "x-systemd.idle-timeout=60" "x-systemd.mount-timeout=5s" ]; - in - lib.attrsets.optionalAttrs (config.networking.hostName != "mauville") { - "/mnt/Archive" = { - inherit options fsType; - device = "//mauville/Archive"; - }; - - "/mnt/Media" = { - inherit options fsType; - device = "//mauville/Media"; - }; + in { + "/mnt/Archive" = { + inherit options fsType; + device = "//mauville/Archive"; }; + "/mnt/Media" = { + inherit options fsType; + device = "//mauville/Media"; + }; + }; + home-manager.sharedModules = [ { gtk.gtk3.bookmarks = [ diff --git a/common/tailscale.nix b/common/tailscale.nix new file mode 100644 index 00000000..e9a25bc4 --- /dev/null +++ b/common/tailscale.nix @@ -0,0 +1,9 @@ +{config, ...}: { + age.secrets.tailscaleAuthKey.file = ../secrets/tailscale/authKeyFile.age; + + services.tailscale = { + enable = true; + openFirewall = true; + authKeyFile = config.age.secrets.tailscaleAuthKey.path; + }; +} diff --git a/hosts/common/wifi.nix b/common/wifi.nix similarity index 50% rename from hosts/common/wifi.nix rename to common/wifi.nix index fc430882..b3feb8ae 100644 --- a/hosts/common/wifi.nix +++ b/common/wifi.nix @@ -1,4 +1,4 @@ -let +{config, ...}: let mkOpenWiFi = ssid: { connection.id = "${ssid}"; connection.type = "wifi"; @@ -30,11 +30,22 @@ let } ); in { - "Dustin's A54" = mkWPA2WiFi "Dustin's A54" "$DustinsA54PSK"; - "Muchacho Guest" = mkOpenWiFi "Muchacho Guest"; - "Stargate-Discovery" = mkWPA2WiFi "Stargate-Discovery" "$StargateDiscoveryPSK"; - "Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi"; - "WeWorkWiFi" = mkEAPWiFi "WeWorkWiFi" "$WeWorkWiFiIdentity" "$WeWorkWiFiPassword" "mschapv2"; - "javapatron" = mkOpenWiFi "javapatron"; - "wallace" = mkWPA2WiFi "wallace" "$wallacePSK"; + age.secrets.wifi.file = ../secrets/wifi.age; + + networking.networkmanager = { + enable = true; + + ensureProfiles = { + environmentFiles = [config.age.secrets.wifi.path]; + profiles = { + "Dustin's A54" = mkWPA2WiFi "Dustin's A54" "$DustinsA54PSK"; + "javapatron" = mkOpenWiFi "javapatron"; + "Muchacho Guest" = mkOpenWiFi "Muchacho Guest"; + "Stargate-Discovery" = mkWPA2WiFi "Stargate-Discovery" "$StargateDiscoveryPSK"; + "Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi"; + "wallace" = mkWPA2WiFi "wallace" "$wallacePSK"; + "WeWorkWiFi" = mkEAPWiFi "WeWorkWiFi" "$WeWorkWiFiIdentity" "$WeWorkWiFiPassword" "mschapv2"; + }; + }; + }; } diff --git a/flake.nix b/flake.nix index 3d04f570..60e48b33 100644 --- a/flake.nix +++ b/flake.nix @@ -96,7 +96,16 @@ }; nixosModules = { - base = import ./baseModules self; + common-auto-upgrade = import ./common/autoUpgrade.nix; + common-base = import ./common/base.nix; + common-locale = import ./common/locale.nix; + common-mauville-share = import ./common/samba.nix; + common-nix = import ./common/nix.nix; + common-overlays = import ./common/overlays.nix; + common-pkgs = import ./common/pkgs.nix; + common-tailscale = import ./common/tailscale.nix; + common-wifi-profiles = import ./common/wifi.nix; + nixos = import ./nixosModules self; users = import ./userModules self; }; @@ -111,7 +120,6 @@ self.inputs.disko.nixosModules.disko self.inputs.home-manager.nixosModules.home-manager self.inputs.stylix.nixosModules.stylix - self.nixosModules.base self.nixosModules.nixos self.nixosModules.users { diff --git a/hosts/common/default.nix b/hosts/common/default.nix deleted file mode 100644 index 74445105..00000000 --- a/hosts/common/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{pkgs, ...}: { - imports = [ - ./locale.nix - ./network.nix - ./nix.nix - ./samba.nix - ./secrets.nix - ]; - - environment.systemPackages = with pkgs; [git inxi python3]; -} diff --git a/hosts/common/network.nix b/hosts/common/network.nix deleted file mode 100644 index 44f52c67..00000000 --- a/hosts/common/network.nix +++ /dev/null @@ -1,16 +0,0 @@ -{config, ...}: { - networking.networkmanager = { - enable = true; - - ensureProfiles = { - environmentFiles = [config.age.secrets.wifi.path]; - profiles = import ./wifi.nix; - }; - }; - - services.tailscale = { - enable = true; - openFirewall = true; - authKeyFile = config.age.secrets.tailscaleAuthKey.path; - }; -} diff --git a/hosts/common/nix.nix b/hosts/common/nix.nix deleted file mode 100644 index 4af857bd..00000000 --- a/hosts/common/nix.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - config, - lib, - pkgs, - self, - ... -}: let - unstable = import self.inputs.nixpkgs-unstable { - system = pkgs.system; - }; -in { - environment.variables.FLAKE = lib.mkDefault "github:alyraffauf/nixcfg"; - - nix.settings = { - substituters = [ - "https://alyraffauf.cachix.org" - "https://cache.nixos.org/" - "https://nix-community.cachix.org" - ]; - - trusted-public-keys = [ - "alyraffauf.cachix.org-1:GQVrRGfjTtkPGS8M6y7Ik0z4zLt77O0N25ynv2gWzDM=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - - trusted-users = ["aly"]; - }; - - nixpkgs = { - config.allowUnfree = true; # Allow unfree packages - - overlays = [ - (final: prev: { - rofi-bluetooth = - prev.rofi-bluetooth.overrideAttrs - (old: { - version = "unstable-2024-07-25"; - - src = pkgs.fetchFromGitHub { - owner = "alyraffauf"; - repo = old.pname; - rev = "50252e4a9aebe4899a6ef2f7bc11d91b7e4aa8ae"; - sha256 = "sha256-o0Sr3/888L/2KzZZP/EcXx+8ZUzdHB/I/VIeVuJvJks="; - }; - }); - - zed-editor = unstable.zed-editor; - }) - ]; - }; - - system.autoUpgrade = { - enable = true; - allowReboot = false; - dates = "02:00"; - flags = ["--accept-flake-config"]; - flake = config.environment.variables.FLAKE; - operation = "switch"; - persistent = true; - randomizedDelaySec = "30min"; - - rebootWindow = { - lower = "02:00"; - upper = "06:00"; - }; - }; -} diff --git a/hosts/common/secrets.nix b/hosts/common/secrets.nix deleted file mode 100644 index fad264d8..00000000 --- a/hosts/common/secrets.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - pkgs, - self, - ... -}: { - age.secrets = { - tailscaleAuthKey.file = ../../secrets/tailscale/authKeyFile.age; - wifi.file = ../../secrets/wifi.age; - }; - - environment.systemPackages = [self.inputs.agenix.packages.${pkgs.system}.default]; -} diff --git a/hosts/fallarbor/default.nix b/hosts/fallarbor/default.nix index 2a746010..43f4e350 100644 --- a/hosts/fallarbor/default.nix +++ b/hosts/fallarbor/default.nix @@ -6,12 +6,19 @@ ... }: { imports = [ - ../common ./disko.nix ./home.nix ./secrets.nix ./stylix.nix self.inputs.nixhw.nixosModules.framework-13-intel-11th + self.nixosModules.common-auto-upgrade + self.nixosModules.common-base + self.nixosModules.common-mauville-share + self.nixosModules.common-nix + self.nixosModules.common-overlays + self.nixosModules.common-pkgs + self.nixosModules.common-tailscale + self.nixosModules.common-wifi-profiles ]; boot.loader = { diff --git a/hosts/lavaridge/default.nix b/hosts/lavaridge/default.nix index 7b14f1ff..69bb59c1 100644 --- a/hosts/lavaridge/default.nix +++ b/hosts/lavaridge/default.nix @@ -7,12 +7,19 @@ ... }: { imports = [ - ../common ./disko.nix ./home.nix ./secrets.nix ./stylix.nix self.inputs.nixhw.nixosModules.framework-13-amd-7000 + self.nixosModules.common-auto-upgrade + self.nixosModules.common-base + self.nixosModules.common-mauville-share + self.nixosModules.common-nix + self.nixosModules.common-overlays + self.nixosModules.common-pkgs + self.nixosModules.common-tailscale + self.nixosModules.common-wifi-profiles ]; boot = { diff --git a/hosts/mauville/default.nix b/hosts/mauville/default.nix index 38505509..d1b4fed6 100644 --- a/hosts/mauville/default.nix +++ b/hosts/mauville/default.nix @@ -11,7 +11,6 @@ mediaDirectory = "/mnt/Media"; in { imports = [ - ../common ./disko.nix ./home.nix ./secrets.nix @@ -21,6 +20,13 @@ in { self.inputs.nixhw.nixosModules.common-bluetooth self.inputs.nixhw.nixosModules.common-ssd self.inputs.raffauflabs.nixosModules.raffauflabs + self.nixosModules.common-auto-upgrade + self.nixosModules.common-base + self.nixosModules.common-nix + self.nixosModules.common-overlays + self.nixosModules.common-pkgs + self.nixosModules.common-tailscale + self.nixosModules.common-wifi-profiles ]; boot = { diff --git a/hosts/mauville/home.nix b/hosts/mauville/home.nix index 249ad08e..4c3627c4 100644 --- a/hosts/mauville/home.nix +++ b/hosts/mauville/home.nix @@ -7,6 +7,11 @@ home-manager = { sharedModules = [ { + gtk.gtk3.bookmarks = [ + "file:///mnt/Media" + "file:///mnt/Archive" + ]; + wayland.windowManager.sway.config.output = {"LG Electronics LG ULTRAWIDE 311NTAB5M720".scale = "1.25";}; xdg.userDirs.music = "/mnt/Media/Music"; diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index 9e414588..20db74d4 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -5,12 +5,19 @@ ... }: { imports = [ - ../common ./disko.nix ./home.nix ./secrets.nix ./stylix.nix self.inputs.nixhw.nixosModules.lenovo-yoga-9i-intel-13th + self.nixosModules.common-auto-upgrade + self.nixosModules.common-base + self.nixosModules.common-mauville-share + self.nixosModules.common-nix + self.nixosModules.common-overlays + self.nixosModules.common-pkgs + self.nixosModules.common-tailscale + self.nixosModules.common-wifi-profiles ]; boot = { diff --git a/hosts/rustboro/default.nix b/hosts/rustboro/default.nix index c77a930b..e7e20dfa 100644 --- a/hosts/rustboro/default.nix +++ b/hosts/rustboro/default.nix @@ -6,12 +6,19 @@ ... }: { imports = [ - ../common ./disko.nix ./home.nix ./secrets.nix ./stylix.nix self.inputs.nixhw.nixosModules.thinkpad-t440p + self.nixosModules.common-auto-upgrade + self.nixosModules.common-base + self.nixosModules.common-mauville-share + self.nixosModules.common-nix + self.nixosModules.common-overlays + self.nixosModules.common-pkgs + self.nixosModules.common-tailscale + self.nixosModules.common-wifi-profiles ]; boot.loader = { diff --git a/hosts/slateport/default.nix b/hosts/slateport/default.nix index ea8a718a..d0ed022c 100644 --- a/hosts/slateport/default.nix +++ b/hosts/slateport/default.nix @@ -8,7 +8,6 @@ domain = "raffauflabs.com"; in { imports = [ - ../common ./disko.nix ./home.nix ./secrets.nix @@ -18,6 +17,14 @@ in { self.inputs.nixhw.nixosModules.common-bluetooth self.inputs.nixhw.nixosModules.common-ssd self.inputs.raffauflabs.nixosModules.raffauflabs + self.nixosModules.common-auto-upgrade + self.nixosModules.common-base + self.nixosModules.common-mauville-share + self.nixosModules.common-nix + self.nixosModules.common-overlays + self.nixosModules.common-pkgs + self.nixosModules.common-tailscale + self.nixosModules.common-wifi-profiles ]; boot = { diff --git a/nixosModules/desktop/default.nix b/nixosModules/desktop/default.nix index b1471345..0c6a2907 100644 --- a/nixosModules/desktop/default.nix +++ b/nixosModules/desktop/default.nix @@ -17,6 +17,12 @@ || config.ar.desktop.steam.enable || config.ar.desktop.sway.enable ) { + boot = { + consoleLogLevel = 0; + initrd.verbose = false; + plymouth.enable = true; + }; + environment = { sessionVariables.NIXOS_OZONE_WL = "1"; }; @@ -51,6 +57,9 @@ pulse.enable = true; }; + printing.enable = true; + system-config-printer.enable = true; + xserver = { enable = true; excludePackages = with pkgs; [xterm];