Compare commits
3 Commits
f08e634bd0
...
9e621aea66
Author | SHA1 | Date |
---|---|---|
Tim Van Baak | 9e621aea66 | |
Tim Van Baak | e16e492695 | |
Tim Van Baak | de23766af9 |
|
@ -2,11 +2,14 @@
|
|||
|
||||
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
|
||||
|
||||
The defaultPackage output of this repository's flake is a derivation containing the motd files in this repository.
|
||||
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
|
||||
```
|
||||
|
||||
## sources
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1640223855,
|
||||
"narHash": "sha256-2bOGDrou/P0E85O5CzcZcHrvDBR78kRIwSPMlaLnFb8=",
|
||||
"lastModified": 1721369373,
|
||||
"narHash": "sha256-KomTFhD1yPKYvU7cqJGBRyQACfmGJMMkUWJpvw3K7B8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e7f5c0a08e442ed5772852b9f832d5d716020ebf",
|
||||
"rev": "9d5188abf958325668881e99aa74866b69214639",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
55
flake.nix
55
flake.nix
|
@ -1,38 +1,39 @@
|
|||
{
|
||||
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 }:
|
||||
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:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue