Compare commits

..

No commits in common. "9e621aea661862a30055dd991e9a616eeb92e12b" and "f08e634bd09be51c30ebb69a849b694bc3f45544" have entirely different histories.

7 changed files with 33 additions and 37 deletions

View File

@ -2,14 +2,11 @@
Repository of lists of one-liners to use as a message-of-the-day.
This repository was a learning exercise; this is not a good example to follow of how to distribute text files with Nix.
## flake
Package `motd` is a folder of the MOTD files in `motd/`. Each file's path is also accessible as a passthru attribute on the package.
```
$ nix eval --raw .#motd.rebirth
/nix/store/ikp1hxb1hrzific5wyghm2lvzv27qqxp-motd/boi-rebirth-fortunes.txt
```
The defaultPackage output of this repository's flake is a derivation containing the motd files in this repository.
## sources

View File

@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1721369373,
"narHash": "sha256-KomTFhD1yPKYvU7cqJGBRyQACfmGJMMkUWJpvw3K7B8=",
"lastModified": 1640223855,
"narHash": "sha256-2bOGDrou/P0E85O5CzcZcHrvDBR78kRIwSPMlaLnFb8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9d5188abf958325668881e99aa74866b69214639",
"rev": "e7f5c0a08e442ed5772852b9f832d5d716020ebf",
"type": "github"
},
"original": {

View File

@ -1,39 +1,38 @@
{
description = "A flake of MOTD files.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = github:NixOS/nixpkgs;
inputs.flake-utils.url = github:numtide/flake-utils;
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
outputs = { self, 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};
inherit (pkgs) symlinkJoin;
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))}
'';
};
in
{
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";
};
};
defaultPackage = motd;
}
);
}