Refactor to symlinkJoin with passthru

This commit is contained in:
Tim Van Baak 2024-07-18 23:34:25 -07:00
parent de23766af9
commit e16e492695
5 changed files with 17 additions and 20 deletions

View File

@ -10,33 +10,30 @@
nixpkgs,
flake-utils,
}:
let
motdFiles = {
"40k" = ./40k-thought-for-the-day.txt;
rebirth = ./boi-rebirth-fortunes.txt;
bofh = ./bofh-excuses.txt;
discordium = ./discordium.txt;
};
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
motd = pkgs.stdenv.mkDerivation {
pname = "motd";
version = "1.0";
builder = builtins.toFile "motd-builder.sh" ''
source $stdenv/setup
mkdir -p $out
${builtins.foldl' (a: b: "${a}\n${b}") "" (
map (attr: "cp ${motdFiles.${attr}} $out/${attr}.txt") (builtins.attrNames motdFiles)
)}
'';
};
inherit (pkgs) symlinkJoin;
in
{
defaultPackage = motd;
formatter = pkgs.nixfmt-rfc-style;
packages.default = self.packages.${system}.motd;
packages.motd = symlinkJoin {
name = "motd";
paths = [ ./motd ];
passthru =
let
motd = "${self.packages.${system}.motd}";
in
{
"40k" = "${motd}/40k-thought-for-the-day.txt";
rebirth = "${motd}/boi-rebirth-fortunes.txt";
bofh = "${motd}/bofh-excuses.txt";
discordium = "${motd}/discordium.txt";
};
};
}
);
}