45 lines
1.2 KiB
Nix
45 lines
1.2 KiB
Nix
{
|
|
description = "Nix flake for the activity logging script";
|
|
outputs =
|
|
{ nixpkgs, ... }:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = import nixpkgs { inherit system; };
|
|
generatePackages =
|
|
args:
|
|
let
|
|
inherit (args) dir ext handler;
|
|
in
|
|
./${dir}
|
|
|> builtins.readDir
|
|
|> builtins.attrNames
|
|
|> builtins.filter (file: builtins.match ".*\\.${ext}$" file != null)
|
|
|> builtins.map (file: rec {
|
|
name = builtins.replaceStrings [ ".${ext}" ] [ "" ] file;
|
|
value = handler ./${dir}/${file} name;
|
|
})
|
|
|> builtins.listToAttrs;
|
|
in
|
|
{
|
|
packages.x86_64-linux =
|
|
let
|
|
scriptBin = path: name: pkgs.writeScriptBin name (builtins.readFile path);
|
|
in
|
|
generatePackages {
|
|
dir = "pkgs";
|
|
ext = "nix";
|
|
handler = (path: name: pkgs.callPackage path { });
|
|
}
|
|
// generatePackages {
|
|
dir = "src/scripts";
|
|
ext = "sh";
|
|
handler = scriptBin;
|
|
}
|
|
// generatePackages {
|
|
dir = "src/scripts";
|
|
ext = "py";
|
|
handler = scriptBin;
|
|
};
|
|
};
|
|
}
|