flake: add modules, make lib compatible
This commit is contained in:
parent
b8e37d3eeb
commit
1071440ed1
@ -121,6 +121,8 @@
|
||||
# flake-parts imports
|
||||
imports = [
|
||||
./flake
|
||||
./lib/nixfiles/module.nix
|
||||
# ./pkgs/module.nix
|
||||
];
|
||||
|
||||
config = {
|
||||
|
@ -1,8 +1,27 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
{...} @ attrs: let
|
||||
# compatibility with old loading system (this looks awful fix this when i
|
||||
# fully migrate to flake-parts). this constructs an attrset that resembles
|
||||
# what the old args used to look like in attrs', so i don't have to rewrite
|
||||
# all of the glue. it creates a fake pkgs value containing only `lib`.
|
||||
#
|
||||
# actually no idk if i can fix this because it needs to be accessible from
|
||||
# everything (flake, nixos/home-manager modules, maybe derivations). this
|
||||
# might be the best way to do this so i can pass in either pkgs or lib based
|
||||
# on the current context, and just return relevant libraries based on that
|
||||
# input.
|
||||
#
|
||||
# create empty `pkgs` with lib only `lib` attr as fallback
|
||||
pkgs = attrs.pkgs or {inherit (attrs) lib;};
|
||||
# inherit lib from whatever `pkgs` happens to be
|
||||
inherit (pkgs) lib;
|
||||
|
||||
# compat
|
||||
attrs' = attrs // {inherit pkgs;};
|
||||
in
|
||||
{
|
||||
types = (import ./types.nix) { inherit pkgs; };
|
||||
minecraft = (import ./minecraft.nix) { inherit pkgs; };
|
||||
}
|
||||
{
|
||||
types = (import ./types.nix) attrs';
|
||||
}
|
||||
# only if an actual `pkgs` was passed
|
||||
// lib.optionalAttrs (attrs ? pkgs) {
|
||||
minecraft = (import ./minecraft.nix) attrs';
|
||||
}
|
||||
|
11
lib/nixfiles/module.nix
Normal file
11
lib/nixfiles/module.nix
Normal file
@ -0,0 +1,11 @@
|
||||
{lib, ...}: let
|
||||
inherit (lib) types;
|
||||
nixfiles-lib = (import ./.) {inherit lib;};
|
||||
in {
|
||||
options.nixfiles.lib = lib.mkOption {
|
||||
description = "nixfiles library";
|
||||
type = types.attrs;
|
||||
readOnly = true;
|
||||
default = nixfiles-lib;
|
||||
};
|
||||
}
|
51
pkgs/module.nix
Normal file
51
pkgs/module.nix
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
inputs,
|
||||
self,
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}: let
|
||||
cfg = config.nixfiles.outputs.packages;
|
||||
inherit (lib) mapAttrs mkEnableOption mkIf;
|
||||
in {
|
||||
options.nixfiles.outputs.packages = {
|
||||
enable =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
description = ''
|
||||
Whether to generate the packages output.
|
||||
'';
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
perSystem = {
|
||||
system,
|
||||
inputs',
|
||||
self',
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
packages = let
|
||||
inherit (pkgs) callPackage callPackages;
|
||||
|
||||
# i forget how this works so i'm not messing with it.
|
||||
mopidyPackages = callPackages ./mopidy {
|
||||
python = pkgs.python3;
|
||||
};
|
||||
in
|
||||
(mapAttrs (_: v: callPackage v {}) {
|
||||
google-fonts = ./google-fonts;
|
||||
wm-helpers = ./wm-helpers;
|
||||
atool = ./atool-wrapped;
|
||||
nixfiles-assets = ./nixfiles-assets;
|
||||
redlib = ./redlib;
|
||||
cross-seed = ./cross-seed;
|
||||
})
|
||||
// {
|
||||
inherit (mopidyPackages) mopidy-autoplay;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user