nixos-figurine/flake.nix
2024-12-09 19:25:38 -06:00

88 lines
2.2 KiB
Nix

{
description = "figureine";
inputs = {
nixpkgs = {
url = "nixpkgs/nixos-24.11";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem
(
system: let
pkgs = import nixpkgs {
inherit system;
};
in {
packages = {
figurine = let
pname = "figurine";
version = "1.3.0";
hash = "sha256-1q6Y7oEntd823nWosMcKXi6c3iWsBTxPnSH4tR6+XYs=";
vendorHash = "sha256-mLdAaYkQH2RHcZft27rDW1AoFCWKiUZhh2F0DpqZELw=";
src = pkgs.fetchFromGitHub {
inherit hash;
owner = "arsham";
repo = pname;
rev = "refs/tags/v${version}";
};
in
pkgs.buildGoModule {
inherit pname src version vendorHash;
meta = {
description = "";
homepage = "";
changelog = "";
license = pkgs.lib.licenses.asl20;
mainProgram = pname;
};
};
};
}
)
// {
nixosModules.figurine = {
config,
lib,
pkgs,
...
}: let
cfg = config.services.figurine;
in {
options = {
services.figurine = lib.mkOption {
type = lib.types.submodule {
options = {
enable = lib.mkEnableOption "Enable figurine";
};
};
};
};
config = lib.mkIf cfg.enable {
environment.etc = {
"fish/conf.d/figurine.fish".text = ''
status is-login; and begin
${self.packages.${pkgs.system}.figurine}/bin/figurine --font 3d.flf ${config.networking.hostName}
end
'';
};
programs.bash.interactiveShellInit = ''
if [ $SHLVL -eq 1 ]
then
${self.packages.${pkgs.system}.figurine}/bin/figurine --font 3d.flf ${config.networking.hostName}
fi
'';
};
};
};
}