Refactor helpers & overlay

This commit is contained in:
Fern Garden 2025-08-26 09:53:37 +08:00
parent d19c81dfb4
commit 7417d91809
2 changed files with 136 additions and 171 deletions

View file

@ -12,19 +12,12 @@ with inputs.nixpkgs.lib; {
suite ? "", suite ? "",
docker ? false, docker ? false,
hostModules ? [], hostModules ? [],
}: let }:
# System architecture. {
nixosConfigurations.${hostname} = nixosSystem rec {
# Architecture.
system = platform; 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. # nixpkgs config.
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
@ -39,37 +32,18 @@ with inputs.nixpkgs.lib; {
]; ];
}; };
# Import my overlay. # Import my overlays.
overlays = [ overlays = [
(import ./overlay.nix {inherit inputs system;}) (import ./overlay.nix {inherit nixpkgs-unstable nixpkgs-pr-feishin;})
]; ];
}; };
# 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;
specialArgs = { specialArgs = {
# Make some variables accesible to modules. # Pass hostname & inputs to config.
inherit inherit inputs hostname;
inputs
hostname # Secrets directory.
secrets secrets = builtins.toString inputs.secrets;
;
}; };
modules = 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) { // 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"; hostname = "${hostname}.local";
profiles.system = { profiles.system = {
user = "root"; user = "root";

View file

@ -1,19 +1,13 @@
{ {
inputs, nixpkgs-unstable,
system, nixpkgs-pr-feishin,
... ...
}: }: final: prev: let
with inputs; pkgs-unstable = import nixpkgs-unstable {inherit (prev) config system;};
final: prev: let pkgs-pr-feishin = import nixpkgs-pr-feishin {inherit (prev) config system;};
pkgsConfig = {
inherit system;
config.allowUnfree = true;
};
pkgs-unstable = import nixpkgs-unstable pkgsConfig;
pkgs-pr-feishin = import nixpkgs-pr-feishin pkgsConfig;
in { in {
# My packages. ## My packages ##
webone = prev.pkgs.callPackage ./packages/webone {}; # WebOne HTTP proxy. 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. 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. cups-dymo = prev.pkgs.callPackage ./packages/cups-dymo {}; # Dymo label printer drivers.
@ -37,33 +31,18 @@ with inputs;
## Unstable channel. ## ## Unstable channel. ##
protonmail-desktop = pkgs-unstable.protonmail-desktop; # Protonmail desktop client. protonmail-desktop = pkgs-unstable.protonmail-desktop;
rockbox-utility = pkgs-unstable.rockbox-utility; # Rockbox installer. rockbox-utility = pkgs-unstable.rockbox-utility;
# Fluffychat. fluffychat = pkgs-unstable.fluffychat.overrideAttrs (prevAttrs: {
fluffychat =
(pkgs-unstable
// {
overlay = [
(final: prev: {
fluffychat = prev.fluffychat.overrideAttrs (prevAttrs: {
desktopItems = [ desktopItems = [
((builtins.elemAt prevAttrs.desktopItems 0).override {startupWMClass = "fluffychat";}) ((builtins.elemAt prevAttrs.desktopItems 0).override {startupWMClass = "fluffychat";})
]; ];
}); });
})
];
}).fluffychat;
## Pull requests. ## ## Pull requests. ##
# Feishin music player. feishin = pkgs-pr-feishin.feishin.overrideAttrs (prevAttrs: rec {
feishin =
(pkgs-pr-feishin
// {
overlay = [
(final: prev: {
feishin = prev.feishin.overrideAttrs (prevAttrs: rec {
pname = "feishin"; pname = "feishin";
version = "0.18.0"; version = "0.18.0";
@ -79,9 +58,6 @@ with inputs;
hash = "sha256-1MGxrUcfvazxAubaYAsQuulUKm05opWOIC7oaLzjr7o="; hash = "sha256-1MGxrUcfvazxAubaYAsQuulUKm05opWOIC7oaLzjr7o=";
}; };
}); });
})
];
}).feishin;
## Modifications ## ## Modifications ##