Open hacker1024 opened 2 years ago
I managed to package it, the only issue is, that it's just a static site basically? It doesn't have a binary or anything. What would you like to do with it?
I was thinking about trying out homer
too. Please post if you don't mind 👍
Again, it is just a static site with html/js/css, you can get it already built from homer's releases on github. It does not have a binary. Take a look at this: https://github.com/pborzenkov/nix-config/blob/master/nixos/machines/rock/dashboard.nix
Oh I thought you had to "build" it with your custom yaml
file. Is that yaml
file read at runtime?
I believe it is, yes.
Oh... lol. Since fetchzip
exists so we'll consider this "packaged" already.
@hacker1024 please feel free to ping if you need a hand running this at all.
i agree, that using fetchzip
is simple, but on the other hand the application has to be updated by yourself manually every now and then.
i would welcome this as a package in nixpkgs. Therefore I will reopen it.
Does anyone have any advice on how to get this working? I looked at the linked repo but I had trouble replicating their setup: I am new to nixos and haven't messed around much with custom derivations yet so I assume I am missing some crucial step (I could not get around a "the option 'pkgs' does not exist" error.)
@aanderse are you still offering help with this?
Perfect timing @estaroc - I just got round to setting this up yesterday. This is my WIP Homer derivation and setup. Once I'm happy with it, I'll submit a PR to Nixpkgs, but I'm not 100% sure I like the API yet. Suggestions are welcome! Regardless, it should be enough to get you started for now.
First, the Homer derivation. Unlike other solutions online, this uses symlinkJoin
for adding assets, allowing the base Homer derivation to remain unmodified during use, and depending on no special Web server setup.
pkgs/homer.nix
{ lib, fetchzip, writeTextFile, runCommandLocal, symlinkJoin }:
let
homer = fetchzip rec {
pname = "homer";
version = "22.11.2";
url =
"https://github.com/bastienwirtz/${pname}/releases/download/v${version}/${pname}.zip";
hash = "sha256-kqD7hm4W51MTSxiYd+6O8Dbnf3c3E60av7x0HYVcAPQ=";
stripRoot = false;
passthru = {
withAssets = { name ? null, config, extraAssets ? [ ] }:
let nameSuffix = lib.optionalString (name != null) "-${name}";
in symlinkJoin {
name = "homer-root${nameSuffix}";
paths = [
homer
(writeTextFile {
name = "homer-configuration${nameSuffix}";
text = builtins.toJSON config;
destination = "/assets/config.yml";
})
] ++ lib.optional (extraAssets != [ ])
(runCommandLocal "homer-assets${nameSuffix}" { }
(builtins.concatStringsSep "\n" (map (asset: ''
mkdir -p $out/assets/${dirOf asset}
ln -s ${asset} $out/assets/${asset}
'') extraAssets)));
};
};
};
in homer
Next, the derivation can be added in a Nixpkgs overlay, like so:
configuration.nix
{
nixpkgs.overlays = [
(self: super: {
homer = super.callPackage ./pkgs/homer { };
})
];
}
Finally, you can create a customized Homer derivation like so. This can then be used as a directory root for a Web server.
pkgs.homer.withAssets {
name = "homelab";
config = {
/* https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md */
};
extraAssets = [
/* Any extra assets (such as icons) to include.
/* These can be referenced through "assets/" in the Homer configuration. */
];
}
for the config it might be nice to have the options with something like: https://github.com/Stunkymonkey/nixos/blob/master/modules/services/homer/config.nix
Oh... lol. Since fetchzip exists so we'll consider this "packaged" already.
It would be nice to build this properly from source, to allow easy modifications. This is tricky at the moment, though, as it's a non-binary Yarn project and there's not much support for this in Nixpkgs.
Just tried this myself. For anybody else, Homer has recently switched to pnpm, and so you'll want a script like this:
{ lib
, fetchFromGitHub
, pnpm
, nodejs
, pkgs
, config ? {}
}:
let
formatYaml = pkgs.formats.yaml { };
yaml-conf = formatYaml.generate "config.yml" config;
in pkgs.stdenv.mkDerivation rec {
pname = "homer";
version = "24.10.1";
src = fetchFromGitHub {
owner = "bastienwirtz";
repo = "homer";
rev = "v${version}";
hash = "sha256-9OuX32p9eEmyR7af8rIRYUvc1wmmgrYfJXsmChV9D+k=";
};
pnpmDeps = pnpm.fetchDeps {
inherit pname version src patches;
hash = "sha256-5unoY8lPaX9sZAJEBICpxSddwLV8liK1tbamB2ulvew=";
};
patches = [ ./sass-embedded.patch ];
nativeBuildInputs = with pkgs; [
nodejs
dart-sass
pnpm.configHook
];
buildPhase = ''
runHook preBuild
export SASS_EMBEDDED_BIN_PATH="${pkgs.dart-sass}/bin/sass"
pnpm build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -R dist/* $out/
cp -r ${yaml-conf} $out/assets/config.yml
runHook postInstall
'';
}
Project description
Homer is a homepage to link to other hosted services. As the configuration is all done in YAML, it shouldn't be too hard to represent in a Nix derivation.
Metadata