From cab6072bd8a60a7b46edfc2c7cf2eca07aec7f06 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 22 Dec 2021 18:15:44 -0800 Subject: [PATCH] Add nix flake support --- README.md | 11 +++++++++-- flake.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 6e2a06b..049f52b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ Repository of lists of one-liners to use as a message-of-the-day. -`boi-rebirth-fortunes.txt` is taken from The Binding of Isaac: Rebirth. +## flake + +The defaultPackage output of this repository's flake is a derivation containing the motd files in this repository. + +## sources + +* `boi-rebirth-fortunes.txt` is taken from the Fortune Telling Machine messages from The Binding of Isaac: Rebirth. + +* `40k-thought-for-the-day.txt` is sourced from 40k Lexicanum. -`40k-thought-for-the-day.txt` is sourced from 40k Lexicanum. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..06fa618 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1640223855, + "narHash": "sha256-2bOGDrou/P0E85O5CzcZcHrvDBR78kRIwSPMlaLnFb8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e7f5c0a08e442ed5772852b9f832d5d716020ebf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e8ddf44 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "A flake of MOTD files."; + + 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; + }; + 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))} + ''; + }; + in + { + defaultPackage = motd; + } + ); +}