initial flake setup
This commit is contained in:
commit
3184f1f8db
2 changed files with 114 additions and 0 deletions
87
flake.nix
Normal file
87
flake.nix
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
description = "A very basic flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
overlay =
|
||||
final: pkgs:
|
||||
(packages pkgs)
|
||||
// lib.attrsets.mapAttrs' (name: value: {
|
||||
name = "jellyfin-plugin-${name}";
|
||||
inherit value;
|
||||
}) (plugins final);
|
||||
|
||||
pkgs' = pkgs: pkgs.extend overlay;
|
||||
|
||||
per-pkgs = fn: builtins.mapAttrs (_: fn) nixpkgs.legacyPackages;
|
||||
scan =
|
||||
base: fn:
|
||||
let
|
||||
fold =
|
||||
acc: entry: kind:
|
||||
let
|
||||
name = lib.strings.removeSuffix ".nix" entry;
|
||||
attr = lib.optionalAttrs (lib.strings.hasSuffix ".nix" entry) {
|
||||
${name} = fn name "${base}/${entry}";
|
||||
};
|
||||
in
|
||||
acc // attr;
|
||||
files = lib.optionalAttrs (builtins.pathExists base) (builtins.readDir base);
|
||||
in
|
||||
lib.attrsets.foldlAttrs fold { } files;
|
||||
|
||||
packages =
|
||||
pkgs: scan ./package (name: def: (pkgs' pkgs).callPackage def { original = pkgs.${name} or null; });
|
||||
plugins =
|
||||
pkgs:
|
||||
let
|
||||
base = ./plugin;
|
||||
result = lib.attrsets.foldlAttrs (
|
||||
acc: name: kind:
|
||||
acc
|
||||
// lib.optionalAttrs (kind == "directory") {
|
||||
${name} = (pkgs' pkgs).jellyfin.plugin (base + "/${name}") { };
|
||||
}
|
||||
) { } (builtins.readDir base);
|
||||
in
|
||||
if builtins.pathExists base then result else { };
|
||||
|
||||
module = defs: {
|
||||
imports = lib.toList defs;
|
||||
config.nixpkgs.overlays = [ overlay ];
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
overlays.default = overlay;
|
||||
|
||||
packages = per-pkgs (
|
||||
pkgs:
|
||||
(packages pkgs)
|
||||
// lib.attrsets.mapAttrs' (name: value: {
|
||||
name = "plugin-${name}";
|
||||
inherit value;
|
||||
}) (plugins pkgs)
|
||||
);
|
||||
|
||||
nixosModules =
|
||||
let
|
||||
modules = scan ./module (
|
||||
_: def: {
|
||||
config.nixpkgs.overlays = [ overlay ];
|
||||
imports = [ def ];
|
||||
}
|
||||
);
|
||||
in
|
||||
{ default.imports = builtins.attrValues modules; } // modules;
|
||||
|
||||
formatter = per-pkgs ({ nixfmt-tree, ... }: nixfmt-tree);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue