From 7417d918095fb4041e5e794bdbb231ca0cb1e20f Mon Sep 17 00:00:00 2001 From: Fern Garden Date: Tue, 26 Aug 2025 09:53:37 +0800 Subject: [PATCH] Refactor helpers & overlay --- helpers.nix | 103 ++++++++++++-------------- overlay.nix | 204 +++++++++++++++++++++++----------------------------- 2 files changed, 136 insertions(+), 171 deletions(-) diff --git a/helpers.nix b/helpers.nix index 3d43a25..7856d87 100644 --- a/helpers.nix +++ b/helpers.nix @@ -12,64 +12,38 @@ with inputs.nixpkgs.lib; { suite ? "", docker ? false, hostModules ? [], - }: let - # System architecture. - system = platform; - - # Secrets directory. - secrets = builtins.toString inputs.secrets; - - # Extra modules to import. - extraModules = - hostModules # Host-specific modules. - ++ optionals (docker == true) [./suites/server/docker] # Enable docker if required. - ++ (filesystem.listFilesRecursive ./modules); # Custom modules. - - # nixpkgs config. - pkgs = import nixpkgs { - inherit system; - - config = { - # Allow installation of proprietary software. - allowUnfree = true; - # Allow the installation of packages marked as insecure in nixpkgs. - permittedInsecurePackages = [ - "dotnet-sdk-6.0.428" # For WebOne. - "dotnet-runtime-6.0.36" # For WebOne. - ]; - }; - - # Import my overlay. - overlays = [ - (import ./overlay.nix {inherit inputs system;}) - ]; - }; - - # deploy-rs overlay. - deployPkgs = import nixpkgs { - inherit system; - overlays = [ - deploy-rs.overlays.default - (self: super: { - deploy-rs = { - inherit (pkgs) deploy-rs; - lib = super.deploy-rs.lib; - }; - }) - ]; - }; - in + }: { - nixosConfigurations.${hostname} = nixosSystem { - inherit system pkgs; + nixosConfigurations.${hostname} = nixosSystem rec { + # Architecture. + system = platform; + + # nixpkgs config. + pkgs = import nixpkgs { + inherit system; + + config = { + # Allow installation of proprietary software. + allowUnfree = true; + # Allow the installation of packages marked as insecure in nixpkgs. + permittedInsecurePackages = [ + "dotnet-sdk-6.0.428" # For WebOne. + "dotnet-runtime-6.0.36" # For WebOne. + ]; + }; + + # Import my overlays. + overlays = [ + (import ./overlay.nix {inherit nixpkgs-unstable nixpkgs-pr-feishin;}) + ]; + }; specialArgs = { - # Make some variables accesible to modules. - inherit - inputs - hostname - secrets - ; + # Pass hostname & inputs to config. + inherit inputs hostname; + + # Secrets directory. + secrets = builtins.toString inputs.secrets; }; modules = @@ -105,11 +79,26 @@ with inputs.nixpkgs.lib; { }; } ] - ++ extraModules; + ++ hostModules # Host-specific modules. + ++ optionals (docker == true) [./suites/server/docker] # Enable docker if required. + ++ (filesystem.listFilesRecursive ./modules); # Custom modules. }; } // optionalAttrs (strings.hasPrefix "server" suite) { - deploy.nodes.${hostname} = { + deploy.nodes.${hostname} = let + deployPkgs = import nixpkgs { + inherit system; + overlays = [ + deploy-rs.overlays.default + (self: super: { + deploy-rs = { + inherit (pkgs) deploy-rs; + lib = super.deploy-rs.lib; + }; + }) + ]; + }; + in { hostname = "${hostname}.local"; profiles.system = { user = "root"; diff --git a/overlay.nix b/overlay.nix index 195692d..2074b57 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,121 +1,97 @@ { - inputs, - system, + nixpkgs-unstable, + nixpkgs-pr-feishin, ... -}: -with inputs; - final: prev: let - pkgsConfig = { - inherit system; - config.allowUnfree = true; - }; +}: final: prev: let + pkgs-unstable = import nixpkgs-unstable {inherit (prev) config system;}; + pkgs-pr-feishin = import nixpkgs-pr-feishin {inherit (prev) config system;}; +in { + ## My packages ## - pkgs-unstable = import nixpkgs-unstable pkgsConfig; - pkgs-pr-feishin = import nixpkgs-pr-feishin pkgsConfig; - in { - # My packages. - webone = prev.pkgs.callPackage ./packages/webone {}; # WebOne HTTP proxy. - yazi-flavour-kanagawa-dragon = prev.pkgs.callPackage ./packages/yazi-flavour-kanagawa-dragon {}; # Kanagawa theme for yazi. - cups-dymo = prev.pkgs.callPackage ./packages/cups-dymo {}; # Dymo label printer drivers. + webone = prev.pkgs.callPackage ./packages/webone {}; # WebOne HTTP proxy. + yazi-flavour-kanagawa-dragon = prev.pkgs.callPackage ./packages/yazi-flavour-kanagawa-dragon {}; # Kanagawa theme for yazi. + cups-dymo = prev.pkgs.callPackage ./packages/cups-dymo {}; # Dymo label printer drivers. - # Kanagawa Dragon theme for tmux. - tmuxPlugins = - prev.tmuxPlugins - // { - kanagawa = prev.tmuxPlugins.mkTmuxPlugin { - pluginName = "kanagawa"; - rtpFilePath = "kanagawa.tmux"; - version = "2025-06-01"; - src = prev.fetchFromGitHub { - owner = "Nybkox"; - repo = "tmux-kanagawa"; - rev = "9124a8887587f784aaec94b97631255a4e70b8a0"; - hash = "sha256-ZueH5KjPD0SaReuWJOq1FGpjEFXg216BzeXL64o74MU="; - }; - }; - }; - - ## Unstable channel. ## - - protonmail-desktop = pkgs-unstable.protonmail-desktop; # Protonmail desktop client. - rockbox-utility = pkgs-unstable.rockbox-utility; # Rockbox installer. - - # Fluffychat. - fluffychat = - (pkgs-unstable - // { - overlay = [ - (final: prev: { - fluffychat = prev.fluffychat.overrideAttrs (prevAttrs: { - desktopItems = [ - ((builtins.elemAt prevAttrs.desktopItems 0).override {startupWMClass = "fluffychat";}) - ]; - }); - }) - ]; - }).fluffychat; - - ## Pull requests. ## - - # Feishin music player. - feishin = - (pkgs-pr-feishin - // { - overlay = [ - (final: prev: { - feishin = prev.feishin.overrideAttrs (prevAttrs: rec { - pname = "feishin"; - version = "0.18.0"; - - src = prev.fetchFromGitHub { - owner = "jeffvli"; - repo = "feishin"; - rev = "v${version}"; - hash = "sha256-4gcS7Vd7LSpEByO2Hlk6nb8V2adBPh5XwWGCu2lwOA4="; - }; - - pnpmDeps = prev.pnpm_10.fetchDeps { - inherit pname version src; - hash = "sha256-1MGxrUcfvazxAubaYAsQuulUKm05opWOIC7oaLzjr7o="; - }; - }); - }) - ]; - }).feishin; - - ## Modifications ## - - # PrismLauncher with Temurin JRE; - prismlauncher = prev.prismlauncher.override { - jdks = [ - prev.pkgs.temurin-jre-bin - ]; - }; - - # Custom iosevka build. - iosevka = prev.iosevka.override { - set = "Custom"; - - privateBuildPlan = { - family = "IosevkaCustom"; - spacing = "term"; - serifs = "sans"; - noCvSs = false; - exportGlyphNames = true; - variants.inherits = "ss05"; - - weights = { - Regular = { - shape = 400; - menu = 400; - css = 400; - }; - Bold = { - shape = 700; - menu = 700; - css = 700; - }; + # Kanagawa Dragon theme for tmux. + tmuxPlugins = + prev.tmuxPlugins + // { + kanagawa = prev.tmuxPlugins.mkTmuxPlugin { + pluginName = "kanagawa"; + rtpFilePath = "kanagawa.tmux"; + version = "2025-06-01"; + src = prev.fetchFromGitHub { + owner = "Nybkox"; + repo = "tmux-kanagawa"; + rev = "9124a8887587f784aaec94b97631255a4e70b8a0"; + hash = "sha256-ZueH5KjPD0SaReuWJOq1FGpjEFXg216BzeXL64o74MU="; }; }; }; - } + + ## Unstable channel. ## + + protonmail-desktop = pkgs-unstable.protonmail-desktop; + rockbox-utility = pkgs-unstable.rockbox-utility; + + fluffychat = pkgs-unstable.fluffychat.overrideAttrs (prevAttrs: { + desktopItems = [ + ((builtins.elemAt prevAttrs.desktopItems 0).override {startupWMClass = "fluffychat";}) + ]; + }); + + ## Pull requests. ## + + feishin = pkgs-pr-feishin.feishin.overrideAttrs (prevAttrs: rec { + pname = "feishin"; + version = "0.18.0"; + + src = prev.fetchFromGitHub { + owner = "jeffvli"; + repo = "feishin"; + rev = "v${version}"; + hash = "sha256-4gcS7Vd7LSpEByO2Hlk6nb8V2adBPh5XwWGCu2lwOA4="; + }; + + pnpmDeps = prev.pnpm_10.fetchDeps { + inherit pname version src; + hash = "sha256-1MGxrUcfvazxAubaYAsQuulUKm05opWOIC7oaLzjr7o="; + }; + }); + + ## Modifications ## + + # PrismLauncher with Temurin JRE; + prismlauncher = prev.prismlauncher.override { + jdks = [ + prev.pkgs.temurin-jre-bin + ]; + }; + + # Custom iosevka build. + iosevka = prev.iosevka.override { + set = "Custom"; + + privateBuildPlan = { + family = "IosevkaCustom"; + spacing = "term"; + serifs = "sans"; + noCvSs = false; + exportGlyphNames = true; + variants.inherits = "ss05"; + + weights = { + Regular = { + shape = 400; + menu = 400; + css = 400; + }; + Bold = { + shape = 700; + menu = 700; + css = 700; + }; + }; + }; + }; +}