wip
This commit is contained in:
parent
4c2f85ad62
commit
794925acb2
15 changed files with 516 additions and 529 deletions
90
flake.nix
90
flake.nix
|
|
@ -2,7 +2,7 @@
|
|||
description = "A very basic flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
|
@ -10,16 +10,6 @@
|
|||
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;
|
||||
|
||||
scan'directory = scan (name: type: if type == "directory" then name else null);
|
||||
scan'regular = scan (name: type: if type == "regular" then name else null);
|
||||
scan'nix =
|
||||
|
|
@ -45,62 +35,42 @@
|
|||
in
|
||||
lib.attrsets.foldlAttrs fold empty files;
|
||||
|
||||
packages =
|
||||
pkgs:
|
||||
let
|
||||
package =
|
||||
name: path:
|
||||
let
|
||||
pkg = pkgs.lib.callPackageWith ((pkgs' pkgs) // { original = pkgs.${name} or null; }) path {};
|
||||
patches = scan (name: type: if lib.strings.removeSuffix ".patch" name != name then name else null) (
|
||||
name: path: path
|
||||
) path;
|
||||
in
|
||||
pkg.overrideAttrs (
|
||||
final: prev: {
|
||||
patches = (prev.patches or [ ]) ++ builtins.attrValues patches;
|
||||
scope = pkgs: lib.makeScope pkgs.newScope (
|
||||
self:
|
||||
lib.packagesFromDirectoryRecursive {
|
||||
callPackage = self.callPackage;
|
||||
directory = ./package;
|
||||
}
|
||||
// {
|
||||
jellyfin = (
|
||||
self.callPackage ./package/jellyfin/package.nix {
|
||||
jellyfin = pkgs.jellyfin;
|
||||
}
|
||||
);
|
||||
|
||||
in
|
||||
scan'directory package ./package;
|
||||
|
||||
plugins =
|
||||
pkgs:
|
||||
let
|
||||
plugin = name: path: (pkgs' pkgs).jellyfin.plugin path { };
|
||||
in
|
||||
scan'directory plugin ./plugin;
|
||||
}
|
||||
//
|
||||
lib.attrsets.mapAttrs'
|
||||
(name: value: {
|
||||
name = "jellyfin-plugin-${name}";
|
||||
value = value;
|
||||
})
|
||||
(
|
||||
lib.packagesFromDirectoryRecursive {
|
||||
callPackage = self.callPackage;
|
||||
directory = ./plugin;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
in
|
||||
{
|
||||
overlays.default = overlay;
|
||||
overlay = final: scope;
|
||||
|
||||
packages = per-pkgs (
|
||||
pkgs:
|
||||
(packages pkgs)
|
||||
// lib.attrsets.mapAttrs' (name: value: {
|
||||
name = "plugin-${name}";
|
||||
inherit value;
|
||||
}) (plugins pkgs)
|
||||
);
|
||||
legacyPackages = per-pkgs scope;
|
||||
|
||||
nixosModules =
|
||||
let
|
||||
directories = scan'directory (_: path: path) ./module;
|
||||
files = scan'nix (_: path: path) ./module;
|
||||
modules = directories // {
|
||||
default.imports = builtins.attrValues files ++ (directories.default or [ ]);
|
||||
};
|
||||
module =
|
||||
name: defs:
|
||||
{ ... }:
|
||||
{
|
||||
imports = lib.toList defs;
|
||||
config.nixpkgs.overlays = [ overlay ];
|
||||
};
|
||||
in
|
||||
builtins.mapAttrs module modules;
|
||||
packages = per-pkgs (pkgs: lib.filterAttrs (_: lib.isDerivation) (scope pkgs));
|
||||
|
||||
nixosModules.default = import ./module/default.nix scope;
|
||||
|
||||
formatter = per-pkgs ({ nixfmt-tree, ... }: nixfmt-tree);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue