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 ? "",
docker ? false,
hostModules ? [],
}: let
# System architecture.
}:
{
nixosConfigurations.${hostname} = nixosSystem rec {
# 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;
@ -39,37 +32,18 @@ with inputs.nixpkgs.lib; {
];
};
# Import my overlay.
# Import my 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 = {
# 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";

View file

@ -1,19 +1,13 @@
{
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.
@ -37,33 +31,18 @@ with inputs;
## Unstable channel. ##
protonmail-desktop = pkgs-unstable.protonmail-desktop; # Protonmail desktop client.
rockbox-utility = pkgs-unstable.rockbox-utility; # Rockbox installer.
protonmail-desktop = pkgs-unstable.protonmail-desktop;
rockbox-utility = pkgs-unstable.rockbox-utility;
# Fluffychat.
fluffychat =
(pkgs-unstable
// {
overlay = [
(final: prev: {
fluffychat = prev.fluffychat.overrideAttrs (prevAttrs: {
fluffychat = pkgs-unstable.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 {
feishin = pkgs-pr-feishin.feishin.overrideAttrs (prevAttrs: rec {
pname = "feishin";
version = "0.18.0";
@ -79,9 +58,6 @@ with inputs;
hash = "sha256-1MGxrUcfvazxAubaYAsQuulUKm05opWOIC7oaLzjr7o=";
};
});
})
];
}).feishin;
## Modifications ##
@ -118,4 +94,4 @@ with inputs;
};
};
};
}
}