From e16e492695feaa10e161b6bf24930a2dae1be094 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 18 Jul 2024 23:34:25 -0700 Subject: [PATCH] Refactor to symlinkJoin with passthru --- flake.nix | 37 +++++++++---------- .../40k-thought-for-the-day.txt | 0 bofh-excuses.txt => motd/bofh-excuses.txt | 0 .../boi-rebirth-fortunes.txt | 0 discordium.txt => motd/discordium.txt | 0 5 files changed, 17 insertions(+), 20 deletions(-) rename 40k-thought-for-the-day.txt => motd/40k-thought-for-the-day.txt (100%) rename bofh-excuses.txt => motd/bofh-excuses.txt (100%) rename boi-rebirth-fortunes.txt => motd/boi-rebirth-fortunes.txt (100%) rename discordium.txt => motd/discordium.txt (100%) diff --git a/flake.nix b/flake.nix index 40242d0..70fad4e 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; + }; + }; } ); } diff --git a/40k-thought-for-the-day.txt b/motd/40k-thought-for-the-day.txt similarity index 100% rename from 40k-thought-for-the-day.txt rename to motd/40k-thought-for-the-day.txt diff --git a/bofh-excuses.txt b/motd/bofh-excuses.txt similarity index 100% rename from bofh-excuses.txt rename to motd/bofh-excuses.txt diff --git a/boi-rebirth-fortunes.txt b/motd/boi-rebirth-fortunes.txt similarity index 100% rename from boi-rebirth-fortunes.txt rename to motd/boi-rebirth-fortunes.txt diff --git a/discordium.txt b/motd/discordium.txt similarity index 100% rename from discordium.txt rename to motd/discordium.txt