nixos-figurine/flake.nix
2023-12-03 10:17:55 -06:00

89 lines
2.2 KiB
Nix

{
description = "figureine";
inputs = {
nixpkgs = {
url = "nixpkgs/nixos-unstable";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
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.buildGo121Module {
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
'';
};
};
};
}